
formval = '	<form onSubmit="return chEmailForm()" name="frmLogin" action="/mailer.php" method="post"><span class="sometext"><b>View Winery Itinerary</b></span>';
formval += '<br><INPUT onFocus="chEmail(this.value)" onBlur="chEmailOff(this.value)" value="email@domain.com" style="font-family:arial; BORDER-RIGHT: #a4a4a4 1px solid; BORDER-TOP: #a4a4a4 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #a4a4a4 1px solid; WIDTH: 145px; COLOR: #787878; BORDER-BOTTOM: #a4a4a4 1px solid" name="username" id="username" /><br><INPUT onFocus="chPhone(this.value)" onBlur="chPhoneOff(this.value)" value="000-000-0000" style="font-family:arial; BORDER-RIGHT: #a4a4a4 1px solid; BORDER-TOP: #a4a4a4 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #a4a4a4 1px solid; WIDTH: 145px; COLOR: #787878; BORDER-BOTTOM: #a4a4a4 1px solid" name="userphone" id="userphone" />';
formval += '<br><textarea style="font-family:arial; BORDER-RIGHT: #a4a4a4 1px solid; BORDER-TOP: #a4a4a4 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #a4a4a4 1px solid; WIDTH: 145px; HEIGHT: 70PX; COLOR: #787878; BORDER-BOTTOM: #a4a4a4 1px solid" name="message" id="message" onFocus="chMessage(this.value)" onBlur="chMessageOff(this.value)">your message</textarea>	<br><input type="submit" value="Send"></form>';

o = document.getElementById("contactformdiv");
o.innerHTML = formval;

// pass referrer through to iframe then store in session var

function openpopup(popurl)
{
var winpops=window.open(popurl,"","resizable=1,scrollbars=1,width=870px,height=1100px")
}

function chRef()
{
w = document.referrer;
w2pass = "";
//alert(w);
if(w.indexOf("?") != -1)
	{
	ws = w.split("?");
	w2pass = ws[1];
	}

iframeval = '<iframe src="//www.nycwinetours.com/red/scripts/tracker.php?'+w2pass+'" height="30" width="100" style="display:none;"></iframe>';
document.write(iframeval);
}
chRef();
function chEmail(wh)
{
o = document.getElementById("username");
if(o.value == "email@domain.com")
	{o.value = "";}
}

function chPhone(wh)
{
o = document.getElementById("userphone");
if(o.value == "000-000-0000")
	{o.value = "";}	
}

function chPhoneOff(wh)
{
o = document.getElementById("userphone");
if(o.value == "")
	{o.value = "000-000-0000";}		
}

function chMessage(wh)
{
o = document.getElementById("message");
if(o.value == "your message")
	{o.value = "";}	
}

function chEmailOff(wh)
{
o = document.getElementById("username");
if(o.value == "")
	{o.value = "email@domain.com";}
}

function chMessageOff(wh)
{
o = document.getElementById("message");
if(o.value == "")
	{o.value = "your message";}	
}

function chEmailForm()
{
o = document.getElementById("username");
if(o.value == "email@domain.com" || o.value == "")
	{
	o.focus();
	alert("Please Enter Your Email Address.");
	return false;
	}
if((o.value.indexOf("@") == -1) || (o.value.indexOf(".") == -1))
	{
	o.focus();
	alert("Please Enter a Valid Email\nFormat: email@domain.com");
	return false;
	}
if((o.value.substring(o.value.length-3,o.value.length-2) != ".") && (o.value.substring(o.value.length-4,o.value.length-3) != "."))
	{
	o.focus();
	alert("Please Enter a Valid Email\nFormat: email@domain.com\nMust have 2 or 3 letter extension");
	return false;
	}
o = document.getElementById("userphone");
if(o.value == "000-000-0000" || o.value == "")
	{
	o.focus();
	alert("Please Enter Your Phone Number.");
	return false;
	}
o = document.getElementById("message");
if(o.value == "your message" || o.value.replace(/^\s+|\s+$/g,"") == "")
	{
	o.focus();
	alert("Please Enter a Message.");
	return false;
	}
return true;
}

