﻿// JScript File
//Preload the images start

var ExpiryDate="";
var SignUpcode = "";
var RedirectUrl = "";
var emailAdd = "";
var currentErrorLabel="";
var IsEmailExists=false;
var isContactSubmitClicked=false;
 Image6= new Image();Image6.src = "/images/vsprite_sm.png";
    if (window.location.toString().indexOf("advertisers.aspx")!=-1)
    {   
         Image1= new Image();Image1.src = "/images/mp_advert.png";
    }
    else if (window.location.toString().indexOf("agencies.aspx")!=-1)
    {   
        Image1= new Image();Image1.src = "/images/mp_agency.png";
    }
      else if (window.location.toString().indexOf("about-clickable.aspx")!=-1)
    {
         Image1= new Image();Image1.src = "/images/mp_aboutus.png";
         Image7= new Image();Image7.src = "/images/arrow_blue.png";
    }
     else if (window.location.toString().indexOf("team-clickable.aspx")!=-1)
    {
        Image1= new Image();Image1.src = "/images/mp_team.png";
        Image7= new Image();Image7.src = "/images/arrow_blue.png";
    }
    else if (window.location.toString().indexOf("clickable-press.aspx")!=-1)
    {
        Image1= new Image();Image1.src = "/images/mp_press.png";
        Image7= new Image();Image7.src = "/images/arrow_blue.png";
    }
    else if (window.location.toString().indexOf("clickable-news.aspx")!=-1)
    {
        Image1= new Image();Image1.src = "/images/mp_news.png";
        Image7= new Image();Image7.src = "/images/arrow_blue.png";
    }
    else if (window.location.toString().indexOf("join-us-clickable.aspx")!=-1)
    {
        Image1= new Image();Image1.src = "/images/mp_join.png";
        Image7= new Image();Image7.src = "/images/arrow_blue.png";
    }
    else if (window.location.toString().indexOf("contact-clickable.aspx")!=-1)
    { 
       Image1= new Image();Image1.src = "/images/mp_contact.png";
       Image7= new Image();Image7.src = "/images/arrow_blue.png";
       Image8= new Image();Image8.src = "/images/arrow_google.png";
       Image9= new Image();Image9.src = "http://www.google.com/intl/en_ALL/mapfiles/transparent.png";
       Image11= new Image();Image11.src = "http://www.google.com/intl/en_ALL/mapfiles/poweredby.png";
       Image12= new Image();Image12.src = "http://www.google.com/intl/en_ALL/mapfiles/scale.png";
       Image13= new Image();Image13.src = "http://www.google.com/intl/en_ALL/mapfiles/lmc.png";
       Image14= new Image();Image14.src = "http://www.google.com/intl/en_ALL/mapfiles/lmc-bottom.png";
       
       Image15= new Image();Image15.src = "http://www.google.com/intl/en_ALL/mapfiles/lmc-bottom.png";
       Image16= new Image();Image16.src = "http://www.google.com/intl/en_ALL/mapfiles/slider.png";
       Image17= new Image();Image17.src = "http://www.google.com/intl/en_ALL/mapfiles/openhand.cur";
       Image18= new Image();Image18.src = "http://www.google.com/intl/en_ALL/mapfiles/iw2.png";
       Image19= new Image();Image19.src = "http://www.google.com/intl/en_ALL/mapfiles/iws2.png";
       Image20= new Image();Image20.src = "http://www.google.com/intl/en_ALL/mapfiles/iw_close.gif";
       Image21= new Image();Image21.src = "http://www.google.com/intl/en_ALL/mapfiles/iw_plus.gif";
       
       Image22= new Image();Image22.src = "http://www.google.com/intl/en_ALL/mapfiles/iw_fullscreen.gif";
       Image23= new Image();Image23.src = "http://www.google.com/intl/en_ALL/mapfiles/iw_minus.gif";
       Image24= new Image();Image24.src = "http://www.google.com/intl/en_ALL/mapfiles/transparent.gif";
       Image25= new Image();Image25.src = "/images/wait.gif";
    }
     else if (window.location.toString().indexOf("signup-clickable.aspx")!=-1)
    {
        Image1= new Image();Image1.src = "/images/mp_signup.png";
        Image7= new Image();Image7.src = "/images/wait.gif";
    }
     else if (window.location.toString().indexOf("thankyou-clickable.aspx")!=-1)
    { 
        Image1= new Image();Image1.src = "/images/mp_thankyou.png";
    }
    else
    {
        Image1= new Image();Image1.src = "/images/mp_home.png";
    }
    Image2= new Image();Image2.src = "/images/spacer.gif";
    Image3= new Image();Image3.src = "/images/arrow_green.png";
    Image4= new Image();Image4.src = "/images/arrow_white.png";
    Image5= new Image();Image5.src = "/images/popup/errorPopup/onlynipple.png";
    // Preload the images end
    
//Global Variables
var IsPressed=false;
var j_IsDirectSignup="True";
var IsValidURL=false;

function Common()
{

this.NumberOnly=function(eventElement)
{	
    var bubbleEvent = false;
    if(eventElement.shiftKey===true && eventElement.keyCode==9)
    {
        bubbleEvent=true;
    }
    else if(eventElement.shiftKey===false && ((eventElement.keyCode>=48 && eventElement.keyCode<=57)||(eventElement.keyCode>=96 && eventElement.keyCode<=105)))
    {
       bubbleEvent=true;
    }
    else if(eventElement.shiftKey===false && (this.ValidateKeys(eventElement)))
    {
       bubbleEvent=true;
    }
    else
    {
        bubbleEvent=false;
    }
    if (! bubbleEvent) 
	{
		eventElement.preventDefault();
	}
	    return bubbleEvent;
};

this.ClearOnFocus=function(element)
{
	if (element.value=="Enter Your Email Here") 
	{
		element.value = '';
	}
};

this.ValidateKeys = function(eventElement)
{
	var keyCodes =[32,33,34,35,36,37,38,39,9,8,127];//[16,33,34,35,36,37,38,39,9,8,107,127,188,189,190,109];//188 for(,)189(-),190(.),109(for - in ff),107 for (+)
	for(var i=0; i<keyCodes.length; i++)
	{
		if(keyCodes[i] == eventElement.keyCode)
		{
			return true;
		}
	}
	return false;
};

this.CheckExt4Email=function(mailids)
{
	var arr = [
	'.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro',
	'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al',
	'.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb',
	'.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs',
	'.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci',
	'.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de',
	'.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et',
	'.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh',
	'.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy',
	'.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io',
	'.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
	'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk',
	'.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk',
	'.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw',
	'.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np',
	'.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm',
	'.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa',
	'.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn',
	'.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj',
	'.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug',
	'.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu',
	'.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw'];

	var sd = mailids;

	var ids = sd.split("\n");
	var val = true;

	for(var j=0; j<ids.length; j++)
	{
		var mai = ids[j];
		var dot = mai.lastIndexOf(".");
		var ext = mai.substring(dot,mai.length);

		var at = mai.indexOf("@");

		if(dot > 5 && at >=1)
		{
			for(var i=0; i<arr.length; i++)
			{
				if(ext == arr[i])
				{
				    val = true;
				    break;
				}
				else
				{
				    val = false;
				}
			}
			if(val === false)
			{
				return false;
			}
		}
		else
		{
			 return false;
		}
	}
	return true;
};

 this.ValidateEmailAddress=function(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	;	
};

this.CheckBlankEmail=function(strEmail)
{
	if(strEmail.length===0)
	{
		return false;
	}
	return true;
};

this.CheckCorpID=function(strEmail)
{
	var PeriodPos=strEmail.lastIndexOf('.');    
	var atPos=strEmail.indexOf('@');
	var domain=strEmail.substring(Number(atPos)+1,PeriodPos);

	if(domain.toUpperCase()=='YAHOO' || domain.toUpperCase()=='GMAIL' ||domain.toUpperCase()=='HOTMAIL' ||
		domain.toUpperCase()=='REDIFF'|| domain.toUpperCase()=='AOL' || domain.toUpperCase()=='TEST' || 
		domain.toUpperCase()=='REDIFFMAIL' || domain.toUpperCase()=='MSN'|| domain.toUpperCase()=='MSN')
	{
		return false;
	}
	if((strEmail.toString().indexOf('yahoo.co.in')!=-1)||(strEmail.toString().indexOf('geocities.yahoo.com')!=-1))
	{
	    return false;
	}
	return true;
};

this.ShowErrorPopUp=function(message,Obj)
{
	if(Obj === null)
	{
		return;
	}	
	var controlId=Obj.id;
	var left,top;
	//if(navigator.userAgent=="Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419.2.1 (KHTML, like Gecko) Safari/419.3" && window.location.toString().indexOf("signup-clickable.aspx")!=-1)
    if(navigator.userAgent.indexOf('Mac')!=-1 && navigator.userAgent.indexOf('Safari')!=-1 && window.location.toString().indexOf("signup-clickable.aspx")!=-1)
	{
	   
		if(controlId.substring(0,3)=="lst")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(164);
		}
		else if(controlId.substring(0,5)=="txtAR")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x + Number(157);
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(265);
		}
		else if(controlId.substring(0,3)=="txt")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x + Number(154);
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(286);
		}
		else
		{
		       left = document.getElementById(controlId).offsetWidth- Number(16);
		       top  =document.getElementById(controlId).offsetHeight+ Number(18);
			 //left = Sys.UI.DomElement.getBounds(Obj).x - Number(16) ;
			 //top  = Sys.UI.DomElement.getBounds(Obj).y + Number(18) ;
		}
	}
	//else if(navigator.userAgent=="Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419.2.1 (KHTML, like Gecko) Safari/419.3")
	else if(navigator.userAgent.indexOf('Mac')!=-1 && navigator.userAgent.indexOf('Safari')!=-1)
	{
	//alert('safari');
		if(controlId.substring(0,3)=="lst")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(164);
		}
		else if(controlId.substring(0,5)=="txtAR")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x + Number(157);
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(267);
		}
		else if(controlId.substring(0,3)=="txt")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x + Number(154);
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(251);
		}
		else
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x - Number(16) ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(18) ;
		}
	}
	else if(navigator.appVersion.indexOf('Safari')!=-1)
	{
//	alert('safari PC');
	if(controlId.substring(0,3)=="lst")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(170);
		}
		else if(controlId.substring(0,5)=="txtAR")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(41);
		}
		else if(controlId.substring(0,3)=="txt")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(21);
		}
		else
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x - Number(8);
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(18);
		}
	}
	else if (navigator.appName == "Microsoft Internet Explorer")
	{
		if(controlId.substring(0,3)=="lst")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(164);
		}
		else if(controlId.substring(0,5)=="txtAR")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(47);
		}
		else if(controlId.substring(0,3)=="txt")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(21);
		}
		else
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x - Number(16) ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(18) ;
		}
	}
	else
	{
		if(controlId.substring(0,3)=="lst")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(170);
		}
		else if(controlId.substring(0,5)=="txtAR")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(62);
		}
		else if(controlId.substring(0,3)=="txt")
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x ;
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(21);
		}
		else
		{
			 left = Sys.UI.DomElement.getBounds(Obj).x - Number(8);
			 top  = Sys.UI.DomElement.getBounds(Obj).y + Number(18);
		}
	}
	if( $get('divErrorPopUp').style.display=="none")
	{
		$get('errorMessage').innerHTML=message;  
		$get('divErrorPopUp').style.display="block"; 
		$get('divErrorPopUp').style.left=left+'px';
		$get('divErrorPopUp').style.top=top+'px';
		//$get('divErrorPopUp').style.position="absolute"; 
		
		//var width = Sys.UI.DomElement.getBounds($get('divErrorPopUp')).width;//commented by poonam verma 
//		if(width > 235)
//		$get('divErrorPopUp').style.width = "235px"; 
	}
};
this.HideErrorPopUp=function()
{
	$get('divErrorPopUp').style.display = "none";
	Sys.UI.DomElement.removeCssClass($get('errorMessage'), "tabTitlePopUp"); 
	Sys.UI.DomElement.addCssClass($get('errorMessage'), "errorcontent");
};

}
var common = new Common();

