﻿// JScript File
/*///////  EMAIL VALIDATION /////*/

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}
	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	 if (str.indexOf(" ")!=-1){
		return false
	 }
	 return true					
}

/*///////  FORM VALIDATION /////*/

function validateForm() 
{
	var validationMsg = ''

    if(document.forms[0].fname.value == '') validationMsg = validationMsg + '*Firstname is required.\n';
    if(document.forms[0].lname.value == '') validationMsg = validationMsg + '*Lastname is required.\n';
    if(document.forms[0].email.value == '') validationMsg = validationMsg + '*Email is required.\n';
    else if(echeck(document.forms[0].email.value) == false) validationMsg = validationMsg + 'Email is not valid.\n';
    
	if ( validationMsg != '')
	{
	    alert( validationMsg );
	    return false;
	}
	
	return true;
}

// JScript File
function doBridgeTrack(btId)
{
    // do BT only for the live sapient.com site
    if(document.location.href.toLowerCase().indexOf('sapient.com') != -1)
    {
        var szProtocol = window.location.protocol;  // script on page load
        var szRandom = Math.random() * 1000000;
        var i = document.createElement('img');
		i.src = szProtocol + '//ads.bridgetrack.com/track/?id=' + btId + '&r=' + szRandom;
    }
}

function doGoogleAndBTTracking(googConvId, googConvLabel, btId)
{
    doBridgeTrack(btId);
    
    doGoogleTrack(googConvId, googConvLabel);
    
    return;
}

function doGoogleTrackingOnly(googConvId, googConvLabel)
{

    doGoogleTrack(googConvId, googConvLabel);
    
    return;
}

function doGoogleTrack(googConvId, googConvLabel)
{
    // do BT only for the live sapient.com site
    if(document.location.href.toLowerCase().indexOf('sapient.com') != -1)
    {
        var szProtocol = window.location.protocol;  // script on page load
        var szRandom = Math.random() * 1000000;
        var j = document.createElement('img');
		j.src = szProtocol + '//www.googleadservices.com/pagead/conversion/' + googConvId + '/?label=' + googConvLabel + '&amp;guid=ON&amp;script=0' + '&r=' + szRandom;
		
    }
    
}
