// limit formsubmits to one time
submitted = false;
suppressexitsurvey = false;
var expDays = 1; // number of days the cookie should last

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
function SetCookie (name, value) {//optionals: expires,path,domain,secure  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}



function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function exitsurvey(){
	if(!suppressexitsurvey)
		{
			var exp = new Date(); 
		exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
		var suppressES = GetCookie('suppressES');
		if (suppressES == null) 
			{
			suppressES=1;
			SetCookie('suppressES', suppressES, exp);
		
		
			if (window.is.nav)height=320; else height = 310;
			ST_popUp('exitsurvey.cfm','Exitsurvey',290,height,'Yes');
			}
		}
}

function gointernal(url)
{
	suppressexitsurvey = true;
	location.href = url;
}


function oldExitsurvey()
{
	var GettheCookie = GetCookie('suppressIT');
	if (GettheCookie != null){
	alert("NEQ -1 : found!");
		var start=pos + 11;
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = allcookies.length;
		var value= allcookies.substring(start,end);
		value=unescape(value);
	}
	else
		alert("EQ -1 :not found!");
	if(!suppressexitsurvey)
	{
		if (window.is.nav)height=662; else height = 520;
		ST_popUp('exitsurvey.cfm','Exitsurvey',260,height,'No');
		SetCookie('suppressIT','DoSuppression',1)
	}
}

function submitinternal(form,button,caption)
{                  
	if (!submitted) 
	{    
		suppressexitsurvey = true;
		submitted = true;
		if(button && caption){button.value = caption;}   
		form.submit();         
    }                 
} 


// standard way to open popUp
function ST_popUp(url, name, w, h, scroll)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
	win = window.open(url, name, winprops)
	if (parseInt(navigator.appVersion) >= 4) 
	{ 
		win.window.focus(); 
	}

}

// Standard way to collect parameters from popUps
function ST_collectparam (receiver,type,data){	
	if(type == 'divbyid')
		var str = 'document.getElementById(receiver)';
	else
		var str = 'document.'+ receiver;
		
	element = eval(str);
	
	if(type == 'select'){
		element.selectedIndex = data;
	}
	else if (type == 'text'){
		element.value = data;
	}
	else if (type == 'imagepath'){
		if(element){
			element.src=data;
		}
	}
	else if(type == 'divbyid'){
		element.innerHTML=data;
	}
	
	if(	element.onchange ) { element.onchange(); }
}

// Standard way to send parameters back to openers
function ST_sendparam (receiver,type,data){
	if (opener){
		if(opener.ST_collectparam){
			if(eval("opener.document." + receiver) || (eval("document.getElementById(\'"+ receiver + "\')" && type=="divbyid"))){
				opener.ST_collectparam(receiver, type ,data);
				if(arguments[3] == 'yes'){
					window.close();
				}
			}
			else{
				alert("An error has occured.  You may have performed an action out of sync \n or have navigated away from the parent page.  This window will now close");
				window.close();
			}
		}
		else {
			alert("An error has occured.  You may have performed an action out of sync.  This window will now close"); 	
			window.close();
		}
	}
	else{
		alert("An error has occured.  You may have performed an action out of sync.  This window will now close");
		window.close();
	}
}
// ClientSnifferJr Object Constructor
// Mike Foster, 12/12/01
// cross-browser.com

function ClientSnifferJr() {
  this.ua = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  // DOM Support
  if (document.addEventListener && document.removeEventListener) this.dom2events = true;
  if (document.getElementById) this.dom1getbyid = true;
  // Opera
  this.opera = this.ua.indexOf('opera') != -1;
  if (this.opera) {
    this.opera5 = (this.ua.indexOf("opera 5") != -1 || this.ua.indexOf("opera/5") != -1);
    this.opera6 = (this.ua.indexOf("opera 6") != -1 || this.ua.indexOf("opera/6") != -1);
    return;
  }
  // Konqueror
  this.konq = this.ua.indexOf('konqueror') != -1;
  // MSIE
  this.ie = this.ua.indexOf('msie') != -1;
  if (this.ie) {
    this.ie3 = this.major < 4;
    this.ie4 = (this.major == 4 && this.ua.indexOf('msie 5') == -1 && this.ua.indexOf('msie 6') == -1);
    this.ie4up = this.major >= 4;
    this.ie5 = (this.major == 4 && this.ua.indexOf('msie 5.0') != -1);
    this.ie5up = !this.ie3 && !this.ie4;
    this.ie6 = (this.major == 4 && this.ua.indexOf('msie 6.0') != -1);
    this.ie6up = (!this.ie3 && !this.ie4 && !this.ie5 && this.ua.indexOf("msie 5.5") == -1);
    return;
  }
  // Misc.
  this.hotjava = this.ua.indexOf('hotjava') != -1;
  this.webtv = this.ua.indexOf('webtv') != -1;
  this.aol = this.ua.indexOf('aol') != -1;
  if (this.hotjava || this.webtv || this.aol) return;
  // Gecko, NN4+, and NS6
  this.gecko = this.ua.indexOf('gecko') != -1;
  this.nav = (this.ua.indexOf('mozilla') != -1 && this.ua.indexOf('spoofer') == -1 && this.ua.indexOf('compatible') == -1);
  if (this.nav) {
    this.nav4  = this.major == 4;
    this.nav4up= this.major >= 4;
    this.nav5up= this.major >= 5;
    this.nav6  = this.major == 5;
    this.nav6up= this.nav5up;
  }
}

/* 
	Following 2 functions are called by form's onsubmit validation function
	(disable the submit at the start of function, then if returning fals, enable it again.
*/
function disablesubmit(submitobj){
	submitobj.value="Processing...";
	submitobj.disabled=true;
}

function enablesubmit(submitobj,origtext){
	submitobj.value=origtext;
	submitobj.disabled=false;
}

window.is = new ClientSnifferJr();

