// JavaScript Document
var IE = document.all?true:false













var checkflag = "true";
function check(field) {
if (checkflag == "false") {
  for (i = 0; i < field.length; i++) {
  field[i].checked = true;}
  checkflag = "true";
  return ""; }
else {
  for (i = 0; i < field.length; i++) {
  field[i].checked = false; }
  checkflag = "false";
  return ""; }
}



function unCheckAll(field) {
  field[0].checked = false;
}





































//if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s

var posx = 0;
var posy = 0;

// Main function to retrieve mouse x-y pos.s
function flipDiv(divname, visibility){
	var obj = document.getElementById(divname);
	if(visibility == 'on'){
		obj.style.display = "block";
		obj.style.top =(posy -obj.offsetHeight - 5) + 'px';
		obj.style.left =posx+ 'px';
	}else{
		obj.style.display = "none";

	}

}
function flipDivLower(divname, visibility){
	var obj = document.getElementById(divname);
	if(visibility == 'on'){
		obj.style.display = "block"; 
		obj.style.top =(posy + 10) + 'px';
		obj.style.left =(posx - 100) + 'px';
	}else{
		obj.style.display = "none";
	
	}

}

function getMouseXY(e) {
 
	if (!e) var e = window.event;

	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{

		if(document.readyState == 'complete'){

		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	

} 




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];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuMarket(targ,selObj,restore,url){ //v3.1 Mike
	newLocation = url+selObj.options[selObj.selectedIndex].value;
  	eval(targ+".location='"+newLocation+"'");
if (restore) selObj.selectedIndex=0;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}











function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 setCookie(checkbox, name, value, hours)
{


//alert("name:" + name + "\n" + "value:" + value + "\n" + "checkbox.checked:" + checkbox.checked + "\n" + "hours:" + hours );
 
 
if (checkbox.checked || checkbox == true ) { 
 
  var expire = "";

	var cookie_name_orig = "";
	
	cookie_name_orig_value = readCookie( name );
		//alert( "Original " + name + ": " + cookie_name_orig_value );
		
	if (cookie_name_orig_value == null || cookie_name_orig_value == "" || cookie_name_orig_value == undefined || checkbox == true ) {
		value = value;
	}else{
		
		// not null
		value = cookie_name_orig_value + "," + value;
	}
			//alert( name + " new value : " + value );

	
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();
  }


}else{
	
	//delete the cookie value
	cookie_name_orig_value = readCookie( name );
	//alert(cookie_name_orig_value);
	
		if(cookie_name_orig_value != undefined){
		var cookie_items = cookie_name_orig_value.split(",");
		var cookie_item_newlength = cookie_items.length - 1;
		var new_cookie = "";
		
		for (var j = 0; j < cookie_items.length; j++) {
			//alert("value:" + value + "\n" + "cookie_items["+j+"]:" + cookie_items[j] + "\n" );
			if(cookie_items[j] != value && cookie_items[j] != "" && cookie_items[j] != null && cookie_items[j] != undefined && cookie_items[j] != "undefined" ){
				
				new_cookie += cookie_items[j]; 
				//alert ("Added cookie_items["+j+"]:" + cookie_items[j] );
				//alert ("if " + j +" < " + cookie_item_newlength );
				if (j < cookie_item_newlength ) {
					//alert ("Added comma ,");
					new_cookie += ",";
				}else{
					//last one, no comma	
				}
			}
		}

			//alert("old value:" + value + "\n" );
		if (new_cookie == "" || new_cookie == null || new_cookie == undefined ) {
			value = "";
		}else{
			value = new_cookie;
		}
			//alert("NEW value:" + value + "\n" );

	}

	
	
}

  document.cookie = name + "=" + escape(value) + ";" + expire + "; path=/";
		//alert("document.cookie:" + document.cookie + "\n" );

}






function deleteCookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString()+ "; path=/";

}


function getCookie(cookie_name) {

//' VBScrip Get cookie used.

}


function readCookie(name)

{

  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)

  { 
    offset = document.cookie.indexOf(search);

    if (offset != -1)

    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }

  }

  return cookieValue;

}



function textCounter(field, maxlimit) {
	
	if (field.value.length > maxlimit) {
		// if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	}else {
		// otherwise, update 'characters left' counter
		//countfield.value = maxlimit - field.value.length;
	}
}



function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


function updateLayer( wwwLocation ) {

	
	
	thepageFrame = new getObj("pageFrame").obj;
	thepageLayer = new getObj("pageLayer");
	
	thepageFrame.src = wwwLocation;
	
	if (window.innerHeight)	{
		  pos = window.pageYOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	}
	else if (document.body)	{
		  pos = document.body.scrollTop
	}



	screenWidth = window.screen.availWidth - 25;
	//screenWidth = window.screen.availWidth - 200;
	
	thepageLayer.style.width = screenWidth + "px";
	
	thepageLayer.style.top = pos + "px";

	

	

}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(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_showHideLayersResize() { //v6.1
  var i,p,v,obj,args=MM_showHideLayersResize.arguments;
  var h,left;
  for (i=0; i<(args.length-2); i+=3) 
  if ((obj=MM_findObj(args[i]))!=null) { 
  	v=args[i+2]; 
	h=args[i+2];
	left=args[i+2];
    if (obj.style) { 
		obj=obj.style; 
		v=(v=='show')?'visible':(v=='hide')?'hidden':v;
		h=(h=='show')?'500':(h=='hide')?'1':h;
		left=(left=='show')?'0':(left=='hide')?'-3000':left;
	 }
    
	obj.visibility=v; 

	obj.height = h;
	obj.left = left;
		
	}
}
 
 
 
function toggle(id) {
document.getElementById(id).style.visibility = 'visible';
if (document.getElementById(id).style.display == 'none'){
document.getElementById(id).style.display = '';
} else {
document.getElementById(id).style.display = 'none';
}
}





//GoogleFix for field backgrounds
if(window.attachEvent)
    window.attachEvent("onload",setListeners);
  
  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#ffffff"){
      //event.srcElement.style.backgroundColor = "#a0d0ff"; /* color of choice for AutoFill */
      event.srcElement.style.backgroundColor = "#ffffff"; /* color of choice for AutoFill */
      //document.all['googleblurb'].style.display = "block";
    }
}