function errorPopupVisible()
{
	return ($get('divErrorPopUp').style.display == "block");
};

function HideLabel()
{
	if(currentErrorLabel != "")
    {
        Sys.UI.DomElement.removeCssClass($get(currentErrorLabel), "star");
    }
	$get('tr_message').style.display="none"; 
	$get('spn_status').innerHTML="";
};

function hideErrorPopup()
{
	common.HideErrorPopUp();
	HideLabel();
};

function ShowError(msg,lblid)
{
    currentErrorLabel = lblid;
    if(lblid != "")
    {
	    Sys.UI.DomElement.addCssClass($get(lblid), "star");
	}	
	
	 if(navigator.appName=='Netscape') 
	 {
            $get('tr_message').style.display="table-cell"; 
     }
     else 
     {
            $get('tr_message').style.display="block"; 
     }
	$get('lblError').innerHTML=msg;
};

function ToggleDiv()
{

    if (window.location.toString().indexOf("about-clickable")!=-1)
    {
	    $get('trAbout').className="statnavactive";
	    $get('trOurTeam').className="statnav";
	    $get('trPress').className="statnav";
	    $get('trNews').className="statnav";
	    $get('trJoin').className="statnav";
	    $get('trContactUs').className="statnav";
    //	$get('trSiteMap').className="statnav";

	    $get('imgAbout').src="/images/arrow_white.png";
	    $get('imgOurTeam').src="/images/arrow_blue.png";
	    $get('imgPress').src="/images/arrow_blue.png";
	    $get('imgNews').src="/images/arrow_blue.png";
	    $get('imgJoinUs').src="/images/arrow_blue.png";
	    $get('imgContactUs').src="/images/arrow_blue.png";
    //	$get('imgSiteMap').src="/images/arrow_blue.png";
	    $get('tdHeader').className="aboutclick";
    }
    else if (window.location.toString().indexOf("contact-clickable")!=-1)
    {
	    $get('trAbout').className="statnav";
	    $get('trOurTeam').className="statnav";
	    $get('trPress').className="statnav";
	    $get('trNews').className="statnav";
	    $get('trJoin').className="statnav";
	    $get('trContactUs').className="statnavactive";
    //	$get('trSiteMap').className="statnav";

	    $get('imgAbout').src="/images/arrow_blue.png";
	    $get('imgOurTeam').src="/images/arrow_blue.png";
	    $get('imgPress').src="/images/arrow_blue.png";
	    $get('imgNews').src="/images/arrow_blue.png";
	    $get('imgJoinUs').src="/images/arrow_blue.png";
	    $get('imgContactUs').src="/images/arrow_white.png";
    //	$get('imgSiteMap').src="/images/arrow_blue.png";	
        $get('tdHeader').className="contactclick";
    }
    else if (window.location.toString().indexOf("join-us-clickable")!=-1) 
    {
	    $get('trAbout').className="statnav";
	    $get('trOurTeam').className="statnav";
	    $get('trPress').className="statnav";
	    $get('trNews').className="statnav";
	    $get('trJoin').className="statnavactive";
	    $get('trContactUs').className="statnav";
    //	$get('trSiteMap').className="statnav";

	    $get('imgAbout').src="/images/arrow_blue.png";
	    $get('imgOurTeam').src="/images/arrow_blue.png";
	    $get('imgPress').src="/images/arrow_blue.png";
	    $get('imgNews').src="/images/arrow_blue.png";
	    $get('imgJoinUs').src="/images/arrow_white.png";
	    $get('imgContactUs').src="/images/arrow_blue.png";
    //	$get('imgSiteMap').src="/images/arrow_blue.png";	
        $get('tdHeader').className="joinclick";
    }
    else if (window.location.toString().indexOf("clickable-press")!=-1 || window.location.toString().indexOf("Venture-Funding")!=-1 || window.location.toString().indexOf("TechCrunch")!=-1 || window.location.toString().indexOf("MaxKalehoff")!=-1 || window.location.toString().indexOf("jonathanMiller")!=-1 || window.location.toString().indexOf("SeriesA-6Million")!=-1 || window.location.toString().indexOf("PrestonGreen")!=-1 || window.location.toString().indexOf("AlwaysOn")!=-1 || window.location.toString().indexOf("SevenExecs")!=-1)
    {
	    $get('trAbout').className="statnav";
	    $get('trOurTeam').className="statnav";
	    $get('trPress').className="statnavactive";
	    $get('trNews').className="statnav";
	    $get('trJoin').className="statnav";
	    $get('trContactUs').className="statnav";
    //	$get('trSiteMap').className="statnav";

	    $get('imgAbout').src="/images/arrow_blue.png";
	    $get('imgOurTeam').src="/images/arrow_blue.png";
	    $get('imgPress').src="/images/arrow_white.png";
	    $get('imgNews').src="/images/arrow_blue.png";
	    $get('imgJoinUs').src="/images/arrow_blue.png";
	    $get('imgContactUs').src="/images/arrow_blue.png";
    //	$get('imgSiteMap').src="/images/arrow_blue.png";	
        $get('tdHeader').className="pressclick";
    }
    else if (window.location.toString().indexOf("clickable-news")!=-1)
    {
	    $get('trAbout').className="statnav";
	    $get('trOurTeam').className="statnav";
	    $get('trPress').className="statnav";
	    $get('trNews').className="statnavactive";
	    $get('trJoin').className="statnav";
	    $get('trContactUs').className="statnav";
    //	$get('trSiteMap').className="statnav";
	    $get('imgAbout').src="/images/arrow_blue.png";
	    $get('imgOurTeam').src="/images/arrow_blue.png";
	    $get('imgPress').src="/images/arrow_blue.png";
	    $get('imgNews').src="/images/arrow_white.png";
	    $get('imgJoinUs').src="/images/arrow_blue.png";
	    $get('imgContactUs').src="/images/arrow_blue.png";
    //	$get('imgSiteMap').src="/images/arrow_blue.png";
        $get('tdHeader').className="newsclick";
    }
    else if (window.location.toString().indexOf("team-clickable")!=-1) 
    {
	    $get('trAbout').className="statnav";
	    $get('trOurTeam').className="statnavactive";
	    $get('trPress').className="statnav";
	    $get('trNews').className="statnav";
	    $get('trJoin').className="statnav";
	    $get('trContactUs').className="statnav";
    //	$get('trSiteMap').className="statnav";

	    $get('imgAbout').src="/images/arrow_blue.png";
	    $get('imgOurTeam').src="/images/arrow_white.png";
	    $get('imgPress').src="/images/arrow_blue.png";
	    $get('imgNews').src="/images/arrow_blue.png";
	    $get('imgJoinUs').src="/images/arrow_blue.png";
	    $get('imgContactUs').src="/images/arrow_blue.png";
    //	$get('imgSiteMap').src="/images/arrow_blue.png";
        $get('tdHeader').className="teamclick";
    }
};

function checkBlank_firstName()
{
	if (errorPopupVisible()){ return false;}

	hideErrorPopup();
	var Name=$get('txtFirstName');
	
	if(Name.value.trim().length===0)
	{
		blurElement = Name; 
		setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your first name.',Name);
		return false;
	}
	return true;
};
function checkBlank_lastname()
{
	if (errorPopupVisible()) {return false;}

	hideErrorPopup();
	var lastName=$get('txtLastName');
	if(lastName.value.trim().length===0)
	{
		blurElement = lastName; 
		setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your last name.',lastName);
		return false;
	}
	return true;
};

function ValidateEmail(eventElement)
{
    if (errorPopupVisible()) {return false;}
    hideErrorPopup();
    var email=$get('txtContactEmail');
    email.value = email.value.toLowerCase();
    if(email.value.trim().length===0)
    {
        blurElement = email; 
        setTimeout("blurElement.focus()",10); 
	    common.ShowErrorPopUp("Please enter your email address.",email);
	    return false;
    }
    else
    {
	    if(common.ValidateEmailAddress(email.value)===false)
	    {
		    blurElement = email; 
            setTimeout("blurElement.focus()",10); 
	        common.ShowErrorPopUp("Please enter a valid Email address.",email);
	        return false;
	    }
    }
    //------------Email Validation------------------------
     var EmailExp = new RegExp('\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*');//Added by manoj pal
     var ProvidedEmail = email.value.trim();
     
     if(common.CheckBlankEmail(ProvidedEmail)===false)
     { 
        blurElement = email; 
        setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp("Please enter your Email address.",email);
        return false;
     }      
    if (!ProvidedEmail.match(EmailExp))
    {
        blurElement = email; 
        setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp("Please enter a valid Email address.",email);
        return false;
    }
    ProvidedEmail = ProvidedEmail.toLowerCase();
    if(common.ValidateEmailAddress(ProvidedEmail)===false)
    { 
        blurElement = email; 
        setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp("Please enter a valid Email address.",email);
        return false;
    }

    if(common.CheckExt4Email(ProvidedEmail)===false)
    {
        blurElement = email; 
        setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp("Please enter a valid Email address.",email);
        return false;
    }
//------------Email Validation------------------------
 eventElement.preventDefault();
};

function checkBlank_subject()
{
	if (errorPopupVisible()) {return false;}

	hideErrorPopup();
	var Subject=$get('txtMessageSubject');
	if(Subject.value.trim().length===0)
	{
		blurElement = Subject; 
		setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your message subject.',Subject);
		return false;
	}
	return true;
};
function checkBlank_message()
{
	if (errorPopupVisible()) {return false;}

	hideErrorPopup();
	var Message=$get('txtARMessage');
	if(Message.value.trim().length===0)
	{
		blurElement = Message; 
		setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your message.',Message);
		return false;
	}
	return true;
};

function DisableContact()
{
    $get('txtFirstName').disabled = true;
	$get('txtLastName').disabled = true;
	$get('txtContactEmail').disabled = true;
	$get('txtMessageSubject').disabled = true;
	$get('txtARMessage').disabled = true;
	$get('btnSubmit').disabled = true;
	$get('btnSubmit').className = "contactSubmitDisable";
	$get('btnSubmit').style.cursor = "default";
};
function EnableContact()
{
    $get('txtFirstName').disabled = false;
	$get('txtLastName').disabled = false;
	$get('txtContactEmail').disabled = false;
	$get('txtMessageSubject').disabled = false;
	$get('txtARMessage').disabled = false;
	$get('btnSubmit').disabled = false;
	$get('btnSubmit').className = "contactSubmit";
    $get('btnSubmit').style.cursor = "pointer";
};

