// Top menu image rollover
/*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_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;
  showHideSelect(1);
}
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_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_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_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
	showHideSelect(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_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];}
}*/

// hide show select boxes in IE browser
function showHideSelect(show) {	
	if(browser.IE) {
		var aSel = document.getElementsByTagName("SELECT");
		
		for(var x=0;x<aSel.length; x++) {
		
			if(show) {
				aSel[x].style.display = "inline";
			} else {
				aSel[x].style.display = "none";
			}
		} 
	}
}


function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}



var browser = new dudiBrowser();
	
// Determine browser
function dudiBrowser() {
	var agt=navigator.userAgent.toLowerCase();
	
	// is DOM
	this.DOM = document.getElementById?1:0;
	
	// is IE
	this.IE = document.all?1:0;
	
	// is IE
	this.IE5 = this.IE?(document.hasFocus?0:1):0;
	
	// is NS
	this.NS = (!this.DOM && !this.IE)?1:0
	
	// is on mac
	this.MAC = (agt.indexOf("mac")!=-1);

	// is on mac safari
	this.SAFARI = (agt.indexOf("safari")!=-1);
	
	// is on win 98
    this.WIN9X = (agt.indexOf("windows 9")!=-1);
	
	// is firefox
	this.FIREFOX = (agt.indexOf("firefox")!=-1);
}

function dudiObject(id) {
	
	this.obj = browser.NS?document.layers[id]:browser.DOM?document.getElementById(id):document.all[id];
	this.elm = browser.NS?eval("document."+id):document;
	this.css = browser.NS?eval("document."+id):(browser.DOM || browser.IE)?this.obj.style:"NaN";
	
	return this;
}

/*¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤*/
/* Imagefader object */
/*¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤*/

function imageFader() {
	
	this.arrImages 		= 	new Array();
	this.fadetime		= 	20;
	this.stoptime		= 	5000;
	this.fadekey		= 	0;
	this.directionUp	= 	1;
	this.intervals		=   50;
	this.fadinginterval	= 	100/this.intervals;
	this.currentfading1	= 	0;
	this.currentfading2	= 	100;
	this.link			=   "";
	
	this.addImage 		= 	function(src,link) {
								var tempImage = new Image();
								tempImage.src = src;
								if(link) {
									tempImage.link = link;
								}
								
								this.arrImages[this.arrImages.length] = tempImage;
								
					  		}

	this.executeFade 	=	function() {
	
								// setting first image 
								this.image1	= document.images["image1"];
								this.image2	= document.images["image2"];
								
								if(this.arrImages[this.fadekey].link) {
									this.link = document.getElementById('linkRandom').href;
									document.getElementById('linkRandom').href = this.arrImages[this.fadekey].link;
								}
								
								
								// use stoptime
								this.tempTimeout = window.setTimeout('fader.nextSequence()',this.stoptime);
							}
	
	this.fadeImages		= 	function() {
								// which picture to replace?
								
								if(this.directionUp) {
									if(browser.DOM) {
										this.image2.src = this.arrImages[this.fadekey].src;
									}
								} else {
									this.image1.src = this.arrImages[this.fadekey].src;
								}
								this.fadeSequence(this.intervals);
							}
	
	this.fadeSequence	=	function(fadeerintervals) {
								if(fadeerintervals > 0 && browser.DOM) {
									this.tempTimeout = window.setTimeout('fader.fade(' + (fadeerintervals-1) +')',this.fadetime);
								} else {
									
									if(this.arrImages[this.fadekey].link) {
										document.getElementById('linkRandom').href = this.arrImages[this.fadekey].link;
									} else {
										document.getElementById('linkRandom').href = this.link;
										
									}
									
									// use stoptime
									this.tempTimeout = window.setTimeout('fader.nextSequence()',this.stoptime);
									
								}
							}
							
	this.nextSequence	=	function() {
								this.fadekey++;
								if(this.fadekey == this.arrImages.length) {
									this.fadekey = 0;
								}
								this.directionUp = this.directionUp?0:1;
								this.fadeImages();
							
							}
							
	this.fade			=	function(fadeerintervals) {
								if(browser.DOM) {
									if(this.directionUp) {
										this.currentfading1 = this.currentfading1 - this.fadinginterval;
										this.currentfading2 = this.currentfading2 + this.fadinginterval;
									} else {
										this.currentfading1 = this.currentfading1 + this.fadinginterval;
										this.currentfading2 = this.currentfading2 - this.fadinginterval;
										
									}
									
									// negative fading
									if(!browser.IE) {
										if(this.currentfading1/100 == 1) {
											this.currentfading1/100;
										} else if (this.currentfading1/100 == 0) {
											this.image1.style.opacity = 0.01;
										} else {
											this.image1.style.opacity = this.currentfading1/100;
										}
										
									} else {
										this.image1.style.filter = "alpha(opacity="+ this.currentfading1 +");"; 
									}
									// positive fading
									if(!browser.IE ) {
										if(this.currentfading2/100 == 1) {
											this.image2.style.opacity = 0.99;
										} else if (this.currentfading2/100 == 0) {
											this.image2.style.opacity = 0.01;
										} else {
											this.image2.style.opacity = this.currentfading2/100;
										}
									} else {
										this.image2.style.filter = "alpha(opacity="+ this.currentfading2 +");"; 
									}
								}	
								this.fadeSequence(fadeerintervals);
							}
							
	this.init			=	function() {
								//this.fadekey =  Math.floor(Math.random() * (this.arrImages.length));
								this.fadekey =  0;
								if(browser.DOM) {
									var tempimage1 = "<img class=\"fadeImage1\" name=\"image1\" height=\"193\" width=\"169\" border=\"0\" src=\"/img/spc.gif\">";
									var tempimage2 = "<img class=\"fadeImage2\" name=\"image2\" height=\"193\" width=\"169\" border=\"0\" src=\"" + this.arrImages[this.fadekey].src + "\">";
									document.write( tempimage2 +tempimage1);
									
								} else {
									document.write("<img name=\"image1\" src=\"" + this.arrImages[this.fadekey].src + "\">");
								}
							}
}


