function fixflashinie() {
	theObjects = document.getElementsByTagName("object"); 
	for (var i = 0; i < theObjects.length; i++) { 
	theObjects[i].outerHTML = theObjects[i].outerHTML; 
	} 
}

function isFilled(elm) {
	//alert(elm.type);
	//Last Updated by Sol - 6/5/07
	switch(elm.type){
	case "text":
		if (elm.value == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "password":
		if (elm.value == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "textarea":
		if (elm.value == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "select-one":
		var myindex=elm.selectedIndex;
		if (myindex==0){
		return false;}
		else {return true;}
		break;
	}
}

function validEmail(email) {
			var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			return re.test(email); 
		}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function validateform(formname){
	//last updated on 6/14/07
	//index of is mo betta
	var x = document.forms[formname];
	var allgood = true;
	for (var i=0;i<x.length;i++){
		if (x.elements[i].className.indexOf('required')>-1) {
		 	var thisformname = x.elements[i].name;
			var thisformid = x.elements[i].id;
			if (!isFilled(x.elements[i])) {
				document.getElementById(thisformid).style.background = "yellow";
				allgood = false;
				} else {
				  document.getElementById(thisformid).style.background = "#ffffff"; 
				}
			}
		}
		if (allgood) {
			return true;
			} else {
			return false;
			}
	}

function ordersupplies(formname,validateid,ajaxpage){
	//VALIDATE REQUIRED
	if(validateform(formname)){				
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "yellow"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {	
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) { 
			document.getElementById('submitform').innerHTML = '';
			document.getElementById(validateid).innerHTML = transport.responseText;	
			Effect.Appear(validateid,'blind');
			
			}//-onSuccess
			}//-request arguments
			);// new ajax request	
			}
	}
}

function ordersupplies1(formname,validateid,ajaxpage){
	//VALIDATE REQUIRED
	if(validateform(formname)){				
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "yellow"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {	
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) { 
			if (transport.responseText.indexOf('Thank')>-1){
			document.getElementById('submitform').innerHTML = '';
			}
			document.getElementById(validateid).innerHTML = transport.responseText;	
			Effect.Appear(validateid,'blind');
			
			}//-onSuccess
			}//-request arguments
			);// new ajax request	
			}
	}
}

function ordersupplies2(formname,validateid,ajaxpage){
	var darthvader = document.getElementById("darthvader").value;
	if(darthvader != ''){
	document.getElementById(validateid).innerHTML = 'Please turn on CSS in your browser. It appears that you are not human.';	
	} else {
		//VALIDATE REQUIRED
		if(validateform(formname)){				
		
			//EMAIL IS VALID?
			var email = document.getElementById("email").value;
			if(!validEmail(email)){
				document.getElementById("email").style.background = "yellow"; 
				document.getElementById(validateid).innerHTML = 'Invalid Email';
				if (document.getElementById(validateid).style.display == "none"){
						Effect.Appear(validateid,'blind');
						} else {
						Effect.Shake(validateid);
						}
				} else {	
				//AJAX POST
				new Ajax.Request(ajaxpage, {
				method: "post",
				parameters: Form.serialize(document.forms[formname]),
				onComplete: function(transport) { 
				if (transport.responseText.indexOf('Thank')>-1){
				document.getElementById('submitform').innerHTML = '';
				}
				document.getElementById(validateid).innerHTML = transport.responseText;	
				Effect.Appear(validateid,'blind');
				
				}//-onSuccess
				}//-request arguments
				);// new ajax request	
				}
		}
	}
}

function ordersupplies3(formname,validateid,indicatorid,ajaxpage){
	var darthvader = document.getElementById("darthvader").value;
	if(darthvader != ''){
	document.getElementById(validateid).innerHTML = 'Please turn on CSS in your browser. It appears that you are not human.';	
	} else {
		//VALIDATE REQUIRED
		if(validateform(formname)){				
		
			//EMAIL IS VALID?
			var email = document.getElementById("email").value;
			if(!validEmail(email)){
				document.getElementById("email").style.background = "yellow"; 
				document.getElementById(validateid).innerHTML = 'Invalid Email';
				if (document.getElementById(validateid).style.display == "none"){
						Effect.Appear(validateid,'blind');
						} else {
						Effect.Shake(validateid);
						}
				} else {
				document.getElementById(indicatorid).style.display = "block";
				//AJAX POST
				new Ajax.Request(ajaxpage, {
				method: "post",
				parameters: Form.serialize(document.forms[formname]),
				onComplete: function(transport) { 
				if (transport.responseText.indexOf('Thank')>-1){
				document.getElementById('submitform').innerHTML = '';
				}
				document.getElementById(indicatorid).style.display = "none";
				document.getElementById(validateid).style.display = "block";
				document.getElementById(validateid).innerHTML = transport.responseText;	
				Effect.Appear(validateid,'blind');
				
				}//-onSuccess
				}//-request arguments
				);// new ajax request	
				}
		}
	}
}
	
