// JavaScript Document
var theWindow;
function popDesc(page)
{
	if(theWindow){theWindow.close();}
	theWindow = window.open(page,"n","width=580,height=630,top=10,y=10,x=10,left=10,status,scrollbars=1,resizable=1");
}
/********************************/
function popCompare(page)
{
	if(theWindow){theWindow.close();}
	theWindow = window.open(page,"n","width=630,height=500,top=10,y=10,x=10,left=10,status,scrollbars=1,resizable=0");
}
/********************************/
function popPhoto(image)
{
	if(theWindow){theWindow.close();}
	theWindow = window.open('photoDisplay.cfm?theImage='+image,"n","top=10,y=10,x=10,left=10,width=580,height=600,status=0,scrollbars=0");
}
/********************************/
// Flip it on
function roll(imgName) {
document[imgName].src = "i/" + imgName + "-on.gif"
}
/***********************************/
// Flip it off
function out(imgName) {
	document[imgName].src = "i/" + imgName + ".gif"	
}
/*********************************************
Function to load room section from the room comparison chart (or any pop up window)
***********************************************************************************/
function loadRoomSection(page)
{
	/*this page is located in the details folder, so pad the requested page to load with ../*/
	this.opener.parent.location.replace('../'+page);
}
function checkEmail()
{
	var re = new RegExp("^[A-Za-z0-9_]+[A-Za-z0-9_\.\-]*[A-Za-z0-9_-]+@[A-Za-z0-9_-]+\\.[a-z0-9\.-]*[a-z]{2,4}$","i");

	if(!re.test(document.rform.email.value))
	{alert('Your email address seems incorrect!');}
	else{document.forms[0].submit();}
}

function grabEmail()
{
	//grab signup_email value in case they entered one
	var theEmail = document.emailSignupForm.signup_email.value;
	var width="450", height="550";
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  if(theWindow)
  {
    if(!theWindow.closed) theWindow.close();
  }
  theWindow = open('http://pitcherinn.com/enews.cfm?email='+theEmail, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=1,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

//use the following var to remember an image's original src value
//the imageRoll function will constantly update this value, allowing the imageOut function to use its current value
var imageSourceValue = '';
function imageRoll(imageObject)
{
	//store the current src value
	imageSourceValue = imageObject.src;
	//grab the directory from the src attribute
	var folderIndex = imageObject.src.lastIndexOf("/");
	var theDirectory = imageObject.src.substring(0,folderIndex+1);//returns the DIR in the form http://domain.com/folder
	//test for image file type, jpg v. gif
	var theFileType = imageObject.src.substring(imageObject.src.length-3);//grab the last 3 characters, they represent the file type

	imageObject.src=theDirectory+imageObject.name+'-on.'+theFileType;
}
function imageOut(imageObject)
{
	//retrieve the original image src attribute
	imageObject.src = imageSourceValue;
}