function Save_CallBack(response)
{
    
    if(response==1 || response==2)
    {
	    DisableContact();
	    isContactSubmitClicked=true;
	    $get('imgWait').style.display = "none"; 
	    $get('spn_status').innerHTML = "Thank you for contacting Clickable. We'll be in touch soon.";  
    }
    else
    {   
        $get('imgWait').style.display = "none"; 
	    $get('spn_status').innerHTML = "Problem in sending your message,please try again."; 
	    EnableContact();
	    $get('txtFirstName').focus();
	    $get('imgWait').style.display = "none"; 
    }
};
function SavePage(eventElement)
{
    if(isContactSubmitClicked==true){return;}
    if($get('txtFirstName').value.trim().length===0)
    {
        if (errorPopupVisible()) {return;}
	    ShowError("Please enter your First Name.","lblError");
	    $get('txtFirstName').focus();
	    return;
    }
    if($get('txtLastName').value.trim().length===0)
    {
        if (errorPopupVisible()) {return;}
	    ShowError("Please enter your Last Name.","lblError");
	    $get('txtLastName').focus();
	    return;
    }
    if($get('txtContactEmail').value.trim().length===0)
    {
        if (errorPopupVisible()) {return;}
	    ShowError("Please enter your Email address.","lblError");
	    $get('txtContactEmail').focus();
	    return;
    }
    //------------Email Validation------------------------
     var EmailExp = new RegExp('\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*');//Added by manoj pal
     var ProvidedEmail = $get('txtContactEmail').value.trim();
            
    if (!ProvidedEmail.match(EmailExp))
    {
        if (errorPopupVisible()) {return;}
        ShowError("Please enter a valid Email address.","lblError");
        $get('txtContactEmail').focus();
        return;
    }
     if(common.CheckBlankEmail(ProvidedEmail)===false)
     { 
        if (errorPopupVisible()) {return;}
        ShowError("Please enter your Email address.","lblError");
        $get('txtContactEmail').focus();
        return;
     }
     ProvidedEmail = ProvidedEmail.toLowerCase();
    if(common.ValidateEmailAddress(ProvidedEmail)===false)
    { 
        if (errorPopupVisible()) {return;}
        ShowError("Please enter a valid Email address.","lblError");
        $get('txtContactEmail').focus();
        return;
    }
    if(common.CheckExt4Email(ProvidedEmail)===false)
    {
        if (errorPopupVisible()) {return;}
        ShowError("Please enter a valid Email address.","lblError");
        $get('txtContactEmail').focus();
        return;
    }
    //------------Email Validation------------------------
    if($get('txtMessageSubject').value.trim().length===0)
    {
        if (errorPopupVisible()) {return;}
        ShowError("Please enter your message subject.","lblError");
	    $get('txtMessageSubject').focus();
	    return;
    }
    if($get('txtARMessage').value.trim().length===0)
    {
	    ShowError("Please enter your message.","lblError");
	    $get('txtARMessage').focus();
	    return;
    }
    var firstName=$get('txtFirstName').value;
    var lastName=$get('txtLastName').value;
    var email=$get('txtContactEmail').value;
    var messageSubject=$get('txtMessageSubject').value;
    var message=$get('txtARMessage').value;
    DisableContact();
    $get('imgWait').style.display = "block"; 

    PageMethods.Save(firstName,lastName,email,messageSubject,message,Save_CallBack);
};

function SavePageOnEnter(eventElement)
{
    if(eventElement.keyCode==13)
    {
        SavePage(eventElement);
    }
};

function HideErrorLabel()
{
 $get('spn_status').innerHTML="";
};

function noPostBack(sNewFormAction)
{    
    document.forms[0].action = sNewFormAction;
    document.forms[0].__VIEWSTATE.name = '';
};  

function EnableOnSubmit()
{
    if( $get('txtEmail')!==null)
    {
        $get('txtEmail').disabled=false;
        $get('lblMsg').innerHTML=""; 
    }
   if( $get('txtEmail4SignUp')!==null)
   {
        $get('txtEmail4SignUp').disabled=false;  
        $get('lblMsgBottom').innerHTML="";  
   }
};
function IsValidEmail(ProvidedEmail)
{ 
    var EmailExp = new RegExp('\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*');
    if (!ProvidedEmail.match(EmailExp))
    {
	    return false;
    }
    return true;
};
function CheckEmail(strEmail)
{
    strEmail = strEmail.toLowerCase();
    if(common.CheckBlankEmail(strEmail)===false)
    { 
	    if($get('txtSignupEmail')!==null)
	    {
	        EnableAll();
	        $get('imgWait').style.display="none";
	        ShowError("Please enter your Email address.","lbltxtSignupEmail");
	        $get('txtSignupEmail').focus();
	    }
	    return false;
    }
    if(common.ValidateEmailAddress(strEmail)===false)
    {
	    if($get('txtSignupEmail')!==null)
	    {
	        EnableAll();
	        $get('imgWait').style.display="none";
	        ShowError("Please enter a valid Email address.","lbltxtSignupEmail");
	        $get('txtSignupEmail').focus();
	    }
	    return false;
    }
    if(common.CheckExt4Email(strEmail)===false)
    {
	    if($get('txtSignupEmail')!==null)
	    { 
	        EnableAll();
	        $get('imgWait').style.display="none";
	        ShowError("Please enter a valid Email address.","lbltxtSignupEmail");
	        $get('txtSignupEmail').focus();
	    }
	    return false;
    }
    if(IsValidEmail(strEmail)===false)
    {
	    if($get('txtSignupEmail')!==null)
	    { 
	        EnableAll();
	        $get('imgWait').style.display="none";
	        ShowError("Please enter a valid Email address.","lbltxtSignupEmail");
	        $get('txtSignupEmail').focus();
	    }  
	    return false;
    }
};
function Submit_Error()
{
    EnableOnSubmit();
};
function Login()
{
	window.location.href="/ac";  
};
function PasswrodPreventSpaceChar(eventElement)
{
    if(eventElement.keyCode == 32)
    {
        eventElement.preventDefault();
    }
};
function txtPassword_Blur()
{
    // This peice would be called when The 
    // User decides not to enter the password and 
    // Proceed.
   // if (errorPopupVisible()){ return false;}
	HideLabel();
	var password=$get('txtPassword');
	if(password.value.trim().length===0)
	{
		//blurElement = password; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter Password.',password);
		return false;
	}
	if(!validate_password($get('txtPassword').value.trim()))
    {
        //blurElement = password; 
		//setTimeout("blurElement.focus()",10); 
        //common.ShowErrorPopUp('Invalid password! Password must contain letters and either numbers or punctuation marks.',password);
        common.ShowErrorPopUp('Invalid password! Your password must be at least 6 characters long and contain at least <br> one letter and one number.',password);
        //$get('txtPassword').focus();
		return false;
    }
    if(!comparePassword() && $get('txtRePassword').value.trim() != 0)
    {
       // blurElement = password; 
		//setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp('Passwords do not match.',password);
       // $get('txtPassword').focus();
		return false;
    }
	return true;
}
function txtRePassword_Blur()
{
    // This peice would be called when The 
    // User decides not to enter the password again and 
    // Proceed.
    //if (errorPopupVisible()){ return false;}
	HideLabel();
	var password=$get('txtRePassword');
	if(password.value.trim().length===0)
	{
		//blurElement = password; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter Password again.',password);
		return false;
	}
	if(!validate_password($get('txtPassword').value.trim()))
    {
        //blurElement = password; 
		//setTimeout("blurElement.focus()",10); 
        //common.ShowErrorPopUp('Invalid password! Password must contain letters and either numbers or punctuation marks.',password);
        common.ShowErrorPopUp('Invalid password! Your password must be at least 6 characters long and contain letters <br> and either numbers or punctuation marks.',password);
        //$get('txtRePassword').focus();
		return false;
    }
    if(!comparePassword() && $get('txtPassword').value.trim() != 0)
    {
       // blurElement = password; 
		//setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp('Passwords do not match.',password);
       // $get('txtRePassword').focus();
		return false;
    }
	return true;
}
function comparePassword()
{
    if($get('txtPassword').value.trim() != $get('txtRePassword').value.trim())
    {
        return false;
    }
    return true;
}
function txtSignupEmail_Blur()
{
    
    $get('txtHiddenEmail').value = $get('txtSignupEmail').value;
    //if (errorPopupVisible()) {return false;}

	HideLabel();
	var Name=$get('txtSignupEmail');
	var strErrorMsg = "";
	var flag = 0;
	var strEmail = $get('txtSignupEmail').value;
	blurElement = Name;
	if(Name.value.trim().length===0)
	{
		setTimeout("blurElement.focus()",10);
		strErrorMsg = "Please enter Email.";
		common.ShowErrorPopUp('Please enter Email address.',Name);
		return false;
	}
	else
	{
	    strEmail = strEmail.toLowerCase();
	    if(common.ValidateEmailAddress(strEmail)===false)
        {
            strErrorMsg = "Please enter a valid Email address.";
            flag = 1;
		}
        else if(common.CheckExt4Email(strEmail)===false)
        {
	        strErrorMsg = "Please enter a valid Email address.";
	        flag = 1;
        }
		if(flag == 1)
		{
		    setTimeout("blurElement.focus()",10);
		    common.ShowErrorPopUp(strErrorMsg,Name);
		    return false;
		}
		else
		{
	        $get('txtHiddenEmail').value = $get('txtSignupEmail').value;
	        CheckEmailAvailability();
		}		
	}
};
function ShowChkEmailAvaiLbl()
{
    $get('lblChkEmailAval').style.dispaly='block';
    $get('lblChkEmailAval').innerHTML='Verifying email...';
};
function HideChkEmailAvaiLbl()
{
    $get('lblChkEmailAval').style.dispaly='none';
    $get('lblChkEmailAval').innerHTML='';
};
function CheckEmailAvailability()
{
    ShowChkEmailAvaiLbl();
    DisableAll();
    PageMethods.CheckEmailAvailability($get('txtSignupEmail').value,CheckEmailAvailability_callback);
};
function CheckEmailAvailability_callback(response)
{ 
    HideChkEmailAvaiLbl();
    EnableAll();
    if(response==true)
    {
         common.ShowErrorPopUp("Email already exists.",$get('txtSignupEmail'));
         IsEmailExists=true;
         $get('txtSignupEmail').focus();
    }
    else
    {
        IsEmailExists=false;
        $get('txtName').focus();
    }
};
function txtName_Blur()
{
	//if (errorPopupVisible()){ return false;}
	HideLabel();
	var Name=$get('txtName');
	if(Name.value.trim().length===0)
	{
		//blurElement = Name; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your First Name.',Name);
		return false;
	}
	return true;
};
function txtLastName_Blur()
{
	//if (errorPopupVisible()) {return false;}
    HideLabel();
	var lastName=$get('txtLastName');
	if(lastName.value.trim().length===0)
	{
		//blurElement = lastName; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your Last Name.',lastName);
		return false;
	}
	return true;
};
function txtTitle_Blur()
{
	//if (errorPopupVisible()) {return false;}

	HideLabel();
	var Title=$get('txtTitle');
	if(Title.value.trim().length===0)
	{
		//blurElement = Title; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your Job Title.',Title);
		return false;
	}
	return true;
};
function txtCompanyName_Blur()
{
	//if (errorPopupVisible()) {return false;}

	HideLabel();
	var CompName=$get('txtCompanyName');
	    if(CompName.value.trim().length===0)
	{
		//blurElement = CompName; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your Company Name.',CompName);
		return false;
	}
	return true;
};

function txtCode_Blur()
{
	//if (errorPopupVisible()) {return false;}
	HideLabel();
	var Code=$get('txtCode');
	if(Code.value.trim().length===0)
	{
		//blurElement = Code; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your Country Code.',Code);
		return false;
	}
	if(Code.value.trim()=="+")
	{
		//blurElement = Code; 
		//setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your Country Code.',Code);
		return false;
	}
	return true;
};
function ignoreSpaces(string) 
{
    var temp = "";
    string = '' + string;
    splitstring = string.split(" ");
    for(i = 0; i < splitstring.length; i++)
    temp += splitstring[i];
    return temp;
};
function getLength()
{
    var val=ignoreSpaces($get('txtPhone').value);
    var count=0;
    for(var i=0;i<val.length;i++)
    {
        if(val.substring(i,i+1)>=0 && val.substring(i,i+1)<=9)
        {
            count=count+1;
        }  
    }
    return (count);
};

