// JavaScript Document
// testing function
function subit(s,t,u,v,w) { 
	var popwin = window.open ('','tester','height=600,width=600, scrollbars=yes,resize=yes');
	popwin.document.write(s+'<br />'+t+'<br />'+u+'<br />'+v+'<br />'+w);
}

//used for coloring alternate rows of the tour table
function tourtablerow(table_name,rowheader,row1,row2) {	
	//loop over a tags inside tour div 
	rowlist=document.getElementById(table_name);	
	rowlistlinks= rowlist.getElementsByTagName('tr');
	for (i=0;i<rowlistlinks.length;i++) {
		if (i/1>0) {		
			if (i%2==1) {		
				rowlistlinks[i].setAttribute('className',row1);
				rowlistlinks[i].setAttribute('class',row1);				
			} else {			
				rowlistlinks[i].setAttribute('className',row2);
				rowlistlinks[i].setAttribute('class',row2);					
/* className is use so ie can read it */				
			}
		} else {
			rowlistlinks[i].setAttribute('className',rowheader);
			rowlistlinks[i].setAttribute('class',rowheader);					
		}
	}
}

function go(url,w,h) {
	var dim = eval('"width=' + w + ',height=' + h + ',toolbar=0, location=0,directories=0,status=0, menubar=0,scrollbars=0,resizable=yes, top=100, left=100"');
	Npop = window.open(url,"instruct",dim);
	oldWin = Npop.opener;
}

function CloseMe() {
        parent.window.close();
}


function MM_findObj(n, d) { //v3.0
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); return x;
}

/* Functions that swaps images. */
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];}
}

/* Functions that handle preload. */
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];}}
}


//This is the greatest and best javascipt pop-up script ever
//actually it's just a tribute
var galleryWindow = null;

//Function to create HTML code, combine it with arguments passed from clickable text, and pass it to a variable
function createWinContent(image,gWinWidth,gWinHeight,title,desc) {
	var winContent = "";
	winContent += "<html> \n <head> \n <title>" + title + "</title> \n <LINK rel='stylesheet' type='text/css' href='/includes/css/paulstanley.css'> \n <script language='JavaScript' type='text/JavaScript' src='/includes/javascript/popup.js'></script>\n</head> \n <body class='popup'  onLoad='preload_image(\""+image+"\");'> \n";
	winContent += "<div class='headline' style='height:40px; text-align:center;'>" + title + "</div> \n ";
	winContent += "<div class='subhead' style=' text-align:center;'>" + desc + "\n";
	winContent += "<div align=center><A onClick='JavaScript:closeWindow();' href='javascript://'><IMG class='gallFullPic' border=0 src='" + image + "' alt='" + desc + "' align=middle ></a></div>";
	winContent += "<DIV align='right'><A onClick='JavaScript:closeWindow();' href='javascript://'>Close Window</A>&nbsp;&nbsp;&nbsp;</DIV></BODY></HTML>";
	openWindow(winContent,gWinWidth,gWinHeight);
	_uacct = "UA-856725-9";
	urchinTracker(image);
}

//Opens window and populates with content
function openWindow(winContent, gWinWidth,gWinHeight) {
//open new window with the attributes supplied by if statement
	 var galleryWindow = window.open(" ","galleryWin","top=40,left=200,width=" + gWinWidth +",height=" + gWinHeight + ", menubar=no, resizable=no, scrollbars=no, location=no, toolbar=no"); 
	if(!galleryWindow.closed) {
		galleryWindow.resizeTo(gWinWidth,gWinHeight);	
	}	 
// write content into new window
	galleryWindow.document.open();
	galleryWindow.document.write(winContent);
	galleryWindow.document.close();
	galleryWindow.focus();
	
}

//used for login /user_state username
function prePopUserName() {
  	elem = document.getElementsByTagName('input');
  	for ( i = 0; elem.length > i +1; i++)
  	{
  		if (elem[i].name == 'username' )
  		{
  			if( elem[i].value == '')
  			{
  				elem[i].value = 'Username';
  				elem[i].onfocus = function() {
  					if(this.value == 'Username')
  					{
  						this.value = '';
  					}	
  				}
  			}
  		}
  	}
}

//used for login /user_state password
function prePopPassword() {
  	elem = document.getElementsByTagName('input');
  	for ( i = 0; elem.length > i +1; i++)
  	{
  		if (elem[i].name == 'password' )
  		{
  			if( elem[i].value == '')
  			{
  				elem[i].value = 'Password';
  				elem[i].onfocus = function() {
  					if(this.value == 'Password')
  					{
  						this.type = 'password';
  						this.value = '';
  					}	
  				}
  			}
  		}
  	}
}

//used for subscribe form
function prePopBirthday() {
	
  	elem = document.getElementsByTagName('input');
  	for ( i = 0; elem.length > i +1; i++)
  	{
  		if (elem[i].name == 'dob' )
  		{
  			if( elem[i].value == '')
  			{
  				elem[i].value = 'mm/dd/yyyy';
  				elem[i].onfocus = function() {
  					if(this.value == 'mm/dd/yyyy')
  					{
  						this.value = '';
  					}	
  				}
  			}
  		}
  	}
}



function setStateDropdownContents () {					
	if(countryDropDown[0].value == 'US') {	
		//hide non pertinent fields
		document.getElementsByName('us_states')[0].style.display = 'inline';
		document.getElementsByName('ca_states')[0].style.display = 'none';
		document.getElementsByName('foreign_states')[0].style.display = 'none';
	} else if(countryDropDown[0].value == 'CA') {
		document.getElementsByName('us_states')[0].style.display = 'none';
		document.getElementsByName('ca_states')[0].style.display = 'inline';
		document.getElementsByName('foreign_states')[0].style.display = 'none';
	} else {
		document.getElementsByName('us_states')[0].style.display = 'none';
		document.getElementsByName('ca_states')[0].style.display = 'none';
		document.getElementsByName('foreign_states')[0].style.display = 'inline';
		return true;
	}
}
