d = document;

function inArray(val, arr){
	for (a = 0; a < arr.length; a++){
		if (arr[a] == val) return true;
	}
	return false;
}

function isArray(obj){
	if (obj.constructor.toString().indexOf('Array') == -1) return false;
	else return true;
}

function openAjax(responseDest, destType, openMethod, openURL){
	var xmlhttp;

	if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); //IE7+/C/FF/S/O
	else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE5-6
	else alert("Your browser does not support XMLHTTP!");

	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4){
			if (destType == 'innerHTML') document.getElementById(responseDest).innerHTML = xmlhttp.responseText;
			else if (destType == 'value') document.getElementById(responseDest).value = xmlhttp.responseText;
		}
	}

	xmlhttp.open(openMethod, openURL, true);
	xmlhttp.send(null);
}

/* AREA TOGGLERS - START */

	function toggleCheck(toggle, which){
		if (toggle) d.getElementById(which).style.display = 'none';
		else d.getElementById(which).style.display = 'block';
	}

	function toggleSelect(toggle, selectArray){

		selectArray = selectArray.split(',');
		for (i = 0; i < selectArray.length; i++){
			if (selectArray[i] === toggle) d.getElementById('country_' + toggle).style.display = 'block';
			else d.getElementById('country_' + selectArray[i]).style.display = 'none';
		}
	}

/* AREA TOGGLERS - END */

/* DROPDOWN NAV - START */

function sfHover() {
    var sfEls = document.getElementById("header").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}

/* DROPDOWN NAV - END */

/* FLASH PLAYER - START */

	l = location.href.toLowerCase();

	if (l.substr(0,5) == "https") thisProtocol = "https";
	else thisProtocol = "http";

	function activateControls(CLSID, Cbase, ObjectID, Width, Height, Movie, Loop, Menu, Quality, WMode){
		buildHTML = new String();
		buildHTML += '<object classid="'+CLSID+'" codebase="'+thisProtocol+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+Cbase+'" height="'+Height+'" id="'+ObjectID+'" width="'+Width+'">';
		buildHTML += '<param name="movie" value="'+Movie+'" />';
		buildHTML += '<param name="loop" value="'+Loop+'" />';
		buildHTML += '<param name="menu" value="'+Menu+'" />';
		buildHTML += '<param name="quality" value="'+Quality+'" />';
		buildHTML += '<param name="wmode" value="'+WMode+'" />';
		buildHTML += '<param name="allowScriptAccess" value="always" />';
		buildHTML += '<embed allowscriptaccess="always" height="'+Height+'" loop="'+Loop+'" menu="'+Menu+'" name="'+ObjectID+'" pluginspage="'+thisProtocol+'://www.macromedia.com/go/getflashplayer" quality="'+Quality+'" src="'+Movie+'" type="application/x-shockwave-flash" width="'+Width+'" wmode="'+WMode+'" />';
		buildHTML += '</object>';

		d.write(buildHTML);
	}

/* FLASH PLAYER - END */

/* CONTRACTOR POPUPS - START */

	pops = ['dairyhost' , 'ccprocessing' , 'rapidresponse' , 'safesoft'];

	function showPop(which, oWidth, oHeight) {
		if (typeof(window.innerWidth) == 'number') {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		} else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight)) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = d.documentElement.clientWidth;
		    myHeight = d.documentElement.clientHeight;
		} else if (d.body && (d.body.clientWidth || d.body.clientHeight)) {
		    //IE 4 compatible
		    myWidth = d.body.clientWidth;
		    myHeight = d.body.clientHeight;
		}

		leftSpace = (myWidth/2)-(oWidth/2);
		topSpace = (myHeight/2)-(oHeight/2);
		d.getElementById(which).style.display = 'block';
		d.getElementById(which).style.left = leftSpace;
		d.getElementById(which).style.top = topSpace;

		for (i = 0; i < pops.length; i++){
			if (pops[i] != which) d.getElementById(pops[i]).style.display = 'none';
		}
	}

	function hidePop(which){
		for (i = 0; i < pops.length; i++){
			d.getElementById(pops[i]).style.display = 'none';
		}
	}

	pops2 = ['bluebook'];

	function showPop2(which, oWidth, oHeight) {
		if (typeof(window.innerWidth) == 'number') {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		} else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight)) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = d.documentElement.clientWidth;
		    myHeight = d.documentElement.clientHeight;
		} else if (d.body && (d.body.clientWidth || d.body.clientHeight)) {
		    //IE 4 compatible
		    myWidth = d.body.clientWidth;
		    myHeight = d.body.clientHeight;
		}

		leftSpace = (myWidth/2)-(oWidth/2);
		topSpace = (myHeight/2)-(oHeight/2);
		d.getElementById(which).style.display = 'block';
		d.getElementById(which).style.left = leftSpace;
		d.getElementById(which).style.top = topSpace;

		for (i = 0; i < pops2.length; i++){
			if (pops2[i] != which) d.getElementById(pops2[i]).style.display = 'none';
		}
	}

	function hidePop2(which){
		for (i = 0; i < pops2.length; i++){
			d.getElementById(pops2[i]).style.display = 'none';
		}
	}

	pops3 = ['whatIsThis','businessservices1','safesoft'];

	function showPop3(which, oWidth, oHeight) {
		if (typeof(window.innerWidth) == 'number') {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		} else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight)) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = d.documentElement.clientWidth;
		    myHeight = d.documentElement.clientHeight;
		} else if (d.body && (d.body.clientWidth || d.body.clientHeight)) {
		    //IE 4 compatible
		    myWidth = d.body.clientWidth;
		    myHeight = d.body.clientHeight;
		}

		leftSpace = (myWidth/2)-(oWidth/2);
		topSpace = (myHeight/2)-(oHeight/2);
		d.getElementById(which).style.display = 'block';
		d.getElementById(which).style.left = leftSpace;
		d.getElementById(which).style.top = topSpace;

		for (i = 0; i < pops3.length; i++){
			if (pops3[i] != which) d.getElementById(pops3[i]).style.display = 'none';
		}
	}

	function hidePop3(which){
		for (i = 0; i < pops3.length; i++){
			d.getElementById(pops3[i]).style.display = 'none';
		}
	}

	pops4 = ['whatIsThis'];

	function showPop4(which, oWidth, oHeight) {
		if (typeof(window.innerWidth) == 'number') {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		} else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight)) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = d.documentElement.clientWidth;
		    myHeight = d.documentElement.clientHeight;
		} else if (d.body && (d.body.clientWidth || d.body.clientHeight)) {
		    //IE 4 compatible
		    myWidth = d.body.clientWidth;
		    myHeight = d.body.clientHeight;
		}

		leftSpace = (myWidth/2)-(oWidth/2);
		topSpace = (myHeight/2)-(oHeight/2);
		d.getElementById(which).style.display = 'block';
		d.getElementById(which).style.left = leftSpace;
		d.getElementById(which).style.top = topSpace;

		for (i = 0; i < pops4.length; i++){
			if (pops4[i] != which) d.getElementById(pops4[i]).style.display = 'none';
		}
	}

	function hidePop4(which){
		for (i = 0; i < pops4.length; i++){
			d.getElementById(pops4[i]).style.display = 'none';
		}
	}

/* CONTRACTOR POPUPS - END */