//function CountNumber(eventElement)
//{
//    if($get('cmbCountry').value!='US' && $get('cmbCountry').value!='CA'){return true;}
//    
//    var count=getLength();
//    if(count>=10)
//    {
//        if(!(eventElement.shiftKey==true && (eventElement.charCode==48 || eventElement.charCode==57))&&(eventElement.charCode>=48 && eventElement.charCode<=57) || (eventElement.charCode>=96 && eventElement.charCode<=105))  
//        {
//             blurElement = $get('txtPhone'); 
//		     setTimeout("blurElement.focus()",10); 
//             common.ShowErrorPopUp("Number of digits in phone number cannot be greater than 10.","txtPhone");
//             eventElement.preventDefault();
//             return false;
//        }     
//    }
//    return true;
//};
function txtPhone_Blur()
{
	//if (errorPopupVisible()) {return false;}
	HideLabel();
	var Phone=$get('txtPhone');
	//blurElement = Phone; 
    
	if(getLength() == 0)
	{   
	    //setTimeout("blurElement.focus()",10); 
		common.ShowErrorPopUp('Please enter your Phone Number.',Phone);
		return false;
	}
	else if(($get('cmbCountry').value=='US' || $get('cmbCountry').value=='CA') && (getLength() != 10))
    {
        //setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp('Please enter a valid Phone Number with only 10 numbers.',Phone);
	    return false;
	}
	else if(getLength() < 7)
    {
       // setTimeout("blurElement.focus()",10); 
        common.ShowErrorPopUp('Please enter a valid Phone Number with minimum 7 numbers.',Phone);
	    return false;
	}
	return true;
};
function txtCode_Keydown(eventElement)
{
	if(!common.NumberOnly(eventElement)) {return false;}
	common.HideErrorPopUp();
	HideLabel();
};

function txtPhone_Keydown(eventElement)
{   
    if(!ValidatePhone(eventElement)) {return false;	}
    
    if($get('cmbCountry').value=='US' || $get('cmbCountry').value=='CA')
    {
	    if(getLength() > 9 && !( eventElement.keyCode == 9 || eventElement.keyCode == 35 || eventElement.keyCode == 36 || eventElement.keyCode == 37 || eventElement.keyCode == 38 || eventElement.keyCode == 39 || eventElement.keyCode == 40 || eventElement.keyCode == 8 || eventElement.keyCode == 127))
        {
            eventElement.keyCode = null;
            eventElement.preventDefault();
            return false;
        }
	}
	
	
    common.HideErrorPopUp();
    HideLabel();
};

function ShowAdvertiser()
{
	common.HideErrorPopUp();
	HideLabel();
	$get('divAdvertiser').style.display="block";
	$get('divAgency').style.display="none";
	$get('divAdNet').style.display="none";
	$get('divPressBlogger').style.display="none";
};

function ShowAgency()
{ 
	common.HideErrorPopUp();
	HideLabel();
	$get('divAdvertiser').style.display="none";
	$get('divAgency').style.display="block";
	$get('divAdNet').style.display="none";
	$get('divPressBlogger').style.display="none";

};
function ShowAdNetwork()
{
	common.HideErrorPopUp();
	HideLabel();
	$get('divAdvertiser').style.display="none";
	$get('divAgency').style.display="none";
	$get('divAdNet').style.display="block";
	$get('divPressBlogger').style.display="none";
};

function ShowPressBlogger()
{
	common.HideErrorPopUp();
	HideLabel();
	$get('divAdvertiser').style.display="none";
	$get('divAgency').style.display="none";
	$get('divAdNet').style.display="none";
	$get('divPressBlogger').style.display="block";
};

function HideAllCompanyType()
{
	$get('divAdvertiser').style.display="none";
	$get('divAgency').style.display="none";
	//$get('divAdNet').style.display="none";
};

function ClearAllCorp()
{
	HideLabel();
	common.HideErrorPopUp();

	//$get('txtSignupEmail').value="";
	
	$get('txtName').value="";
	$get('txtLastName').value="";
	$get('txtTitle').value="";
	$get('txtCompanyName').value="";
	$get('txtCode').value="";
	$get('txtPhone').value="";
	$get('txtPassword').value="";
	$get('txtRePassword').value="";
	$get('rdoAdvertiser').checked=false;
	$get('rdoAgency').checked=false;
	$get('rdoAdNetwork').checked=false;
	$get('rdoPressBlogger').checked=false;
	$get('chkGoogle').checked=false;
	$get('chkYahoo').checked=false;
	$get('chkMSN').checked=false;
	$get('chkAsk').checked=false;
	$get('chkOther').checked=false;
	 $get('chkAgGoogle').checked=false;
	$get('chkAgYahoo').checked=false;
	$get('chkAgMSN').checked=false;
	$get('chkAgAsk').checked=false;
	$get('chkAgOther').checked=false;
	$get('txtOther').value="";
	$get('txtAgOther').value="";
	$get('txtPublicationBlogURL').value="";
	$get('cmbMonthlySpend').selectedIndex=0;
	$get('cmbNoOfAcctManaged').selectedIndex=0;
	$get('cmbTotalSpend').selectedIndex=0;
	$get('cmbNoOfPublishers').selectedIndex=0;
	$get('cmbNoOfAdvertisers').selectedIndex=0;
	//$get('txtNoOfPublishers').value="";
	//$get('txtNoOfAdvertisers').value="";
	$get('txtARQuestionComments').value="";
	$get('chkSubscribeNewsLetter').checked=true;
	HideAllCompanyType();
};
function DisableAll()
{
	HideLabel();
	common.HideErrorPopUp();
    $get('txtSignupEmail').disabled=true;
	$get('txtName').disabled=true;
	$get('txtLastName').disabled=true;
	$get('txtTitle').disabled=true;
	$get('txtCompanyName').disabled=true;
	$get('txtCode').disabled=true;
	$get('txtPhone').disabled=true;
    $get('txtPassword').disabled=true;
	$get('txtRePassword').disabled=true;
	$get('rdoAdvertiser').disabled=true;
	$get('rdoAgency').disabled=true;
	$get('rdoAdNetwork').disabled=true;
	$get('rdoPressBlogger').disabled=true;
	$get('chkGoogle').disabled=true;
	$get('chkYahoo').disabled=true;
	$get('chkMSN').disabled=true;
	$get('chkAsk').disabled=true;
	$get('chkOther').disabled=true;
	$get('chkAgGoogle').disabled=true;
	$get('chkAgYahoo').disabled=true;
	$get('chkAgMSN').disabled=true;
	$get('chkAgAsk').disabled=true;
	$get('chkAgOther').disabled=true;
	$get('txtOther').disabled=true;
	$get('txtAgOther').disabled=true;
	$get('cmbMonthlySpend').disabled=true;
	$get('cmbNoOfAcctManaged').disabled=true;
	$get('cmbAvClientMonSMSpend').disabled=true;
	$get('cmbTotalSpend').disabled=true;
	$get('cmbCountry').disabled=true;
	
	$get('cmbTotalSpend').disabled=true;
	$get('cmbNoOfPublishers').disabled=true;
	$get('cmbNoOfAdvertisers').disabled=true;
	$get('txtPublicationBlogURL').disabled=true;
	
	$get('txtARQuestionComments').disabled=true;
	$get('chkSubscribeNewsLetter').disabled=true;
	$get('btnSubmit').disabled=true;
	$get('btnSubmit').className="signupSubmitLt";
};
function EnableAll()
{
	HideLabel();
	common.HideErrorPopUp();
	
    $get('txtSignupEmail').disabled=false;
	$get('txtName').disabled=false;
	$get('txtLastName').disabled=false;
	$get('txtTitle').disabled=false;
	$get('txtCompanyName').disabled=false;
	$get('txtCode').disabled=false;
	$get('txtPhone').disabled=false;
	$get('txtPassword').disabled=false;
	$get('txtRePassword').disabled=false;
	$get('rdoAdvertiser').disabled=false;
	$get('rdoAgency').disabled=false;
	$get('rdoAdNetwork').disabled=false;
	$get('rdoPressBlogger').disabled=false;
	$get('chkGoogle').disabled=false;
	$get('chkYahoo').disabled=false;
	$get('chkMSN').disabled=false;
	$get('chkAsk').disabled=false;
	$get('chkOther').disabled=false;
	$get('chkAgGoogle').disabled=false;
	$get('chkAgYahoo').disabled=false;
	$get('chkAgMSN').disabled=false;
	$get('chkAgAsk').disabled=false;
	$get('chkAgOther').disabled=false;
	$get('txtOther').disabled=false;
	$get('txtAgOther').disabled=false;
	$get('cmbMonthlySpend').disabled=false;
	$get('cmbNoOfAcctManaged').disabled=false;
	$get('cmbAvClientMonSMSpend').disabled=false;
	$get('cmbTotalSpend').disabled=false;
	
	$get('cmbNoOfPublishers').disabled=false;
	$get('cmbNoOfAdvertisers').disabled=false;
	$get('txtPublicationBlogURL').disabled=false;
	
	$get('cmbCountry').disabled=false;
	$get('txtARQuestionComments').disabled=false;
	$get('chkSubscribeNewsLetter').disabled=false;
	$get('btnSubmit').disabled=false;
	$get('btnSubmit').className="signupSubmit";
};