function contactus(formname,validateid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname)){				
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "yellow"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) { 
			document.getElementById('submitform').innerHTML = '';
			document.getElementById(validateid).innerHTML = transport.responseText;	
			Effect.Appear(validateid,'blind');
			
			}//-onSuccess
			}//-request arguments
			);// new ajax request	
			}
	}
}

function contactus1(formname,validateid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname)){				
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "yellow"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) { 
			if (transport.responseText.indexOf('Thank')>-1){
			document.getElementById('submitform').innerHTML = '';
			}
			document.getElementById(validateid).innerHTML = transport.responseText;	
			Effect.Appear(validateid,'blind');
			
			}//-onSuccess
			}//-request arguments
			);// new ajax request	
			}
	}
}

function contactus2(formname,validateid,ajaxpage) {
	var darthvader = document.getElementById("darthvader").value;
	if(darthvader != ''){
	document.getElementById(validateid).innerHTML = 'Please turn on CSS in your browser. It appears that you are not human.';	
	} else {
	//VALIDATE REQUIRED
		if(validateform(formname)){					
			//EMAIL IS VALID?
			var email = document.getElementById("email").value;
			if(!validEmail(email)){
				document.getElementById("email").style.background = "yellow"; 
				document.getElementById(validateid).innerHTML = 'Invalid Email';
				if (document.getElementById(validateid).style.display == "none"){
						Effect.Appear(validateid,'blind');
						} else {
						Effect.Shake(validateid);
						}
				} else {
				//AJAX POST
				new Ajax.Request(ajaxpage, {
				method: "post",
				parameters: Form.serialize(document.forms[formname]),
				onComplete: function(transport) { 
				if (transport.responseText.indexOf('Thank')>-1){
				document.getElementById('submitform').innerHTML = '';
				}
				document.getElementById(validateid).innerHTML = transport.responseText;	
				Effect.Appear(validateid,'blind');
				
				}//-onSuccess
				}//-request arguments
				);// new ajax request	
				}
		}
	}
}
	
	

	
function hidenav(location) {
	var count = 1
	var msg = "";
	for (var i = 1; i <= count; i++)
	   {
	   if (i != location) {
	   		
			//Effect.Fade('list' + i);	
			document.getElementById('list' + i).style.display = 'none';	
	   		msg = msg + i + "\n";
			//alert(msg);
	   }
	   }
}

function changefontsize(whichway,divtochange,increment){
	var bodytext = document.getElementById(divtochange)
	var defaulttextsize = $(bodytext).getStyle('font-size')
	var fontmeasurement = right(defaulttextsize,2);
	defaulttextsize = defaulttextsize.replace(fontmeasurement,'');
	//defaulttextsize = defaulttextsize.substring(0,2);
	
	var numValue = Number(defaulttextsize);
	if (whichway == "up"){
		var newNalue = numValue + increment;
	} else {
		var newNalue = numValue - increment;
	}
	document.getElementById(divtochange).style.fontSize = newNalue + fontmeasurement;
	document.getElementById("fontsize").innerHTML = newNalue + fontmeasurement;
}


function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function rolloverInit(){
	
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].getAttribute('name') == "rollover") {			
			setupRollover(document.images[i]);
		}
	}
}

function setupRollover(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	thisImage.overImage = new Image();
	thisImage.overImage.src = "/gl_images/nav/on/" + thisImage.id + ".gif";
	thisImage.onmouseover = rollOver;	
}

function rollOver() {
	this.src = this.overImage.src;
}

function rollOut() {
	this.src = this.outImage.src;
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {	
   	  //var element = document.getElementById(id);
	  //element.style.backgroundImage = "url("+image+")";
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='none');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

function assets(){
	var x=document.getElementsByTagName("div");
	for (var i=0;i<x.length;i++)
  	{
	if (x[i].id.indexOf("assetbox")>-1){
		//alert('a');
		var element = document.getElementById(x[i].id);
		element.style.cssFloat = 'left !important';
		element.style.width = '150px';
		element.style.height = '200px';
		element.style.border = '1px #dddddd solid';
		element.style.background = 'white';
		element.onmouseover = assetrollover;
		element.onmouseout  = assetrollout;
		element.onclick = assetclickme;
	}
  	}
}

function assetclickme(){
	var theid = this.id.replace('assetbox','');
	var linkid = 'link' + theid
	var thelink = document.getElementById(linkid).href;
	window.open(thelink);
}

function assetrollover(){
	this.style.border = '1px #4471b9 solid';
	this.style.backgroundColor='#F9F9F9';
	this.style.cursor = 'pointer';
	this.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=40);-moz-opacity:.4;';
}

function assetrollout(){
	this.style.border = '1px #dddddd solid';
	this.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100);-moz-opacity:1;';
	this.style.backgroundColor='white';
}

window.onload = masterloader;

function masterloader(){
	rolloverInit();
	correctPNG();
	assets();
}
