// site location
var loc = "http://" + window.location.toString().split("//")[1].split("/")[0] + "/";

if (loc.search("hornetmedia.ca") > -1)
{
	loc = loc + "syntergy2010/";
}

//var loc = "http://www.syntergy.com/";

	
function clickClear(thisField, defaultText)
{
	if (thisField.value == defaultText)
	{
		thisField.value = "";
	}
}

function clickRecall(thisField, defaultText)
{
	if (thisField.value == "")
	{
		thisField.value = defaultText;
	}
}

function comingSoon()
{
	alert("We are currently working on this link. Sorry for the inconvenience.");
}

var sp = "";
var otll = "";

function newsletterSignup(spT, otllT)
{
	sp = spT;
	otll = otllT;
	
	document.getElementById('captcha').contentWindow.sendRequest();
}

function checkNewsletterSignup(response)
{
	
	var email = document.forms['newsletterForm'].elements['emailaddress1'].value;
	var first = document.forms['newsletterForm'].elements['firstname'].value;
	var last = document.forms['newsletterForm'].elements['lastname'].value;
	var popup = document.forms['newsletterForm'].elements['popup'].value;
	
	var filter = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
	///^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/
	
	if (!filter.test(email))
	{
		alert("You must fill a valid email address.");
		document.forms['newsletterForm'].elements['emailaddress1'].focus();
	}
	else if (first == '' || first == "Enter your first name...")
	{
		alert("You must fill in your first name.");
		document.forms['newsletterForm'].elements['firstname'].focus();
	}
	else if (last == '' || last == "Enter your last name...")
	{
		alert("You must fill in your last name.");
		document.forms['newsletterForm'].elements['lastname'].focus();
	}
	else if (response == "failed" && opened)
	{
		alert("Please enter the reCAPTCHA correctly to prove you are human.");
		document.getElementById('captcha').contentWindow.Recaptcha.reload();
	}
	else
	{
		document.forms['newsletterForm'].elements['sharepointNewsletter'].value = sp;
		document.forms['newsletterForm'].elements['openTextLivelinkNewsletter'].value = otll;
		
		document.forms['newsletterForm'].submit();
		//alert("passed");
		//alert(document.forms['newsletterForm'].elements['sharepointNewsletter'].value);
	}
	
}

function openEmailApp(dept)
{
	
	document.location.href = "mailto:" + dept + "@syntergy.com"
	
}

function openEmailAppSubject(dept, subj)
{
	
	document.location.href = "mailto:" + dept + "@syntergy.com?subject=" + subj;
	
}

function popUpContent(page, pdf_link) {
	
	var winW = 600;
	var winH = 500;
	var scrollWin = "yes";
	var resizeWin = "yes";
	
	if (page == "newsletter") {
		winW = 330;
		winH = 570;
		scrollWin = "no";
		resizeWin = "no";
		page = "newsletter_signup";
	}
	
	if (page == "demo") {
		winW = 330;
		winH = 540;
		scrollWin = "no";
		resizeWin = "no";
		page = "live_demo_signup";
	}
	
	var pdf = '';
	
	if (page == "whitepaper") {
		winW = 330;
		winH = 530;
		scrollWin = "no";
		resizeWin = "no";
		page = "sharepointreplicator/download_whitepaper";
		pdf = "?pdf=" + pdf_link;
	}
	
	// half the screen width minus half the new window width (plus 5 px borders).
	var myWidth = (window.screen.width/2) - ((winW/2) + 10);
	
	// half the screen height minus half the new window height (plus title and status bars).
	var myHeight = (window.screen.height/2) - ((winH/2) + 50);
	
	var myWin = window.open(loc + page + ".html" + pdf,"popUpContent","status=no,height=" + winH + ",width=" + winW + ",resizable=" + resizeWin + ",left=" + myWidth + ",top=" + myHeight + ",screenX=" + myWidth + ",screenY=" + myHeight + ",toolbar=no,menubar=no,scrollbars=" + scrollWin + ",location=no,directories=no");
	
	myWin.focus();
	
}