// Validate password on button 
// "Next" click.
function validate_password(strPass)
{
    //The password must be a minimum of 6 characters and contain letters and either numbers or punctuation marks.
    //Must contain only A-Z a-z 0-9 . ? ! : ; , - _ / '
    var re = /^[\w.?!:;,-_/']{6,}$/;
    //For at least one alphabate.
    var re1 = /[A-Za-z]{1}/; 
    //For at least one char other than alphabate.
    var re2 = /[0-9.?!:;,-/'_]{1}/; 
    if (!re.test(strPass) || !re1.test(strPass) || !re2.test(strPass)) 
    {
        return false;
    }
    return true;
};
function CheckBeforeSave()
{
    EnableAll(); 
    if($get('txtSignupEmail').value.trim().length===0)
	{
		ShowError("Please enter Email address.","lbltxtSignupEmail");
		if(!$get('txtSignupEmail').disabled)
		{
		    $get('txtSignupEmail').focus();
		}
		return false;
	}
	if(IsEmailExists==true)
	{
	    ShowError("Email already exists.");
	    if(!$get('txtSignupEmail').disabled)
		{
		    $get('txtSignupEmail').focus();
		}
		return false;
	}
	if($get('txtName').value.trim().length===0)
	{
		ShowError("Please enter your First Name.","lbltxtName");
		$get('txtName').focus();
		return false;
	}
	if($get('txtLastName').value.trim().length===0)
	{
		ShowError("Please enter your Last Name.","lbltxtLastName");
		$get('txtLastName').focus();
		return false;
	}
	if($get('cmbCountry').selectedIndex==0)
	{
		ShowError("Please select your Country Name.","lblcmbCountry");
		$get('cmbCountry').focus();
		return false;
	}
	 if($get('cmbCountry').options[$get('cmbCountry').selectedIndex].innerHTML.indexOf("----")!=-1)
    {
       ShowError("Please select your Country Name.","lblcmbCountry");
		$get('cmbCountry').focus();
		return false;
    }
	if(getLength() == 0)
	{
        ShowError("Please enter your Phone Number.","lbltxtPhone");
        $get('txtPhone').focus();
        return false;
	}
	else
	{
	    if(($get('cmbCountry').value=='US' || $get('cmbCountry').value=='CA') && (getLength() != 10))
        {
            ShowError("Please enter a valid Phone Number with only 10 numbers.","lbltxtPhone");
            $get('txtPhone').focus();
	        return false;
	    }
	    else if(getLength() < 7)
        {
            ShowError("Please enter a valid Phone Number with minimum 7 numbers.","lbltxtPhone");
            $get('txtPhone').focus();
	        return false;
	    }
	}
	
	if($get('txtTitle').value.trim().length===0)
	{
		ShowError("Please enter your Job Title.","lbltxtTitle");
		$get('txtTitle').focus();
		return false;
	}
	if($get('txtCompanyName').value.trim().length===0)
	{
		ShowError("Please enter your Company Name.","lbltxtCompanyName");
		$get('txtCompanyName').focus();
		return false;
	}
	
//	if($get('txtCode').value.trim().length===0)
//	{
//		ShowError('Please enter your country code.');
//		$get('txtCode').focus();
//		return false;
//	}
//	if($get('txtCode').value.trim()=="+")
//	{
//		ShowError('Please enter your country code.');
//		$get('txtCode').focus();
//		return false;
//	}
	
	if($get('txtPassword').value.trim().length===0)
	{
		ShowError("Please enter Password.","lbltxtPassword");
		$get('txtPassword').focus();
		return false;
	}
	if(!validate_password($get('txtPassword').value.trim()))
    {
        //ShowError("Invalid password! Password must contain letters and either numbers or punctuation marks.","lbltxtPassword");
        ShowError("Invalid password! Your password must be at least 6 characters long and contain letters and either numbers or punctuation marks.","lbltxtPassword");
        $get('txtPassword').focus();
		return false;
    }
	if($get('txtRePassword').value.trim().length===0)
	{
		ShowError("Please enter Password again.","lbltxtRePassword");
		$get('txtRePassword').focus();
		return false;
	}
	if(!comparePassword() && ($get('txtPassword').value.trim() != 0 && $get('txtRePassword').value.trim() != 0))
    {
        ShowError('Passwords do not match.',"lbltxtPassword");
        $get('txtPassword').focus();
		return false;
    }
   
	if($get('rdoAdvertiser').checked==false && $get('rdoAgency').checked==false && $get('rdoAdNetwork').checked==false && $get('rdoPressBlogger').checked==false)
	{
		ShowError("Please select a Company Type.","lblcompanyType");
		$get('rdoAdvertiser').focus();
		return false;
	}

	if($get('rdoAdvertiser').checked==true)
	{
	    if($get('chkGoogle').checked==false && $get('chkYahoo').checked==false && $get('chkMSN').checked==false && $get('chkAsk').checked==false && $get('chkOther').checked==false)
	    {
	        ShowError("Please select at least one Network you advertise on.","lblNetworks1");
			$get('chkGoogle').focus();
			return false;
	    }
		if($get('chkOther').checked==true)
		{
			if($get('txtOther').value.trim().length===0)
			{
				ShowError("Please specify the other Network you advertise on.","lblOther1");
				$get('txtOther').focus();
				return false;
			}
		}
		if($get('cmbMonthlySpend').selectedIndex==0)
		{
			ShowError("Please select a value for Total Monthly Search Marketing Spend.","lblcmbMonthlySpend1");
			$get('cmbMonthlySpend').focus();
			return false;
		}
	}
	if($get('rdoAgency').checked==true )
	{
	    if($get('chkAgGoogle').checked==false && $get('chkAgYahoo').checked==false && $get('chkAgMSN').checked==false && $get('chkAgAsk').checked==false && $get('chkAgOther').checked==false)
	    {
	        ShowError("Please select at least one Network you advertise on.","lblNetworks2");
			$get('chkAgGoogle').focus();
			return false;
	    }
		if($get('chkAgOther').checked==true)
		{
			if($get('txtAgOther').value.trim().length===0)
			{
				ShowError("Please specify the other Network you advertise on.","lblOther2");
				$get('txtAgOther').focus();
				return false;
			}
		}
		if($get('cmbTotalSpend').selectedIndex==0)
		{
			//ShowError('Please select the total spend managed.');
			ShowError("Please select a value for Total Monthly Search Marketing Spend.","lblcmbMonthlySpend2");
			$get('cmbTotalSpend').focus();
			return false;
		}
		 if($get('cmbNoOfAcctManaged').selectedIndex==0)
		{
			ShowError("Please select a value for Number of Accounts Managed.","lblcmbNoOfAcctManaged");
			$get('cmbNoOfAcctManaged').focus();
			return false;
		}
		if($get('cmbAvClientMonSMSpend').selectedIndex==0)
		{
			ShowError("Please select a value for Average Client Monthly Search Marketing Spend.","lblcmbAvClientMonSMSpend");
			$get('cmbAvClientMonSMSpend').focus();
			return false;
		}
	}
    if($get('rdoAdNetwork').checked==true )
	{
	    if($get('cmbNoOfPublishers').selectedIndex==0)
		{
			ShowError("Please select a value for Number of Publishers.","lblcmbNoOfPublishers");
			$get('cmbNoOfPublishers').focus();
			return false;
		}
		 if($get('cmbNoOfAdvertisers').selectedIndex==0)
		{
			ShowError("Please select a value for Number of Advertiser.","lblcmbNoOfAdvertisers");
			$get('cmbNoOfAdvertisers').focus();
			return false;
		}
	}
	if($get('rdoPressBlogger').checked==true )
	{
	    if($get('txtPublicationBlogURL').value.trim().length===0)
		{
			ShowError("Please enter Publication/Blog URL.","lbltxtPublicationBlogURL");
			$get('txtPublicationBlogURL').focus();
			return false;
		}
		if($get('txtPublicationBlogURL').value.toUpperCase() == "http://WWW.WWW.WWW")
	    {
		    ShowError("Please enter a valid Publication/Blog URL.","lbltxtPublicationBlogURL");
		    $get('txtPublicationBlogURL').focus();
			return false;
	    }
	    if(IsValidURL == false)
	    {
		    ShowError("Please enter a valid Publication/Blog URL.","lbltxtPublicationBlogURL");
		    $get('txtPublicationBlogURL').focus();
			return false;
	    }
	}
	return true;
};
 function UrlWithoutSubfolder(url)
 {
    var strUrlArr = url.split("/");
    if(strUrlArr.length > 3)
    {
        return false;
    }
    return true;
 };
function txtPublicationBlogURL_blur()
{
    if($get('rdoPressBlogger').checked==true )
	{
        HideLabel();
	    var url="";
	    var DisplayUrl=$get('txtPublicationBlogURL').value.toLowerCase();
	    if(DisplayUrl.match("http://"))
	    {
	        url = DisplayUrl;
	    }  
        else
	    {
		    url = "http://"+DisplayUrl;
        }
        if($get('txtPublicationBlogURL').value.trim()=="")
	    {   
		    ShowError("Please enter a valid Publication/Blog URL.","lbltxtPublicationBlogURL");
		    $get('txtPublicationBlogURL').focus();
		    return false;
	    }
	    else if(!UrlWithoutSubfolder(url))
	    {   
	        ShowError("Please enter URL in (www.testing.com) format.","lbltxtPublicationBlogURL");
		    $get('txtPublicationBlogURL').focus();
		    return false;
	    }
	    else if(!ValidateURL(url))
	    {   
	        ShowError("Please enter a valid Publication/Blog URL","lbltxtPublicationBlogURL");
		    $get('txtPublicationBlogURL').focus();
		    return false;
	    }
	    else
	    {
	       DisableAll();
           ShowVerifyUrl();
	       PageMethods.ValidateUrl($get('txtPublicationBlogURL').value,ValidateUrl_Callback);
	    }  
	}         
};
  
function ShowVerifyUrl()
{
    $get('lblVerifyUrl').style.dispaly='block';
    $get('lblVerifyUrl').innerHTML='Verifying url...';
};
function HideVerifyUrl()
{
    $get('lblVerifyUrl').style.dispaly='none';
    $get('lblVerifyUrl').innerHTML='';
};
function ValidateUrl_Callback(response)
{
    HideVerifyUrl();
    EnableAll();  
    if(response==null)
    {
        return false;
    }
    if(response==false)
    {
        ShowError("Please enter a valid Publication/Blog URL.","lbltxtPublicationBlogURL");
		$get('txtPublicationBlogURL').focus();
		return false;
    }
    IsValidURL=true;
    $get('txtARQuestionComments').focus();
   
};

function ValidateURL(url)
 { 
	var urlRegxp = new RegExp("^(((https?)|(ftp)):\\/\\/([\\-\\w]+\\.)+\\w{2,3}(\\/[%\\-\\w]+(\\.\\w{2,})?)*(([\\w\-\\.\\?\\\\/+@&#;`~=%!]*)(\\.\\w{2,})?)*\\/?)");//Originally used.	
	//var urlRegxp = new RegExp('(http|ftp|https)://(www|WWW)\\.(/[\\w- ./?%&=]*)?');//Modified by Manoj Pal
	if (!url.match(urlRegxp)) 
	{
		return false;
	}
	return true;
 };

function SaveSignupOnEnter(eventElement)
{
    if(eventElement.keyCode==13)
    {
          SaveSignup();         
        if(navigator.appName=='Netscape') 
            eventElement.preventDefault();
        else 
            return false;  
    }
};

    
function SaveSignupCorp()
{
    hideErrorPopup();
    if(CheckBeforeSave()==false){return ;}
    var getCookie=__aCMasterCookie.getCookie("SalesFunnelCookie");
    var email=$get('txtHiddenEmail').value;
    if(CheckEmail(email,2)==false){return;}
    var first_name=$get('txtName').value;
	var last_name=$get('txtLastName').value;
	var title=$get('txtTitle').value;
	var company=$get('txtCompanyName').value;
	var phone= $get('txtPhone').value;
	var area_code=$get('txtCode').value;
	var os=navigator.platform;
	var browser=navigator.appName;
	var screen_color=screen.colorDepth;
	var screen_resolution=screen.width+'x'+screen.height;
	var country_id=$get('cmbCountry').value;
	var country_Name=$get('cmbCountry').options[$get('cmbCountry').selectedIndex].text;
	
    var os=navigator.platform;
    var browser=navigator.appName;
    var screen_color=screen.colorDepth;
    var screen_resolution=screen.width+'x'+screen.height;
	var NavigatorAppCodeName=navigator.appCodeName;
	var NavigatorAppMinorVersion=navigator.appMinorVersion;
	
	if(NavigatorAppMinorVersion===undefined)
	{   
	    NavigatorAppMinorVersion="No";
	}

	var NavigatorAppVersion=navigator.appVersion;
	var NavigatorBrowserLanguage=navigator.browserLanguage;
	
	if(NavigatorBrowserLanguage===undefined)
	{
	    NavigatorBrowserLanguage="No";
	}

	var NavigatorCookieEnabled=navigator.cookieEnabled;
	var NavigatorCpuClass=navigator.cpuClass;
	
	if(NavigatorCpuClass===undefined)
	{
	    NavigatorCpuClass="No";
	}

	var NavigatorOnLine=navigator.onLine;
	
	if(NavigatorOnLine===undefined)
	{
	    NavigatorOnLine=0;
	}

	var NavigatorSystemLanguage=navigator.systemLanguage;
	
	if(NavigatorSystemLanguage===undefined)
	{
	    NavigatorSystemLanguage="No";
	}

	var NavigatorUserAgent=navigator.userAgent;
	var NavigatorUserLanguage=navigator.userLanguage;

	if(NavigatorUserLanguage===undefined)
	{
	    NavigatorUserLanguage="No";
	}
	
	var companytype;
	var google=false,yahoo=false,msn=false,ask=false,other="None",monthlySpend=7,
	monthlySpendValue="None",totalSpend=6,totalSpendValue="None",noOfAcctManaged=0,noOfAcctManagedValue="None",AvgClientMnthlySrchMktgSpend=7,AvgClientMnthlySrchMktgSpendValue="None",
	noOfPublishers=0,noOfPublishersValue="None",noOfAdvertisers=0,noOfAdvertisersValue="None",PublicationBlogURL="",EventSource="",AdWordCustomerId="";

	if($get('rdoAdvertiser').checked==true)
	{
		companytype=1;
		if($get('chkGoogle').checked==true)
			google=true;
		else
			google=false;

		if($get('chkYahoo').checked==true)
			yahoo=true;
		else
			yahoo=false;

		if($get('chkMSN').checked==true)
			msn=true;
		else
			msn=false;

		if($get('chkAsk').checked==true)
			ask=true;
		else
			ask=false;

		if($get('chkOther').checked==true)
			other=$get('txtOther').value;
		

		monthlySpend=parseInt($get('cmbMonthlySpend').value);
		
		if(isNaN(monthlySpend))
		{
			monthlySpend=7;
		}
		if(monthlySpend!=0)
		{
		    monthlySpendValue=$get('cmbMonthlySpend').options[$get('cmbMonthlySpend').selectedIndex].text;
		}
	}
	if($get('rdoAgency').checked==true)
	{
		 companytype=2;
		if($get('chkAgGoogle').checked==true)
			 google=true;
		else
			google=false;

		if($get('chkAgYahoo').checked==true)
			yahoo=true;
		else
			yahoo=false;

		if($get('chkAgMSN').checked==true)
			msn=true;
		else
			msn=false;

		if($get('chkAgAsk').checked==true)
			ask=true;
		else
			ask=false;

		if($get('chkAgOther').checked==true)
			other=$get('txtAgOther').value;
		

		totalSpend=Number($get('cmbTotalSpend').value);
		noOfAcctManaged=$get('cmbNoOfAcctManaged').value;
		AvgClientMnthlySrchMktgSpend=$get('cmbAvClientMonSMSpend').value;
		AvgClientMnthlySrchMktgSpendValue=$get('cmbAvClientMonSMSpend').options[$get('cmbAvClientMonSMSpend').selectedIndex].text;
		if(isNaN(totalSpend))
		{
			totalSpend=6;
		}
		if(noOfAcctManaged=="")
		{
			noOfAcctManaged=0;
		}
		if(totalSpend!=0)
		{
		    totalSpendValue=$get('cmbTotalSpend').options[$get('cmbTotalSpend').selectedIndex].text;
		}
		if(noOfAcctManaged!=0)
		{
		    noOfAcctManagedValue=$get('cmbNoOfAcctManaged').options[$get('cmbNoOfAcctManaged').selectedIndex].text;
		}
	}
    if($get('rdoAdNetwork').checked==true)
    {
        companytype=3;
        noOfPublishers=$get('cmbNoOfPublishers').value;
        noOfAdvertisers=$get('cmbNoOfAdvertisers').value;
        if(noOfPublishers!=0)
        {
             noOfPublishersValue=$get('cmbNoOfPublishers').options[$get('cmbNoOfPublishers').selectedIndex].text;
        }
        if(noOfAdvertisers!=0)
        {
             noOfAdvertisersValue=$get('cmbNoOfAdvertisers').options[$get('cmbNoOfAdvertisers').selectedIndex].text;
        }
    }
    if($get('rdoPressBlogger').checked==true)
    {
        companytype=4;
        var URL='http://';
	    if(($get('txtPublicationBlogURL').value).indexOf('www')==-1 && ($get('txtPublicationBlogURL').value).indexOf('WWW')==-1)
	    {
	        URL=URL+'www.';
	    }
	     URL=URL + $get('txtPublicationBlogURL').value;
        PublicationBlogURL=URL;
    }
    
	var comments=$get('txtARQuestionComments').value;
	var subscribeNewsLetters=0;
	if($get('chkSubscribeNewsLetter').checked==true)
		subscribeNewsLetters=1;
	else
		subscribeNewsLetters=0;
		
     $get('imgWait').style.display="block"; 
     DisableAll();
     
    var get_ctt_ch= __aCMasterCookie.getCookieValue("SalesFunnelCookie","ctt_ch");
    var get_ctt_id= __aCMasterCookie.getCookieValue("SalesFunnelCookie","ctt_id");
    var get_ctt_nw= __aCMasterCookie.getCookieValue("SalesFunnelCookie","ctt_nw");
    var get_referralUrl= __aCMasterCookie.getCookieValue("SalesFunnelCookie","referralUrl");
    var get_destinationUrl= __aCMasterCookie.getCookieValue("SalesFunnelCookie","destinationUrl");
    var password = $get("txtPassword").value;
    RedirectUrl = $get("redirectUrl").value;
    
    
    var evalString = new String();
    evalString = "email,first_name,last_name,title,company,area_code,phone,country_id,country_Name,"; 
    evalString += "companytype,google,yahoo,msn,ask,other,monthlySpend,monthlySpendValue,totalSpend,totalSpendValue,noOfAcctManaged,";
    evalString += "noOfAcctManagedValue,AvgClientMnthlySrchMktgSpend,AvgClientMnthlySrchMktgSpendValue,noOfPublishers," ;
    evalString += "noOfPublishersValue,noOfAdvertisers,noOfAdvertisersValue,comments,subscribeNewsLetters,PublicationBlogURL,";
    evalString += "EventSource,AdWordCustomerId,os,browser,screen_color,screen_resolution,NavigatorAppCodeName,";
    evalString += "NavigatorAppMinorVersion,NavigatorAppVersion,NavigatorBrowserLanguage,NavigatorCookieEnabled,NavigatorCpuClass,";
    evalString += "NavigatorOnLine,NavigatorSystemLanguage,NavigatorUserAgent,NavigatorUserLanguage,get_ctt_ch,get_ctt_nw,";
    evalString += "get_ctt_id,get_referralUrl,get_destinationUrl,password,RedirectUrl";
    
    var evalVars = new Array();
    evalVars = evalString.split(",");
    
    var strDynamicFormHTML = "<form target='_top' action='' method='post' id='signupForm'>";
    for(var elCount = 0 ; elCount < evalVars.length; elCount ++)
    {
        strDynamicFormHTML += "<input type='hidden' name='_" + evalVars[elCount] + "' id='_" + evalVars[elCount] + "' />";
    }    
        
        
    strDynamicFormHTML += "</form>";
    var dynamicFormObj = $get("dynamicForm");
    dynamicFormObj.innerHTML = strDynamicFormHTML;
    for(var elCount = 0 ; elCount < evalVars.length; elCount ++)
    {
        eval("$get(\"_" + evalVars [elCount]+ "\").value = " + evalVars [elCount]);
        //eval("alert($get(\"_" + evalVars [elCount]+ "\").value)");
    }
    $get("signupForm").action = RedirectUrl;
    $get("signupForm").submit();
};
function ServerSideSubmit_Callback(response)
{
//    debugger;
//    if(response == -5)
//    {
//        $get('spn_status').innerHTML = "Email already exists, please try with some different email id."; 
//		$get('imgWait').style.display="none";
//    }
//    else if(response == -1)
//    {
//        $get('spn_status').innerHTML = "Server error, please try after some time."; 
//		$get('imgWait').style.display="none";
//    }
////    else if(response > 0)
////	{
////	    //$get('SignupEmail').value = $get('txtSignupEmail').value;
////	    //$get('NsInternalId').value = response;
////        //document.forms[1].action = $get("redirectUrl").value;
////        //document.forms[1].submit();
////        window.location.href = $get("redirectUrl").value + "?SignupEmail=" + $get('txtSignupEmail').value + "&NsInternalId=" + response;
////	}
//	else if(response == 0)
//	{
//	    $get('spn_status').innerHTML = "Problem in saving your information."; 
//		$get('imgWait').style.display="none";
//	}
//	else
//	{
//	    $get('spn_status').innerHTML = "Not able to process your information."; 
//		$get('imgWait').style.display="none";
//	}
};
function ClearTemplateOnFocus(element)
{
    if(element.value=="999-999-9999")
    {
        element.value="";
    }  
    element.style.color="black";
};
//var mask;

function ChangeStatusAreaCode(country_code)
{  
    hideErrorPopup();
    $get('txtCode').value="";
//    $get('txtPhone').value="";
//    $get('txtPhone').style.color="#ced9d9";
    $get('txtCode').disabled=false;
    $get('cmbCountry').value=country_code;
    if($get('cmbCountry').length!=1 && $get('cmbCountry').selectedIndex==0 ){return;}
    PageMethods.GetCountryDialCodeAndTemplate(country_code,GetCountryDialCodeAndTemplate_callback);
   
};
function initDropDowns()
{   
    //debugger;
    if($get('txtPhone').disabled==true)
    {
        EnableAll();  
    }
	PageMethods.PopulateMonthlySpend(ServerSide_MonthlySpendPopulation);
	PageMethods.PopulateTotalSpend(ServerSide_TotalSpendPopulation);
	PageMethods.PopulateCountryNames(ServerSide_CountryNamePopulation);
	
	ChangeStatusAreaCode('US');
	$get('txtCode').disabled=true;
    $get('txtCode').value="1";
    if( $get('txtSignupEmail').value.trim().length===0)
    {
        $get('txtSignupEmail').focus();
    }
    else
    {
        $get('txtName').focus();
    }
	return false;
};
function GetCountryDialCodeAndTemplate_callback(response)
{
    var dtDialCode=response;
	if(dtDialCode==null || dtDialCode.rows==null){return;}
	if(dtDialCode.rows.length==null){return;}
	if(dtDialCode.rows.length==1)
	{
		for(var i=0; i<dtDialCode.rows.length;i++)
		{
		    if(dtDialCode.rows[i]["DialCode"]!=null)
			{
			    $get('txtCode').value=dtDialCode.rows[i]["DialCode"];
			    $get('txtCode').disabled=true;
			}
//			if(dtDialCode.rows[i]["Template"]!=null)    
//			{
//			    $get('txtPhone').value=dtDialCode.rows[i]["Template"];
//			    $get('txtPhone').focus();
//			}
		}
	}
};


function ServerSide_CountryNamePopulation(response)
{
    var us,canada;
	var dtCountryNames=response;
	if(dtCountryNames==null || dtCountryNames.rows==null ){return;}
	if(dtCountryNames.rows.length>0)
	{
		for(var i=0; i<dtCountryNames.rows.length;i++)
		{
			$get('cmbCountry').length+=1;
			$get('cmbCountry').options[$get('cmbCountry').length-1].value=dtCountryNames.rows[i]["CountryCode"];
			$get('cmbCountry').options[$get('cmbCountry').length-1].text=dtCountryNames.rows[i]["CountryName"];
			
			if(dtCountryNames.rows[i]["CountryCode"].toUpperCase()=='US')
			{   
			    us=dtCountryNames.rows[i]["CountryName"];
			}
			if(dtCountryNames.rows[i]["CountryCode"].toUpperCase()=='CA')
			{
			    canada=dtCountryNames.rows[i]["CountryName"];
			}
		}
////		$get('cmbCountry').options[0].value=0;
////		$get('cmbCountry').options[0].text="-Select-";
////		
////		$get('cmbCountry').options[1].value='US';
////		$get('cmbCountry').options[1].text=us;
////		$get('cmbCountry').options[1].selected=true;
////		
////		$get('cmbCountry').options[2].value='CA';
////		$get('cmbCountry').options[2].text=canada;
	}
};

function ServerSide_MonthlySpendPopulation(response)
{
	var dtMonthlySpend=response;
	if(dtMonthlySpend==null){return;}
	if(dtMonthlySpend.rows.length>0)
	{
		for(var i=0; i<dtMonthlySpend.rows.length;i++)
		{
		    //For Monthly Ad spend
			$get('cmbMonthlySpend').length+=1;
			$get('cmbMonthlySpend').options[$get('cmbMonthlySpend').length-1].value=dtMonthlySpend.rows[i]["Id"];
			$get('cmbMonthlySpend').options[$get('cmbMonthlySpend').length-1].text=dtMonthlySpend.rows[i]["SpendAmount"];
			
			//For Av. Client Monthly Ad spend
			if($get('cmbAvClientMonSMSpend')!=null)
			{
			    $get('cmbAvClientMonSMSpend').length+=1;
			    $get('cmbAvClientMonSMSpend').options[$get('cmbAvClientMonSMSpend').length-1].value=dtMonthlySpend.rows[i]["Id"];
			    $get('cmbAvClientMonSMSpend').options[$get('cmbAvClientMonSMSpend').length-1].text=dtMonthlySpend.rows[i]["SpendAmount"];
			}
		}
		    //For Monthly Ad spend
			$get('cmbMonthlySpend').options[0].value=0;
			$get('cmbMonthlySpend').options[0].text="-Select-";
			
			//For Av. Client Monthly Ad spend
			if($get('cmbAvClientMonSMSpend')!=null)
			{
			    $get('cmbAvClientMonSMSpend').options[0].value=0;
			    $get('cmbAvClientMonSMSpend').options[0].text="-Select-";
			}
	}
};

function ServerSide_TotalSpendPopulation(response)
{
	var dtTotalSpend=response;
	if(dtTotalSpend==null){return;}
	if(dtTotalSpend.rows.length>0)
	{
		for(var i=0; i<dtTotalSpend.rows.length;i++)
		{
			$get('cmbTotalSpend').length+=1;
			$get('cmbTotalSpend').options[$get('cmbTotalSpend').length-1].value=dtTotalSpend.rows[i]["Id"];
			$get('cmbTotalSpend').options[$get('cmbTotalSpend').length-1].text=dtTotalSpend.rows[i]["SpendAmount"];
		}
		$get('cmbTotalSpend').options[0].value=0;
		$get('cmbTotalSpend').options[0].text="-Select-";
	}
};

function ShowHideOther(chkOther, txtOther)
{
    txtOther.value="";
    if(chkOther.checked)
    {
        txtOther.style.visibility='visible';        
    }
    else
    {
        txtOther.style.visibility='hidden';        
    }
};
function SaveSignup()
{
    //debugger;
    SaveSignupCorp();
};

function ClearAll()
{
   ClearAllCorp();
};

function HideMsgLabelOnMasterPage()
{
    $get('lblMsg').innerHTML="";
    if($get('lblMsgBottom')!=null)
    {
        $get('lblMsgBottom').innerHTML="";
    }   
};

function checkCR(evt) 
{        
    var evt  = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text")) {return false;}        
};
function BrowerSniffer()
{
    if(navigator.userAgent.indexOf("MSIE 7.0") != -1 || navigator.userAgent.indexOf("Firefox/2") != -1  || navigator.userAgent.indexOf("Firefox/3.0") != -1 ||navigator.userAgent.indexOf("Firefox") != -1  || (navigator.userAgent.indexOf("MSIE 6.0") != -1 && navigator.userAgent.indexOf("SV1") != -1))
    {
    }
    else
    {
       $get("tr_message_sniffer").style.display = "block";
       DisableAll();
    }
};

//Created by Avik Chakraborty  on 24-01-2008
//It servers purpose of opeening windows popup through various ways.

function OpenPopUp(action)
{
    if(action == "PrivacyPolicy")
    {
        var left = (window.parent.document.body.offsetWidth/2) - (550/2);
        window.open("/Legal/PrivacyPolicy/PrivacyPolicy.html","WindowPrivacyPolicy","menubar=no,width=600,height=350,left="+left+", scrollbars=yes, top=250, toolbar=no, resizable=yes");       
    }
};




//--------------------START OF PARSER RELATED LOGIC-----------------------------------------------
// The function which contains the parser logic
// for differentiating between the marketing channels
// and for capturing customer related information.
//var DummyreferralUrl="http://search.yahoo.com/search?p=clickable+india&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8&fp_ip=IN&vc=";
function ParseUrl()
{   
    var ctt_ch = "";
    var ctt_nw = "";
    var ctt_id ="";
    var destinationUrl = location.href;
    var referralUrl = document.referrer;
    var myHostName = GetTopLevelDomain(destinationUrl);
    var refHostName = GetTopLevelDomain(referralUrl);
    
    ctt_ch = getLookUpValue(GetCtt_ch("ctt_ch"));
    
    if(ctt_ch != null)
    {
        ctt_nw = Getctt_nw("ctt_nw");
        
        if(ctt_ch=='BANNER AD' || ctt_ch=='VIDEO' || ctt_ch=='SOCIAL REFERRAL' )
        {
            ctt_id=refHostName;
        }
        else if(ctt_ch=='EMAIL MARKETING' || ctt_ch=='PAID SEARCH')
        {
            ctt_id = Getctt_id("ctt_id");
        }
    }
    else
    {
        ctt_ch = "";
        // First we should see if it is an organic search
        if (refHostName.indexOf("google.") >= 0)
        {
            // Search can be from Google
            var searchKeyword = GetOrganicSearchNetwork("q");
            if (searchKeyword != "")
            {
                ctt_id = searchKeyword;
                ctt_ch = getLookUpValue("os");
                ctt_nw = "Google";
            }
        }
        else if (refHostName.indexOf("yahoo.") >= 0)
        {
            // Search can be from Yahoo
            var searchKeyword = GetOrganicSearchNetwork("p");
            if (searchKeyword != "")
            {
                ctt_id = searchKeyword;
                ctt_ch = getLookUpValue("os");
                ctt_nw = "Yahoo";
            }
        }
        //Arun: 17 June 2009: As Microsoft has changed their Search Engine to “Bing”, so checking this also. 
        else if (refHostName.indexOf("msn.") >= 0 || refHostName.indexOf("bing.") >= 0)
        {
            // Search can be from MSN
            var searchKeyword = GetOrganicSearchNetwork("q");
            if (searchKeyword != "")
            {
                ctt_id = searchKeyword;
                ctt_ch = getLookUpValue("os");
                ctt_nw = "MSN";
            }
        }
        else if (refHostName.indexOf("live.") >= 0)
        {
            // Search can be from Windows Live
            var searchKeyword = GetOrganicSearchNetwork("q");
            if (searchKeyword != "")
            {
                ctt_id = searchKeyword;
                ctt_ch = getLookUpValue("os");
                ctt_nw = "Windows Live";
            }
        }
        else if (refHostName.indexOf("aol.") >= 0)
        {
            // Search can be from AOL
            var searchKeyword = GetOrganicSearchNetwork("query");
            if (searchKeyword != "")
            {
                ctt_id = searchKeyword;
                ctt_ch = getLookUpValue("os");
                ctt_nw = "AOL";
            }
        }
        else if (refHostName.indexOf("ask.") >= 0)
        {
            // Search can be from Ask
            var searchKeyword = GetOrganicSearchNetwork("q");
            if (searchKeyword != "")
            {
                ctt_id = searchKeyword;
                ctt_ch = getLookUpValue("os");
                ctt_nw = "Ask";
            }
        }
        // If the value of ctt_ch and ctt_nw are still EMPTY
        // we should check if it is from the same domain or if there is no referral.
        // If yes, it is DIRECT REFERRAL or else it will be a WEBSITE REFERRAL
        if(ctt_nw == "" && ctt_ch == "")
        {
            ctt_nw = refHostName;
            if (refHostName == myHostName || referralUrl == "")
            {
                ctt_id = "";
                ctt_ch = getLookUpValue("dr");
            }
            else
            {
                ctt_id = "";
                ctt_ch = getLookUpValue("wr");
            }
        }
    }    
    ExpiryDate=__aCMasterCookie.addDays2Today(365);
    var Domain=document.domain;
    var strCookie = "ctt_ch=" + ctt_ch + "|" + "ctt_id=" + ctt_id + "|" + "ctt_nw=" + ctt_nw + "|" + "referralUrl=" +referralUrl + "|" + "destinationUrl=" + destinationUrl ;

    var old_ctt_ch= __aCMasterCookie.getCookieValue("SalesFunnelCookie","ctt_ch");
    
    var overwriteCookie = false;
    // write a new cookie if nothing exists
    if (old_ctt_ch == "" || old_ctt_ch == null)
    {
        overwriteCookie = true;
    }
    else
    {
        // if the channels are same, overwrite with the new values
        if (old_ctt_ch == ctt_ch)
        {
            overwriteCookie = true;
        }
        else
        {
            // if the new channel is PAID SEARCH or WEBSITE referralUrl
            // existing cookie should always be overwritten
            if (ctt_ch == getLookUpValue("wr") || ctt_ch == getLookUpValue("ps"))
            {
                overwriteCookie = true;
            }
            // if new channel is ORGANIC SEARCH, 
            // overwrite only if the existing channel is DIRECT REFERRAL
            else if (ctt_ch == getLookUpValue("os") && old_ctt_ch == getLookUpValue("dr"))
            {
                overwriteCookie = true;
            }
        }
    }
    
    //alert(strCookie.replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n").replace("|","\n") + "\nExisinting Channel: '" + old_ctt_ch + "'\n\n" + "Cookie will " + (overwriteCookie ? "" : "not ") + "be overwritten");
    
    if (overwriteCookie)
    {
        document.cookie = "SalesFunnelCookie=" + strCookie +
            "; path=/"+
            "; domain=clickable.com"+"; expires="+ExpiryDate;
    }
};

function GetTopLevelDomain(url)
{
    var retVal = GetHostName(url);
    var urlParts = retVal.split(".");
    var partCount = urlParts.length;
    
    if (partCount <= 2)
    {
        return retVal;
    }
    else if (urlParts[0].toLowerCase().indexOf("www") >= 0)
    {
        if (partCount == 3)
        {
            return urlParts[1] + "." + urlParts[2];
        }
        else
        {
            if (urlParts[partCount - 2].length <= 3)
            {
                return urlParts[partCount - 3] + "." + urlParts[partCount - 2] + "." + urlParts[partCount - 1];
            }
            else
            {
                return urlParts[partCount - 2] + "." + urlParts[partCount - 1];
            }
        }
    }
    else
    {
        if (urlParts[partCount - 2].length <= 3)
        {
            return urlParts[partCount - 3] + "." + urlParts[partCount - 2] + "." + urlParts[partCount - 1];
        }
        else
        {
            return urlParts[partCount - 2] + "." + urlParts[partCount - 1];
        }
    }
}
// This function returns the HostName for a given URL
function GetHostName(url)
{
    var retVal = url.toLowerCase();
    var checkPos = url.indexOf("://");
    if (checkPos > 0)
    {
        checkPos = checkPos + 3;
    }
    else
    {
        checkPos = 0;
    }
    retVal = retVal.substring(checkPos);
    checkPos = retVal.indexOf("/");
    if (checkPos > 0)
    {
        retVal = retVal.substring(0, checkPos);
    }
    return retVal;
}
 //The function gets the utm_term attribute
// for the organic search type marketing channel.
function GetOrganicSearchNetwork(SearchIdentifier)
{
    
    ctt_ch = SearchIdentifier.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+SearchIdentifier+"=([^&#]*)";  
    var regex = new RegExp(regexS);  
    var results = regex.exec(document.referrer);  
    if(results == null)    
        return "";  
    else    
        return results[1];
}
// The function for extracting the utm_medium code
function GetCtt_ch(ctt_ch)
{  
    ctt_ch=ctt_ch.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    //ctt_ch = utm_medium.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+ctt_ch+"=([^&#]*)";  
    var regex = new RegExp(regexS);  
    var results = regex.exec(window.location.href);  
    if(results == null)    
        return "";  
    else    
        return results[1];
};
// The function for getting the look up data
function getLookUpValue(key)
{
      switch (key.toUpperCase())
      {
            case "PS":
                  return "PAID SEARCH";
            case "EM":
                  return "EMAIL MARKETING";
            case "BN":
                  return "BANNER AD";
            case "VI":
                  return "VIDEO";
            case "SR":
                  return "SOCIAL REFERRAL";
            case "OS":
                  return "ORGANIC SEARCH";
            case "WR":
                  return "WEBSITE REFERRAL";
            case "DR":
                  return "DIRECT REFERRAL";
            default:
                  break;
      }
};
// The function for extracting the utm_source code
function Getctt_nw(ctt_nw)
{
    ctt_nw = ctt_nw.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+ctt_nw+"=([^&#]*)";  
    var regex = new RegExp(regexS);  
    var results = regex.exec(window.location.href);  
    if(results == null)    
        return "";  
    else    
        return results[1];
};
// The function for extracting the utm_term code
function Getctt_id(ctt_id)
{
    ctt_id = ctt_id.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+ctt_id+"=([^&#]*)";  
    var regex = new RegExp(regexS);  
    var results = regex.exec(window.location.href);  
    if(results == null)    
        return "";  
    else    
        return results[1];
};

//----------------------------------- END OF PARSER RELATED LOGIC----------------------------------



//
// TEAencrypt: Use Corrected Block TEA to encrypt plaintext using password
//             (note plaintext & password must be strings not string objects)
//
// Return encrypted text as string
//
function TEAencrypt(plaintext, password)
{
    if (plaintext.length == 0) return('');  // nothing to encrypt
    // 'escape' plaintext so chars outside ISO-8859-1 work in single-byte packing, but keep
    // spaces as spaces (not '%20') so encrypted text doesn't grow too long (quick & dirty)
    var asciitext = escape(plaintext).replace(/%20/g,' ');
    var v = strToLongs(asciitext);  // convert string to array of longs
    if (v.length <= 1) v[1] = 0;  // algorithm doesn't work for n<2 so fudge by adding a null
    var k = strToLongs(password.slice(0,16));  // simply convert first 16 chars of password as key
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = 0;

    while (q-- > 0) {  // 6 + 52/n operations gives between 6 & 32 mixes on each word
        sum += delta;
        e = sum>>>2 & 3;
        for (var p = 0; p < n; p++) {
            y = v[(p+1)%n];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z);
            z = v[p] += mx;
        }
    }

    var ciphertext = longsToStr(v);

    return escCtrlCh(ciphertext);
};

//
// TEAdecrypt: Use Corrected Block TEA to decrypt ciphertext using password
//
function TEAdecrypt(ciphertext, password)
{
    if (ciphertext.length == 0) return('');
    var v = strToLongs(unescCtrlCh(ciphertext));
    var k = strToLongs(password.slice(0,16)); 
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = q*delta;

    while (sum != 0) {
        e = sum>>>2 & 3;
        for (var p = n-1; p >= 0; p--) {
            z = v[p>0 ? p-1 : n-1];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z);
            y = v[p] -= mx;
        }
        sum -= delta;
    }

    var plaintext = longsToStr(v);

    // strip trailing null chars resulting from filling 4-char blocks:
    plaintext = plaintext.replace(/\0+$/,'');

    return unescape(plaintext);
};


