// JavaScript Document

var t; // Used for timed events

// Browser specific style sheets.
var userAgent=navigator.userAgent;
if ((userAgent.indexOf('Firefox') != -1) || (userAgent.indexOf('Netscape') != -1) || (userAgent.indexOf('Safari') != -1)) {
  	//document.write('<link href="/assets/styles/mozilla.css" rel="stylesheet" type="text/css" media="screen">');
}
if ((userAgent.indexOf('MSIE 6') != -1))  {
	document.write('<link href="/assets/styles/ie6.css" rel="stylesheet" type="text/css" media="screen">');
}
/*
if (userAgent.indexOf('Opera') != -1)  {
	document.write('<link href="/assets/styles/opera.css" rel="stylesheet" type="text/css" media="screen">');
}
*/
// End browser-specific style sheets

var x, y;
if (typeof self.innerHeight != "undefined") {
	x = self.innerWidth;
	y = self.innerHeight;
} else if (typeof document.compatMode != 'undefined' && document.compatMode == 'CSS1Compat') {
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
} else if (document.body) {
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}

if (x > 950) { // Use big.css
	document.write('<link href="/assets/styles/big.css" rel="stylesheet" type="text/css">');
}

function TW_changeStyle(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function process_brochure() {
	Spry.Utils.submitForm('BrochureForm', updateResponse_Brochure);
	TW_changeStyle('BrochureProcessing','showme');	
	pageTracker._trackPageview('brochure');
	return false;
}

function updateResponse_Brochure(req) {
	var response = req.xhRequest.responseText;
	var msg;

	switch (response) {
		case "blocked":
			msg = '<p class=alert>Your submission was blocked.</p>';
		break;
		case "success":
			msg = '<p class=alert>Thank you! Your request has been submitted.</p>';
			MM_swapImage('conversion','','http://www.googleadservices.com/pagead/conversion/1072716050/?label=-nVkCL24axCSssH_Aw&script=0',0);
		break;
		default:
			msg = '<p class=alert>The information you submitted is invalid.</p>';
	} // End switch		
	
	TW_changeStyle('BrochureProcessing','hideonscreen');	
	Spry.Utils.setInnerHTML('msg_brochure',msg);
}

function WAAddError(formElement,errorMsg,focusIt,stopIt)  {
  if (document.WAFV_Error)  {
	  document.WAFV_Error += "\n" + errorMsg;
  }
  else  {
    document.WAFV_Error = errorMsg;
  }
  if (!document.WAFV_InvalidArray)  {
    document.WAFV_InvalidArray = new Array();
  }
  document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
  if (focusIt && !document.WAFV_Focus)  {
	document.WAFV_Focus = focusIt;
  }

  if (stopIt == 1)  {
	document.WAFV_Stop = true;
  }
  else if (stopIt == 2)  {
	formElement.WAFV_Continue = true;
  }
  else if (stopIt == 3)  {
	formElement.WAFV_Stop = true;
	formElement.WAFV_Continue = false;
  }
}

function WAValidateRT(formElement,value,errorMsg,notAllowed,focusIt,stopIt,required)  {
  var isValid = true;
  var augValue = " " + value.toLowerCase() + " ";
  var tempVal = augValue;
  if ((!document.WAFV_Stop && !formElement.WAFV_Stop) && !(!required && value==""))  {
    var notAllowed = notAllowed.split(", ");
	for (var x=0; x<notAllowed.length; x++)  {
	  var notAllowedInfo = notAllowed[x].split("|");
	  notAllowedInfo[0] = unescape(notAllowedInfo[0]);
      notAllowedInfo[1] = unescape(notAllowedInfo[1]);
	  while (tempVal.indexOf(notAllowedInfo[0].toLowerCase())>=0)  {
	    isValid = false;
		var theIndex = tempVal.indexOf(notAllowedInfo[0].toLowerCase())
		tempVal = tempVal.substring(0,theIndex) + tempVal.substring(theIndex+notAllowedInfo[0].length);
		if (notAllowedInfo[1]!="")  {
          theIndex = augValue.indexOf(notAllowedInfo[0].toLowerCase())
		  augValue = augValue.substring(0,theIndex) + notAllowedInfo[1] + augValue.substring(theIndex+notAllowedInfo[0].length);
		}
	  }
	}
  }
  if (required && value=="")
    isValid = false;
  if (!isValid)  {
    WAAddError(formElement,errorMsg,focusIt,stopIt);
	formElement.value = augValue.substring(1,augValue.length-1);
  }
}

function WAAlertErrors(errorHead,errorFoot,setFocus,submitForm)  { 
  if (!document.WAFV_StopAlert)  { 
	  document.WAFV_StopAlert = true;
	  if (document.WAFV_InvalidArray)  {  
	    document.WAFV_Stop = true;
        var errorMsg = document.WAFV_Error;
	    if (errorHead!="")
		  errorMsg = errorHead + "\n" + errorMsg;
		if (errorFoot!="")
		  errorMsg += "\n" + errorFoot;
		document.MM_returnValue = false;
		if (document.WAFV_Error!="")
		  alert(errorMsg.replace(/"/g,'"'));
		else if (submitForm)
		  submitForm.submit();
	    if (setFocus && document.WAFV_Focus)  {
		  document.tempFocus = document.WAFV_Focus;
          setTimeout("document.tempFocus.focus();setTimeout('document.WAFV_Stop = false;document.WAFV_StopAlert = false;',1)",1); 
        }
        else {
          document.WAFV_Stop = false;
          document.WAFV_StopAlert = false;
        }
        for (var x=0; x<document.WAFV_InvalidArray.length; x++)  {
	      document.WAFV_InvalidArray[x].WAFV_Stop = false;
	    }
	  }
	  else  {
        document.WAFV_Stop = false;
        document.WAFV_StopAlert = false;
	    if (submitForm)  {
	      submitForm.submit();
	    }
	    document.MM_returnValue = true;
	  }
      document.WAFV_Focus = false;
	  document.WAFV_Error = false;
	  document.WAFV_InvalidArray = false;
  }
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}