var subMenu = 0;
var ready = false;

// MOUSEOVER ACTIONS
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

var foreshadow = 100;
var countFresh = 50;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();
	
	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
		
	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
}

// close showed layer
function mclose()
{
	if(ddmenuitem){ 
		ddmenuitem.style.visibility = 'hidden';
	}
	try{
		subMenu.style.visibility = 'visible';
		ddmenuitem = subMenu;
	}catch(err){
		
	}
}
function mcloseAll()
{
	if(ddmenuitem){
		ddmenuitem.style.visibility = 'hidden';
	}
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
try{
	document.onclick = mcloseAll();
}catch(Err){
	// windows fix;
}

// Find Page Section

// HELLO WORLD 
function sayHello() 
{
	alert('hello');
}

// SET NAV TO REFLECT CURRENT SECTION 
function setNavSection(section)
{
	
	if(section !=1){
		var subSection = section;
		if(subSection == 'WhoWeAre' || subSection == 'OurCoffee' || subSection == 'OurPractices'){
		
		if(subSection =='OurCoffee'){
			var a = document.getElementById('OC');
			a.className="subFocus";
		}
		if(subSection =='WhoWeAre'){
			var a = document.getElementById('WWA');
			a.className="subFocus";
		}
		if(subSection =='OurPractices'){
			var a = document.getElementById('OP');
			a.className="subFocus";
		}
			var button = document.getElementById('aboutButton');
			subMenu = 'aboutSub'; 
   			button.className = 'showAbout';
   			
		}else if(subSection == 'Initiatives' || subSection == 'OurCampaign' || subSection == 'Partners' || subSection == 'Fundraising' || subSection == '12'){
			
			if(subSection =='Initiatives'){
				var a = document.getElementById('JI');
				a.className="subFocus";
			}
			if(subSection =='OurCampaign'){
				var a = document.getElementById('JOC');
				a.className="subFocus";
			}
			if(subSection =='Partners'){
				var a = document.getElementById('JP');
				a.className="subFocus";
			}
			if(subSection =='Fundraising'){
				var a = document.getElementById('JF');
				a.className="subFocus";
			}
			if(subSection =='12'){
				var a = document.getElementById('JP');
				a.className="subFocus";
			}
			
			
			var button = document.getElementById('justiceButton');
			subMenu = 'justiceSub';
			var showSub = document.getElementById(subMenu); 
   			button.className = 'showJustice';
		}else if(subSection =='Blog' || subSection == '?cat=3'){
			
			var button = document.getElementById('communityButton');
			//subMenu = 'communitySub';
			//var showSub = document.getElementById(subMenu);
   			button.className = 'showCommunity';
		}
		
		var showSub = document.getElementById(subMenu);
   		showSub.style.visibility='visible';
   		
   		try{
   			subMenu = showSub;
   			ddmenuitem = showSub;
   		}catch(err){
   			alert(err);
   		}
   		
   	}else{
   		
   	}
}


	 

var qsParm = new Array();

function qs() {

	var query = window.location.href.toString();
	
	var pos = query.indexOf('/',10);
	
	section = query.substring(pos+1);
	try{
		setNavSection(section);
	}catch(err){
		//IE Error;
	}
}

function checkEnter(e, box) //e is event object passed from function invocation
{ 
	var characterCode //literal character code will be stored in this variable
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property 
	}else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		location = "http://www.fullcircleexchange.com/?s=" + box.value;  
	}else{
		
	}
}

function popForm()
{
	window.open('http://www.fullcircleexchange.com/wp-content/themes/FCE/static_blocks/getStartedForm.php', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=850,height=350'); 
}