// supporting functions

function strToLongs(s)
 {  // convert string to array of longs, each containing 4 chars
    // note chars must be within ISO-8859-1 (with Unicode code-point < 256) to fit 4/long
    var l = new Array(Math.ceil(s.length/4));
    for (var i=0; i<l.length; i++) {
        // note little-endian encoding - endianness is irrelevant as long as 
        // it is the same in longsToStr() 
        l[i] = s.charCodeAt(i*4) + (s.charCodeAt(i*4+1)<<8) + 
               (s.charCodeAt(i*4+2)<<16) + (s.charCodeAt(i*4+3)<<24);
    }
    return l;  // note running off the end of the string generates nulls since 
};              // bitwise operators treat NaN as 0

function longsToStr(l) {  // convert array of longs back to string
    var a = new Array(l.length);
    for (var i=0; i<l.length; i++) {
        a[i] = String.fromCharCode(l[i] & 0xFF, l[i]>>>8 & 0xFF, 
                                   l[i]>>>16 & 0xFF, l[i]>>>24 & 0xFF);
    }
    return a.join('');  // use Array.join() rather than repeated string appends for efficiency
};

function escCtrlCh(str)
{  // escape control chars etc which might cause problems with encrypted texts
    return str.replace(/[\0\t\n\v\f\r\xa0'"!]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
};

function unescCtrlCh(str) 
{  // unescape potentially problematic nulls and control characters
    return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
};

//This function allows(all numbers(0-9),-,()) 
//+ : shift + 61 
//( : shift + 57
//) : shift + 48
//- : shift + 187

function ValidatePhone(eventElement)
{	
    var bubbleEvent = false;
    if(eventElement.shiftKey==true && eventElement.keyCode==9)
    {
        bubbleEvent=true;
    }
    else if(eventElement.shiftKey==true && (eventElement.keyCode==48 || eventElement.keyCode==57 ||  eventElement.keyCode==187))
    {
         bubbleEvent=true;
    }
    else if(eventElement.shiftKey==false && ((eventElement.keyCode>=48 && eventElement.keyCode<=57)||(eventElement.keyCode>=96 && eventElement.keyCode<=105)||(eventElement.keyCode==46) ||(eventElement.keyCode==189)||(eventElement.keyCode==109)||(eventElement.keyCode==190)||(eventElement.keyCode==107)))
    {
       bubbleEvent=true;
    }
    else if(eventElement.shiftKey==false && (common.ValidateKeys(eventElement)))
    {
       bubbleEvent=true;
    }
    else
    {
        bubbleEvent=false;
    }
    if (! bubbleEvent) 
	{
		eventElement.preventDefault();
	}
	    return bubbleEvent;
};
function TextOnly(eventElement)
{        
    var bubbleEvent = false;
    if ((eventElement.keyCode >=65  && eventElement.keyCode <=90)||eventElement.keyCode==32 || eventElement.keyCode==8 || eventElement.keyCode==46 || eventElement.keyCode==37 || eventElement.keyCode==39 || eventElement.keyCode==9)
	{
	   bubbleEvent = true;
	}
	else if(eventElement.shiftKey==false && (common.ValidateKeys(eventElement)))
    {
       bubbleEvent=true;
    }
    else
    {
	   bubbleEvent = false;
	}   
	    
    if (! bubbleEvent) 
	{
		eventElement.preventDefault();
	}

	    return bubbleEvent;
};	
function vaidateSpecialCharacter(eventElement)
{
     hideErrorPopup();
     var bubbleEvent = false;
     if ((eventElement.keyCode >=65  && eventElement.keyCode <=90) || eventElement.keyCode==8 || eventElement.keyCode==46 || eventElement.keyCode==37 || eventElement.keyCode==39 || eventElement.keyCode==9)
     {
	   bubbleEvent = true;
	 }
	 else if(eventElement.shiftKey==false && ((eventElement.keyCode>=48 && eventElement.keyCode<=57)||(eventElement.keyCode>=96 && eventElement.keyCode<=105)))
     {
       bubbleEvent=true;
     }
	 else if((eventElement.shiftKey==true && eventElement.keyCode == 50) ||(eventElement.keyCode == 190)||(eventElement.shiftKey==true && eventElement.keyCode == 189)||(eventElement.keyCode == 189) )
     {
       bubbleEvent=true;
     }
     else
     {
	   bubbleEvent = false;
	 }   
	    
     if (! bubbleEvent) 
	 {
	    common.ShowErrorPopUp('Special characters not allowed.',eventElement.target);
		eventElement.preventDefault();
	 }
	    return bubbleEvent;

};


/*
Decription: Functions being used for NewsLetter feature.
Author:     Rashmi Ranjan Sinha.
Date:       Jan-09-2009.
*/
function HideError()
{
        
    document.getElementById('divErrorPopUp').style.display='none';
    if(event.keyCode==13)
    {
        
        if(ValidateEmailInput(txtNLEmailID))
        {
            document.all[btnSubmitID].click();
        }
        
    }    
  
    return false;
};
function HideText()
{
    if(document.getElementById(txtNLEmailID).value=="enter your email")
    document.getElementById(txtNLEmailID).value="";
};
function PresentText()
{
    if(document.getElementById(txtNLEmailID).value=="")
    document.getElementById(txtNLEmailID).value="enter your email";
};
/* 
function NewsletterResponse()
{
    
    var response=document.getElementById(serverMessageClientID).value;
    if(response=='Success')
    {
        dv_newsletter_response.InnerText = "Thank you! You have successfully signed up for our newsletter.";
        tbl_Newsletter.style.display = 'none';
        dv_newsletter_response.style.display = 'block';
    }
    else if(response=="")
    {
        document.getElementById('divErrorPopUp').style.marginTop="-8px";    
        document.getElementById('errorMessage').innerHTML='Newsletter sign up was not succssfull.Please try again!';
        document.getElementById('divErrorPopUp').style.display='block';
    }
    else
    {
        if(window.location.toString().indexOf("products")!=-1 || window.location.toString().indexOf("Products")!=-1 || window.location.toString().indexOf("Corp")!=-1 || window.location.toString().indexOf("corp")!=-1)
        {
            document.getElementById('divErrorPopUp').style.marginTop="-8px";    
            document.getElementById('errorMessage').innerHTML=response;
            document.getElementById('divErrorPopUp').style.display='block';
        }
    }
}*/


function ValidateEmailInput(emailAddress)
{
    
    var showMessage="";
    
    emailAddress=document.getElementById(emailAddress); 
    if(window.location.toString().indexOf("products")!=-1 || window.location.toString().indexOf("Products")!=-1 || window.location.toString().indexOf("Corp")!=-1 || window.location.toString().indexOf("corp")!=-1)
    {
        document.getElementById('divErrorPopUp').style.marginTop="-16px";    
    }  
    /*if(window.location.toString().indexOf("Products/agencies")!=-1 || window.location.toString().indexOf("products/advertisers")!=-1 || window.location.toString().indexOf("products/pricing.aspx")!=-1)
    {
        document.getElementById('nipple')
    }*/
    
    
    if (emailAddress.value.length==0)
    {        
        document.getElementById('errorMessage').innerHTML='Please enter email address';
        
        document.getElementById('divErrorPopUp').style.display='block';
        theForm.onsubmit = function(){return false;};
        return false;
    }
    else if (emailAddress.value.indexOf('<')!=-1 || emailAddress.value.indexOf('>')!=-1)
    {
        document.getElementById('errorMessage').innerHTML='Angle bracket is not allowed.';
        
        document.getElementById('divErrorPopUp').style.display='block';
        theForm.onsubmit = function(){return false;};
        return false;
    }
    else
    {        
        if(common.ValidateEmailAddress(emailAddress.value)==false || common.CheckExt4Email(emailAddress.value)==false)
        {
            theForm.onsubmit = function(){return false;};
            document.getElementById('errorMessage').innerHTML='Please enter valid email address';
            document.getElementById('divErrorPopUp').style.display='block';
            return false;
        }
        //1. Check valid email address which should contain "@.".  
        //   If return flase then show message and revert server post back.
        /*var patternSearch1=new RegExp("[@.]");
        patternSearch1.ignoreCase=false;
        if (patternSearch1.test(emailAddress.value)==false)
        {
            
            theForm.onsubmit = function(){return false;};
            document.getElementById('errorMessage').innerHTML='Please enter valid email address';
            document.getElementById('divErrorPopUp').style.display='block';
            return false;
        }

        //2. Check "@" globally for multiple occurence.        
        var patternSearch2=new RegExp("[@]","g");
        var result1=emailAddress.value.match(patternSearch2);        
        if (result1.length>2) 
        {
            
            theForm.onsubmit = function(){return false;};
            document.getElementById('errorMessage').innerHTML='Please enter valid email address';
            document.getElementById('divErrorPopUp').style.display='block';
            return false;
        }
        
        //3. Check no. of character put after ".".  
        //   If this is less than 3 then show message and revert server post back.       
        var result4=emailAddress.value.lastIndexOf(".");  
        var partString4 = emailAddress.value.substring(result4+1,emailAddress.value.length);
        
        if (partString4.length<3) 
        {
            
            theForm.onsubmit = function(){return false;};
            document.getElementById('errorMessage').innerHTML='Please enter valid email address';
            document.getElementById('divErrorPopUp').style.display='block';
            return false;
        }*/
        

        theForm.onsubmit =null;
        document.getElementById(tbl_Newsletter).visible=false;
        //document.getElementById(dv_newsletter_response).visible=false;
        document.getElementById('imgLoading').style.display='block';//src="~/images/line.gif";
        return true;
        
    }
           
};




/*
Description:  Show message returned from server.
*/
function serverCallBack(getServerMessage)
{
    
    if(window.location.toString().indexOf("products")!=-1 || window.location.toString().indexOf("Products")!=-1 || window.location.toString().indexOf("Corp")!=-1 || window.location.toString().indexOf("corp")!=-1)
    {
        document.getElementById('divErrorPopUp').style.marginTop="-8px";    
    }  
    document.getElementById('errorMessage').innerHTML=getServerMessage;
    document.getElementById('divErrorPopUp').style.display='block';
}

/*
End of Functions being used for NewsLetter feature.
*/