function toggleCvdInfo() {
	
	if(document.getElementById("cvdInfo")) {
		
		if(document.getElementById("cvdInfo").style.display == "block") {
			document.getElementById("cvdInfo").style.display = "none";
		} else {
			document.getElementById("cvdInfo").style.display = "block";
		}
	}
	
	return false;
}



function updateStep2FormFields(){
	
	if(document.forms['signUpFormStep2'].elements['paymentForm'].value == 2){
		
		//show pbs fields
		var pbsWrapperElement = document.getElementById('formExpand');
		pbsWrapperElement.style.display = 'block';
	}
	else {
		
		//hide pbs fields
		var pbsWrapperElement = document.getElementById('formExpand');
		pbsWrapperElement.style.display = 'none';
	}
}



function makePopup() {

	qpwin = window.open("about:blank","qpwin","resizable=0,directories=0,menubar=0,toolbar=0,location=0,status=0,scrollbars=0,width=650,height=480");
	qpwin.focus();
} 


function toggleDivs(div1Id, div2Id, triggerElementId, triggerText1, triggerText2){
	
	var div1 = document.getElementById(div1Id);
	var div2 = document.getElementById(div2Id);
	
	var trigger = document.getElementById(triggerElementId);
	
	if(div2.style.display == 'none'){
		
		div1.style.display = 'none';
		div2.style.display = 'block';
		
		trigger.innerHTML = triggerText2;
	}
	else {
		
		div1.style.display = 'block';
		div2.style.display = 'none';
		
		trigger.innerHTML = triggerText1;
	}
}

function toggleDivs2(div1Id, div2Id, triggerElementId, triggerText1, triggerText2,triggerClass1, triggerClass2){
	
	var div1 = document.getElementById(div1Id);
	var div2 = document.getElementById(div2Id);
	
	var trigger = document.getElementById(triggerElementId);
	
	if(div2.style.display == 'none'){
		
		div1.style.display = 'none';
		div2.style.display = 'block';
		
		trigger.innerHTML = triggerText2;
		trigger.className = triggerClass2;
	}
	else {
		
		div1.style.display = 'block';
		div2.style.display = 'none';
		
		trigger.innerHTML = triggerText1;
		trigger.className = triggerClass1;
	}
}



function toggleDiv(divId){
	
	var divElement = document.getElementById(divId);
	
	if(divElement.style.display == 'none'){
		
		divElement.style.display = 'block';
	}
	else {
		
		divElement.style.display = 'none';
	}
}
