//smk_faq.js file from version: Mootools Suite v1.1p3 bug-fix:2
function mooAcc_onC(toggler,element,me){
	var i=0;
	var me = me.elements;
	while(me[i]){
		((me[i].offsetHeight > 0)?me[i].setStyle('height', 'auto'):'');
		i++;
	}
}

function mooAcc_onB(toggler,element,me){
	var i=0;
	var me = me.elements;
	while(me[i]){
		((me[i].offsetHeight > 0)?me[i].setStyle('height', me[i].offsetHeight):'');
		i++;
	}
}

function mooCC(acc,accString,opener,delay,divs){
	
	var mooCookie, mooIndex;
	mooCookie = Cookie.get('mO_'+accString);
	if(mooCookie != false && mooCookie != null){
		mooIndex = mooArrayCheck(divs,mooCookie);
	}
//alert(mooIndex);
	if(mooIndex >= -1){
		var temp = function(){acc.display(mooIndex);}.delay(0);
		return true;
	}else{
		var temp = function(){acc.display(opener);}.delay(delay);
		return true;
	}
	return false;
}

var mooCookieCheck = mooCC;

function mooAccOpen(acc,id){
//alert(acc);
	//is some leaf in acc open?
	if(!acc.options.alwaysHide) return true; //by definition, there is an open leaf
	
	for(var i in acc.elements){
		if(acc.elements[i] && acc.elements[i].style && ((acc.options.height && acc.elements[i].offsetHeight > 0) || (acc.options.opacity && acc.elements[i].style.opacity > 0))){
			return true;
		}
	}
	return false;
}

function addObjEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

//Tim, Thanks for the idea of the above function to add to the current window.onload event

function mooArrayCheck(myArray,myId){
	if(parseInt(myId) == myId) return myId;
	for(var i in myArray){
		if(myArray[i].id == myId){
			return i;
		}
	}
	return -1;
}

function smkShowHide(smkItem,hide){
	if (document.getElementById){
		// this is the way the standards work
		var style2 = document.getElementById(smkItem).style;
	}else if (document.all){
		// this is the way old msie versions work
		var style2 = document.all[smkItem].style;
	}else if (document.layers){
		// this is the way nn4 works
		var style2 = document.layers[smkItem].style;
	}
	if(style2){
		if(hide === true){
			style2.height = "0px"; return true;
		}else if(hide == 'open'){
			style2.height = "auto"; return true;
		}
		style2.height = style2.height == "0px"? "auto":"0px";
	}
}


function smkShowHideDisplay(smkItem,hide){
	if (document.getElementById){
		// this is the way the standards work
		var style2 = document.getElementById(smkItem).style;
	}else if (document.all){
		// this is the way old msie versions work
		var style2 = document.all[smkItem].style;
	}else if (document.layers){
		// this is the way nn4 works
		var style2 = document.layers[smkItem].style;
	}
	if(style2){
		if(hide === true){
			style2.display = "none"; return true;
		}else if(hide == 'open'){
			style2.display = "block"; return true;
		}
		style2.display = style2.display == "none"? "block":"none";
	}
}

/*	dynamicCSS.js v1.0 <http://www.bobbyvandersluis.com/articles/dynamicCSS.php>
	Copyright 2005 Bobby van der Sluis
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
	tweaked by weaver to only create and share one <style> tag
*/

var createStyleRuleTagLocation;

function createStyleRule(selector, declaration){
	if (!document.getElementsByTagName || !(document.createElement || document.createElementNS)) return;
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_iewin = (is_ie && (agt.indexOf("win") != -1));
	var is_iemac = (is_ie && (agt.indexOf("mac") != -1));
	if (is_iemac) return; // script doesn't work properly in IE/Mac
	
	if(!createStyleRuleTagLocation){
		var head = document.getElementsByTagName("head")[0]; 
		var style = (typeof document.createElementNS != "undefined") ?	 document.createElementNS("http://www.w3.org/1999/xhtml", "style") : document.createElement("style");
		if (!is_iewin) {
			var styleRule = document.createTextNode(selector + " {" + declaration + "}");
			style.appendChild(styleRule); // bugs in IE/Win
		}
		style.setAttribute("type", "text/css");
		style.setAttribute("media", "screen"); 
		head.appendChild(style);
		if (is_iewin && document.styleSheets && document.styleSheets.length > 0) {
			createStyleRuleTagLocation = document.styleSheets[document.styleSheets.length - 1];
		}
	}
	if (createStyleRuleTagLocation && typeof(createStyleRuleTagLocation.addRule) == "object") { // bugs in IE/Mac and Safari
		createStyleRuleTagLocation.addRule(selector, declaration);
	}
}

function smkDocumentAddTag(id,tag,content,aa){
	addObjEvent(window,'load',function(){
		if(document.getElementById){
			var myPos = document.getElementById(id);
				//myPos.style.display = null;
			var myTag = (typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", tag) : document.createElement(tag);
			if(aa){
				for(i=0;i<aa.length;i+=2){
					if(myPos.getAttribute(aa[i])) aa[i+1] += ' '+myPos.getAttribute(aa[i]);
					myPos.setAttribute(aa[i],aa[i+1]);
				}
			}
			var myContent = document.createTextNode(content);
			myTag.appendChild(myContent);
			
			var myHtml = myPos.appendChild(myTag);
		}
		
		//unhider
		faqUnHide(id);
	});
}

function smkDocumentWriteBR(id){
	addObjEvent(window,'load',function(){
		if(document.getElementById){
			var myPos = document.getElementById(id);
				//myPos.style.display = null;
			var myTag = (typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", "br") : document.createElement("br");
			var myHtml = myPos.appendChild(myTag);
		}
		//unhider
		faqUnHide(id);
	});
}

function faqUnHide(id){
	try{
		document.getElementById(id).style.display='';
	}catch(er){
		//alert(id+'\n\n'+er);
	}
}

smkUnHide = faqUnHide;

function smkDocumentAddTagAfter(refChildId,newTag,content,aa){
	if(document.getElementById){
		var myPos = document.getElementById(refChildId);
		var myTag = (typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", newTag) : document.createElement(newTag);
		if(aa){
			for(i=0;i<aa.length;i+=2){
				if(myTag.getAttribute(aa[i])) aa[i+1] += ' '+myTag.getAttribute(aa[i]);
				myTag.setAttribute(aa[i],aa[i+1]);
			}
		}
		if(content){
			var myContent = document.createTextNode(content);
			
			myTag.appendChild(myContent);
		}
		myPos.parentNode.insertBefore(myTag,myPos.nextSibling);
	}
}
