// start footer stuff
function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	} else {
		if (document.documentElement 
			&& document.documentElement.clientHeight) {
				windowHeight=
					document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}

	return windowHeight;
}

function setFooter() {
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			var contentHeight=
				document.getElementById('end-of-content-marker').offsetTop;
			var footerElement=
				document.getElementById('footer');
			var wrapperElement=
				document.getElementById('#pagewrapper');
			var footerHeight=footerElement.offsetHeight;
			if (windowHeight-(contentHeight+footerHeight)>=0) {
				//footerElement.style.position='relative';
				//footerElement.style.top=(windowHeight-
				//(contentHeight+footerHeight))+'px';
				wrapperElement.style.height = '100%';
			} else {
				//footerElement.style.position='static';
				wrapperElement.style.height = 'auto';
			}
		}
	}
}

/*
window.onload = function() {
  setFooter();
}

window.onresize = function() {
  setFooter();
}
*/


// end footer stuff

// start QueryString stuff
function QueryString(key)
{
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;		
		}
	}

}

QueryString_Parse();
// end QueryString stuff

// start SafeOnLoadStuff
// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;

IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

IE5plus = IE5 || IE6;
IEMajor = 0;

if (IE4plus)
{
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
	IE5plus = (IEMajor>=5) ? true : false;
}

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
	else if (window.onload)
	{
		if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
		window.onload = f;
}

function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]();
}
// end SafeOnLoadStuff

// start cookies
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString()
		 + ";domain=www.iosart.com" 
		 + ";path=/";
}

function GetCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
// end cookies

function showDropDownMenu(arrowElem, labelElem, menuElem) {
    if (Element.visible(menuElem)) return false;

	Element.show(menuElem);
       
    if (labelElem) { 
		Element.addClassName(labelElem, 'active');
	} 

	Element.addClassName(arrowElem, 'drop-down-menu-arrow-active');
        
              
    var shimElem = $(menuElem.id + '-shim');
    if (shimElem) { 
        shimElem.style.top = menuElem.style.top;
        shimElem.style.right = menuElem.style.right;        
        shimElem.style.width = (menuElem.offsetWidth + 2) + 'px';
        shimElem.style.height = (menuElem.offsetHeight + 2) + 'px';
		Element.show(shimElem);
    }

	var firstTime = true;    
	var hideMenuFunc = function(e) {
		if (firstTime) {
				firstTime = false;
				return;
		}
        Element.hide(menuElem);
	    if (labelElem) { 
			Element.removeClassName(labelElem, 'active');
		} 
		Element.removeClassName(arrowElem, 'drop-down-menu-arrow-active');
             
        var shimElem = $(menuElem.id + '-shim');
        if (shimElem) {
			Element.hide(shimElem);            
        }
        Event.stopObserving(document,'click',hideMenuFunc);
    }   
  
    Event.observe(document,'click', hideMenuFunc);    	
    
	return false;
}
