//Pnf fix for IE
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)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         //don't touch images in user gallery, otherwise slideshow stops working
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG" && img.className != "usergallery")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='pngFix " + img.className + "' " : ""
            var sizingMethod = 'scale';
            var width = img.width;
            var height = img.height;
            if (img.className.indexOf('eaderClass')>-1) {
              sizingMethod = 'crop';
              width = 500;
              height = 20;
            }
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;visibility:normal !important;" + 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
            //if (img.display == "none") window.alert ("OMG");
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + width + "px; height:" + height + "px;" + imgStyle + "\;"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='" + sizingMethod + "');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

var FRAMEWINDOW_FIXED=0x1;
var FRAMEWINDOW_MODAL=0x2;
isIE=window.clientInformation?true:false;
isN4=document.layers?true:false;
isN6=navigator.appName=="Netscape"&&parseInt(navigator.appVersion)>=5;
isO5=navigator.userAgent.indexOf("Opera")!=-1&&parseInt(navigator.appVersion)>=4;
ie=document.all!=null&&!isO5;
if (ie) {
  window.attachEvent("onload", correctPNG);
}
safari=navigator.userAgent.indexOf("Safari")!=-1&&navigator.userAgent.indexOf("Safari/85")==-1;
moz=!ie&&!safari&&document.getElementById!=null&&document.layers==null&&navigator.userAgent.indexOf("Netscape/7.02")==-1&&(navigator.userAgent.indexOf("Gecko")||navigator.userAgent.indexOf("Firefox"));
mac=(navigator.userAgent.indexOf("Macintosh")!=-1||navigator.userAgent.indexOf("Mac_PowerPC")!=-1);
if(safari){
	document.write("<style> input.button, input.button[disabled] { font-size: 12px; } </style>");
}
var SSConstants={POPUPS_DISABLED_MESSAGE:"It appears that you may have a popup blocker enabled that is preventing the opening of a new window.  You should either disable your popup blocker, or explicitly allow this site to create popups.\n\nMore information on this problem is available in the Troubleshooting area of the FAQ from our front web site."};
function ql_nt(loc){
	n=new Array();
	qidx=loc.indexOf('?');
	if(qidx==-1){
		return(loc);
	}
	p=loc.substring(0,qidx);
	s=loc.substring(qidx+1).split('&');
	for(i=0;i<s.length;++i){
		if(!(s[i].indexOf('returnUrl')==0)&&!(s[i].indexOf('SS_CSAT')==0)&&!(s[i].indexOf('SS_SERIALIZED_FORM_STATE')==0)&&!(s[i].indexOf('SS_INPUT_FORM_STATE')==0)&&SS_INPUT_FORM_STATE.indexOf(s[i])==-1){
			n[n.length]=s[i];
		}
	}
	return(p+(n.length?'?':'')+n.join('&'));
}
function ql_sifs(){
	return(SS_INPUT_FORM_STATE?SS_INPUT_FORM_STATE:'');
}
function ql_sfs(){
	v='';
	f=document.getElementById('dataform');
	if(!f)
		f=document.dataform;
	if(f){
		for(i=0;i<f.elements.length;++i){
			e=f.elements[i];
			if(e.name.length&&e.type!='hidden'&&e.type!='password'&&e.name!='returnUrl'&&e.name!='cardNumber'&&e.name!='securityCode'&&e.name!='expriation'){
				v+=(v.length>0?'&':'')+escape(e.name)+'='+escape(e.value);
			}
		}
	}
	return(v);
}
function ql_csat(){
	var letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var i=30;
	var key=String();
	while(i-->0){
		key+=letters.charAt(Math.round(Math.random()*25));
	}
	return(key);
}
function deserializeFormState(state){
	f=document.getElementById('dataform');
	if(!f)
		f=document.dataform;
	if(f){
		s=state.split('&');
		for(i=0;i<s.length;++i){
			c=s[i].split('=');
			for(j=0;j<c.length;++j){
				e=f.elements[unescape(c[0])];
				if(e&&e.type!='hidden'){
					e.value=unescape(c[1]);
				}
			}
		}
	}
}
var Class={
	create:function(protoDef){
		var c;
		if(protoDef.initialize){
			c=function(){
				this.initialize.apply(this,arguments);
			};
		}
		else{
			c=function(){
			};
		}
		c.prototype=protoDef;
		for(property in protoDef){
			if(typeof(protoDef[property])!="function"){
				c[property]=protoDef[property];
			}
		}
		c.extend=function(protoDef){
			c=Class.create(protoDef);
			if(protoDef){
				var base=this;
				for(property in base.prototype){
					if(typeof(base.prototype[property])=="function"){
						c.prototype[property]=base.prototype[property];
					}
				}
			}
			return c;
		};
		return c;
	}
};
Function.prototype.bind=function(object){
	var method=this;
	return function(){
		method.apply(object,arguments);
	};
};
function disableButtonForAction(buttonObj){
	buttonObj.disabled='true';
}
function smartSubmit(buttonObj,formName){
	confirmPageExit=false;
	disableButtonForAction(buttonObj);
	document.forms[formName].submit();
	return true;
}
function smartLocation(buttonObj,loc){
	confirmPageExit=false;
	disableButtonForAction(buttonObj);
	document.location=loc;
	return true;
}
function smartGoBack(buttonObj){
	confirmPageExit=false;
	disableButtonForAction(buttonObj);
	history.go(-1);
	return true;
}
function smartCancel(){
	if(confirmPageExit&&!confirm("Are you sure you wish to navigate away from this page?\n\nYou have unsaved changes.  These changes will be lost if you leave this page\n\nPress OK to continue, or Cancel to stay on the current page.")){
		return;
	}
	confirmPageExit=false;
	if(window.parent.closeWindow){
		window.parent.closeWindow();
	}
	else{
		window.close();
	}
}
/*function with same name in framewindow.js
function openWindow(url,width,height,options){
	var w=window.open(url,"EditWindow"+Math.round(Math.random()*100000),"width="+width+",height="+height+",modal="+(options&FRAMEWINDOW_MODAL)+",scrollbars=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no");
	if(!w){
		alert(SSConstants.POPUPS_DISABLED_MESSAGE);
	}
}
*/
function getOpenerWindow(){
	return window.opener;
}
function getUsingFrameWindows(){
	return false;
}
function closeWindow(){
	window.close();
}
function scrollToElement(name){
	window.scrollTo(0,getYCoord(document.getElementById(name))-100);
}
functionMap=new Array();
oldButtonColors=new Array();
numericChars="0123456789";
function noop(){
}
function copyToClipboard(resourceName,str,resourceIsText){
	if(!resourceIsText){
		resourceName="\'"+resourceName+"\'";
	}
	if(window.ie){
		window.clipboardData.setData('text',str);
		showHelpTip(window.event,'<strong>URL Copied to Clipboard</strong><br/>The URL for '+resourceName+' has been copied to your clipboard.  To give this file to someone, simply paste this URL to them.');
	}
	else{
		showObject(document.getElementById("clipboardTextContainer"));
		document.getElementById("clipboardTextFilename").innerHTML=resourceName+" ";
		document.getElementById("clipboardTextContent").innerHTML=str;
	}
}
function urlAttributeAdjust(url,name,val){
	if(url.match(new RegExp("(\\?|\\&)"+name+"=([^&]*)","g"))){
		url=url.replace(new RegExp("(\\?|\\&)"+name+"=([^&]*)","g"),"$1"+name+"="+val);
	}
	else{
		if(url.indexOf("?")==-1){
			url=url+"?"+name+"="+val;
		}
		else{
			url=url+"&"+name+"="+val;
		}
	}
	return(url);
}
function inputContainsErrors(targetId){
	var titleObj=document.getElementById(targetId+'_title');
	if(titleObj){
		var scanDivs=titleObj.getElementsByTagName("div");
		for(var i=0;i<scanDivs.length;++i){
			if(scanDivs[i].className=="errorText"){
				return(true);
			}
		}
	}
	return(false);
}
function autoFocus(formName,defaultFocus){
	var f=document.forms[formName];
	if(!f)
		return;
	var elCount=f.elements.length;
	var errorsSeen=false;
	var focusEl=false;
	for(var i=0;i<elCount;++i){
		el=f.elements[i];
		if(el.type=='text'||el.type=='edit'||el.type=='password'||el.type=='textarea'||el.type=='checkbox'||el.type=='radio'||el.type=='select-one'){
			if(inputContainsErrors(el.id)&&!focusEl){
				errorsSeen=true;
				focusEl=el;
			}
			else if(defaultFocus&&!focusEl){
				focusEl=el;
			}
		}
	}
	if(focusEl)
		focusEl.focus();
}
function createBreakableUrl(v){
	if(safari){
		breakChar="&shy;";
	}
	else{
		breakChar="<wbr/>";
	}
	return(v.replace(new RegExp("&","g"),"&"+breakChar).replace(new RegExp("\\?","g"),"?"+breakChar).replace(new RegExp("/","g"),"/"+breakChar));
}
function initFormEffects(formName){
	if(!formName){
		formName="dataform";
	}
	var f=document.forms[formName];
	if(!f)
		return;
	var elCount=f.elements.length;
	for(var i=0;i<elCount;i++){
		el=f.elements[i];
		if(el.type=='text'||el.type=='edit'||el.type=='password'||el.type=='textarea'||el.type=='checkbox'||el.type=='select-one'||el.type=='input'){
			var inSequence=false;var elNum,elName;
			var n=el.name;
			for(j=0;j<n.length;j++){
				if(numericChars.indexOf(n.charAt(j))==-1)
					continue;
				elName=n.substring(0,j);
				elNum=n.substring(j);
				if(elNum!="1"&&document.getElementById(elName+'_title')){
					inSequence=true;
				}
				break;
			}
			if(inSequence){
				focusObjName=elName+'1_title';
			}
			else{
				focusObjName=el.name+'_title';
			}
			o=document.getElementById(focusObjName);
			if(o!=null){
				functionMap[el.name]=focusObjName;
				if(el.type=='checkbox'){
					functionMap[o.id]=focusObjName;
				}
				el.onfocus=function(){
					var o=document.getElementById(functionMap[this.name]);
					if(o)
						o.style.fontWeight='bold';
				};
				el.onblur=function(){
					var o=document.getElementById(functionMap[this.name]);
					if(o)
						o.style.fontWeight='normal';
				};
			}
		}
		else if(el.type=='button'||el.type=='submit'){
		}
	}
}
Date.prototype.getFullYear=function(){
	return(window.moz||window.safari?this.getYear()+1900:this.getYear());
};
String.prototype.trim=function(){
	return this.replace(/^\s+/,'').replace(/\s+$/,'');
};
String.prototype.endsWith=function(sEnd){
	return(this.substr(this.length-sEnd.length)==sEnd);
};
String.prototype.startsWith=function(sStart){
	return(this.substr(0,sStart.length)==sStart);
};
function trim(str){
	var idx_start=0;
	var idx_end=str.length-1;
	while(str.charAt(idx_start)==' '){
		idx_start++;
	}
	while(str.charAt(idx_end)==' '){
		idx_end--;
	}
	return(str.substr(idx_start,(idx_end-idx_start+1)));
}
function getMouseRelativeX(){
	return(parseInt(window.event.clientX));
}
function getMouseRelativeY(){
	return(parseInt(window.event.clientY));
}
function getMouseX(e){
	if(!e)
		var e=window.event;
	if(e.pageX)
		return e.pageX;
	return e.clientX+getViewportScrollX();
}
function getMouseY(e){
	if(!e)
		var e=window.event;
	if(e.pageY)
		return e.pageY;
	return e.clientY+getViewportScrollY();
}
function getWidth(obj){
	return(parseInt(obj.offsetWidth));
}
function getHeight(obj){
	return(parseInt(obj.offsetHeight));
}
function getLeft(obj){
	return(parseInt(obj.offsetLeft));
}
function getTop(obj){
	return(parseInt(obj.offsetTop));
}
function setLeft(obj,distance){
	obj.style.left=distance+"px";
}
function setTop(obj,distance){
	obj.style.top=distance+"px";
}
function getXCoord(obj){
	x=getLeft(obj);
	while(obj.offsetParent.tagName.toLowerCase()!="body"&&obj.offsetParent.tagName.toLowerCase()!="html"){
		obj=obj.offsetParent;
		if(obj.offsetParent.tagName.toLowerCase()!="form"){
			x+=getLeft(obj);
		}
	}
	return(x);
}
function getYCoord(obj){
	y=getTop(obj);
	while(obj.offsetParent.tagName.toLowerCase()!="body"&&obj.offsetParent.tagName.toLowerCase()!="html"){
		obj=obj.offsetParent;
		if(obj.offsetParent.tagName.toLowerCase()!="form"){
			y+=getTop(obj);
		}
	}
	return(y);
}
function isVisible(obj){
	return(obj.style.display!="none");
}
function hideObject(obj){
	if(obj)obj.style.display="none";
}
function showObject(obj){
	if(obj)obj.style.display="";
}
function toggleVisibility(obj){
	if(isVisible(obj)){
		hideObject(obj);
	}
	else{
		showObject(obj);
	}
}
function getWindowHeight(){
	if(ie){
		return(document.body.offsetHeight);
	}
	else{
		return(window.innerHeight);
	}
}
function getWindowWidth(){
	if(ie){
		return(document.body.offsetWidth);
	}
	else{
		return(window.innerWidth);
	}
}
function expandWindowHeight(factor){
	if(ie){
		window.resizeBy(0,factor);
	}
	else{
		window.innerHeight=window.innerHeight+factor;
	}
}
function expandWindowWidth(factor){
	if(ie){
		window.resizeBy(factor,0);
	}
	else{
		window.innerWidth=window.innerWidth+factor;
	}
}
function getWindowScroll(w){
	if(!w){
		if(document.documentElement&&document.documentElement.scrollTop){
			return document.documentElement.scrollTop;
		}
		else if(document.body.scrollTop){
			return document.body.scrollTop;
		}
		else if(window.pageYOffset){
			return window.pageYOffset;
		}
	}
	else{
		if(w.document.documentElement&&w.document.documentElement.scrollTop){
			return w.document.documentElement.scrollTop;
		}
		else if(w.document.body.scrollTop){
			return w.document.body.scrollTop;
		}
		else if(w.pageYOffset){
			alert(w.pageYOffset);
			return w.pageYOffset;
		}
	}
	return(0);
}
function getIFrameWindow(fName){
	if(window.safari){
		return(window.frames[fName]);
	}
	else{
		return(document.getElementById(fName).contentWindow);
	}
}
function suppressEnter(e,f){
	if(!e){
		e=window.event;
	}
	if(e.keyCode==13){
		if(f){
			f();
		}
		return false;
	}
	return true;
}
function getViewportHeight(){
	if(self.innerHeight){
		y=self.innerHeight;
	}
	else if(document.documentElement&&document.documentElement.clientHeight){
		y=document.documentElement.clientHeight;
	}
	else if(document.body){
		y=document.body.clientHeight;
	}
	return(y);
}
function getViewportWidth(){
	if(self.innerHeight){
		x=self.innerWidth;
	}
	else if(document.documentElement&&document.documentElement.clientHeight){
		x=document.documentElement.clientWidth;
	}
	else if(document.body){
		x=document.body.clientWidth;
	}
	return(x);
}
function getViewportScrollX(){
	if(self.pageYOffset){
		x=self.pageXOffset;
	}
	else if(document.documentElement&&document.documentElement.scrollTop){
		x=document.documentElement.scrollLeft;
	}
	else if(document.body){
		x=document.body.scrollLeft;
	}
	return(x);
}
function getViewportScrollY(){
	if(self.pageYOffset){
		y=self.pageYOffset;
	}
	else if(document.documentElement&&document.documentElement.scrollTop){
		y=document.documentElement.scrollTop;
	}
	else if(document.body){
		y=document.body.scrollTop;
	}
	return(y);
}
function toggleContentElement(srcCheckbox,tgtElement){
	if(srcCheckbox.checked){
		showObject(tgtElement);
	}
	else{
		hideObject(tgtElement);
	}
}
function toggleContentElementByValue(val,tgtElement){
	if(val){
		showObject(tgtElement);
	}
	else{
		hideObject(tgtElement);
	}
}
function setCookie(sName,sValue,expires,path,domain){
	document.cookie=sName+"="+escape(sValue)+"; expires="+(expires==null?new Date("January 1, 2023").toGMTString():expires)+"; path="+((path==null)?"/":path)+((domain==null)?"":"; domain="+domain);
}
function delCookie(sName,path,domain){
	document.cookie=sName+"="+escape(getCookie(sName))+";expires="+new Date("December 31, 1975").toGMTString()+"; path="+((path==null)?"/":path)+((domain==null)?"":"; domain="+domain);
}
function getCookie(sCookie){
	var aCookie=document.cookie.split(";");
	for(var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if(sCookie==trim(unescape(aCrumb[0]))){
			return(unescape(aCrumb[1]));
		}
	}
	return(null);
}
function getCookieDomain(fullhost){
	var hs=fullhost.split(".");
	if(hs.length-2<0){
		return("");
	}
	else{
		return("."+hs[hs.length-2]+"."+hs[hs.length-1]);
	}
}
function setRadioValue(formname,radioname,val){
	obj=document.forms[formname][radioname];
	for(i=0;i<obj.length;i++){
		if(obj[i].value==val)obj[i].checked=true;
	}
}
function getRadioValue(formname,radioname){
	obj=document.forms[formname][radioname];
	for(i=0;i<obj.length;i++){
		if(obj[i].checked)
			return(obj[i].value);
	}
}
function getRadio(formname,radioname,val){
	obj=document.forms[formname][radioname];
	for(i=0;i<obj.length;i++){
		if(obj[i].value==val)
			return(obj[i]);
	}
}
function getSelectOptionTitleByValue(formname,fieldName,val){
	obj=document.forms[formname][fieldName];
	for(var i=0;i<obj.length;++i){
		if(obj[i].value==val){
			return(obj[i].text);
		}
	}
	return(null);
}
function setFieldValue(formname,fieldName,val){
	obj=document.forms[formname][fieldName];
	if(obj.tagName.toLowerCase()=="select"){
		for(var i=0;i<obj.length;++i){
			if(obj[i].value==val){	
				obj.selectedIndex=i;
				break;
			}
		}
	}
	else{
		obj.value=val;
	}
}
function setFieldDisabled(formname,fieldName){
	obj=document.forms[formname][fieldName];
	obj.style.color='#727272';
	obj.style.backgroundColor='#F9F9F9';
	obj.readOnly=1;
}
function setFieldEnabled(formname,fieldName){
	obj=document.forms[formname][fieldName];
	obj.style.color='#000000';
	obj.style.backgroundColor='#FFFFFF';
	obj.readOnly=0;
}
function debug(msg){
	dm=document.getElementById("debugAreaMessages");
	if(!dm){
		da=document.createElement("div");
		da.id="debugArea";
		document.body.appendChild(da);
		dh=document.createElement("div");
		dh.id="debugAreaHeader";
		dh.innerHTML="Debug Messages";
		da.appendChild(dh);
		dm=document.createElement("div");
		dm.id="debugAreaMessages";
		da.appendChild(dm);
	}
	dm.style.bottom="0px";
	dm.style.right="0px";
	m=document.createElement("div");
	m.innerHTML=msg;
	dm.appendChild(m);
}
if(typeof aeOL=='undefined'){
	var aeOL=[];
	var addEvent=function(o,n,f,l){
		var d='addEventListener',h='on'+n,t,a;
		if(o[d]&&!l)
			return o[d](n,f,false);
		if(!o.aE){
			o.aE=aeOL.length||1;
			aeOL[o.aE]={o:o}
		}
		t=aeOL[o.aE][n]||(aeOL[o.aE][n]=[]);
		for(var i=0;i<t.length;i++)
			for(var j=0;j<t[i].length;j++)
				if(t[i][j]==f)
					return;
		if(o[h]&&o[h]._ae){
			a=t[t.length-1];
			a[a.length]=f;
		}
		else{
			t[t.length]=o[h]?[o[h],f]:[f];
			o[h]=new Function('e','var r = true, i = 0, o = aeOL['+o.aE+'].o,'+'a = aeOL['+o.aE+']["'+n+'"]['+(t.length-1)+'];'+'for (; i < a.length; i++) { '+'o._f = a[i]; r = o._f(e||window.event) != false && r; o._f = null;'+'} return r');
			o[h]._ae=1;
		}
	};
	var removeEvent=function(o,n,f,l){
		var d='removeEventListener',t,a,i,j,s;
		if(o[d]&&!l)
			return o[d](n,f,false);
		if(!o.aE||!aeOL[o.aE])
			return;
		t=aeOL[o.aE][n];
		i=t.length;
		while(i--){
			a=t[i];
			j=a.length;
			s=0;
			while(j--){
				if(a[j]==f)
					s=1;
				if(s)
					a[j]=a[j+1];
			}
			if(s){
				a.length--;
				break
			}
		}
	};
}


function positionFrame() {
  var baseHeight = 150;
  if (moz) { baseHeight -= 2; }
  var mainFrame = document.getElementById("main");
  if (ie) {
    mainFrame.style.height = (getWindowHeight() - baseHeight) + 'px';
    mainFrame.style.width  = (getWindowWidth()) + 'px';
  } else if (safari) {
    mainFrame.style.height = (getWindowHeight() - (baseHeight + 21)) + 'px';
    mainFrame.style.width  = (getWindowWidth() - 55) + 'px';
  } else {
    mainFrame.style.height = (getWindowHeight() - (baseHeight + 21)) + 'px'; // This is for FireFox
    mainFrame.style.width  = (getWindowWidth() - 25) + 'px';
  }
}