//========================================================================================
// Form fix (Feb 10, 2005)
// closes any previously opened form tag.
//========================================================================================
//========================================================================================
// Incialize necessary variables
//========================================================================================
    var strhidSection;
	var partnerID;
	var filter;
	var style;
	var qualifytitle;
	var bbnhome;
	var bbnbusiness;
	var bbnenterprise;
	var form;
	var shortform;
	var ipd;
	var logoHide;
	var logo;

//========================================================================================
// Set Variables
//========================================================================================


	//strhidSection = "Home"
	partnerID = "BBN"	
	filter = ""	
	rtext = "Home"	
	btext = "Business"	
		
	style = ""	
	qualifytitle = "Get Real Time Quotes For Broadband"	
	bbnhome = "true"	
	bbnbusiness = "true"	
	bbnenterprise = "true"	
	form = ""
	bbnNoPhone = "false"
	moved = "true"	
	test = "www.broadbandnational.com"
	optin = "true"
	optin_check = "false"	
	checktext = "Yes, I'd like to receive updates on special broadband offers or availability in my area."	
	shortform = "false"	
	extrafield = "false"	
	extrafieldtext = "Extra Field:"	
	extrafieldrequired = "false"	
	ipd = "false"	
	nocallback = "false"	
	nocallbackhome = "false"	
	nocallbackbusiness = "false"	
	call_back = "false"	
	call_back_text = "I would like to have a Broadband consultant contact me back for further assistance."	
	call_back_checked = "checked"	 // ===============================
	 // Call Back Black List
	 // ===============================
			if((partnerID == "covad") || (partnerID == "fhtm") || (partnerID == "fionda")){
				call_back_checked = "";
			}
			if((partnerID == "comcast_cj")){
				call_back_checked = "checked";
			}
				// ================================
	
	openin = "default"	
	// =================================
	
	img = "default"	
	// =================================
	
	logoHide = "false"	
	// =================================
	
		
	// === DEFAULT SERVICE ==============================
	
	DefaultServ = "home"	
	// === LOGO =======================================
	//   Changes the display of the provider logos on the results page
	//   Added on 4-18-2006
	
	logo = "1000"	
	debug = "false"	
	// === Salesteam Additional Information Flag ========================
	//   Adds more information to the Results page so that salesteam agents obtain additional information regarding the qual
	//   Added on 6/20/2006
	
	salesteam = "N"	
	// === Customized Text for Qual Form ================================
	// Added July 14, 2006
	
	ServicePhoneText = "Enter Service Phone:"	
	ContactNumberText = "Contact Number:"	
	EnterEmailText = "Enter Your Email:"	
	ContactNameText = "Contact Name:"	
// === Load Powered by IBIS or BBN =======================================================
//  Updated: July  17, 2006
	
	PoweredBy = "http://www.broadbandnational.com/images/bbn88x31powered.gif"		
//========================================================================================
// qualification form functions
//========================================================================================

////// Targus.asp?ContactName=test&ServicePhone=1234567890&Email=test@test.com&ContactPhone=1234567890&Type=home&referring_partner=dslcity 
///// General Note 
///// 1. The controls in input.asp  and HomePage.asp are with same name hence 
/////    a single function in validation.js  "checkHomePageInputValues()" is used

// Function Name  : CallTargus  
// Description    : This function constructs a url for redirection with relevent form values after checking the validations
// Author          : S.M.P.Gokulnath
// Created Date    :  Sep -09- 2004
// Last modified  : June 30, 2005 by David Rodriguez

// Required Variables:
//      	partnerID    - Afiliate Identification
//      	filter       - code to filter service providers in results page

// This function determines how to return the results page after a qualification.
//    Self and Defualt  - returns results on the same page
//    Parent            - returns results on a parent page (such as the top level of a frame or iframe page)
//    New               - returns results in a pop or new winodw.
// Created by David Rodriguez
// Last Modified: June 30, 2005
function RedirectPage(strlocation) {
	prompt('',strlocation);
	/* switch (openin) {
	case 'self': location.href = strlocation; break;
	case 'parent': parent.location.href=strlocation; break;
	case 'new': window.open(strlocation); break;
	default: location.href = strlocation;
	} */
}

function GetAddress(strlocation) {
	strRedirURL = "http://www.broadbandnational.com/business/targus.asp?location=" + strlocation + "&ServicePhone=" + document.IndexForm1.DSLPhoneAreaCode.value + document.IndexForm1.DSLPhoneFirst.value +document.IndexForm1.DSLPhoneLast.value;
	RedirectPage(strRedirURL);
}

//This function will check if particular object is defined or available or not, if available
//return true and if not available return false
function isDefined(uObject)
{
	return typeof(uObject) == "undefined" ? false:true;	
}

// This function allows the value of the extrafield input box to append to the partnerID var 
function updatePartnerID()
{
	if (isDefined(document.IndexForm1.extrafield) == true)	{
		if (document.IndexForm1.extrafield.value != "") {
			if (partnerID.indexOf("-") != -1)	{
				partnerID = partnerID + ":" + document.IndexForm1.extrafield.value;
			} else {
			partnerID = partnerID + "-" + document.IndexForm1.extrafield.value;
			}
		}
	}
}

function CallTargus()
{
	// appends extrafiled value (if it exists) to the partnerID variable
	updatePartnerID();
	
	var str_call_back;
	str_call_back="N";
	
	if (isDefined(document.IndexForm1.call_back) == true)
	{
		if (document.IndexForm1.call_back.checked == true)
		{
			str_call_back = "Y";
		}
		else
		{
			str_call_back = "N";
		}
	}
	else
	{
		str_call_back = "Y";
	}
	if (document.IndexForm1.rbhome.checked==false &&  document.IndexForm1.rbbusiness.checked==false)
	{
		alert("Please Select  'Qualify Service for'  ");
		document.IndexForm1.rbhome.focus();
		return;
	}
	var strhidSection;
		if (document.IndexForm1.rbhome.checked==true)
		{
			strhidSection = "home"
		}
		else
		{
			strhidSection = "business"
		}
	if(document.IndexForm1.RecentMove.checked==true)
	{
		var sFullName="";
		var sFirstName="";
		var sLastName="";
		var ss="";
		sFullName= document.IndexForm1.name.value
		if(sFullName.length>0)
		{
			sFullName=sFullName.replace(/^\s*(.*)/, "$1");
			sFullName=sFullName.replace(/(.*?)\s*$/, "$1");
			arr1=sFullName.split(" ");
			count=1;
			sFirstName=arr1[0];	 
			while(count < arr1.length)
			{
				ss=ss + " " + arr1[count];
				count = count+1;
			}
			 sLastName=ss;
		}

			if (strhidSection.toLowerCase()=="home")
			{
			strRedirURL="http://" + test + "/index.asp?section=home&layout=long&file=homeindex"		
	 		strRedirURL=strRedirURL + "&YourName=" + document.IndexForm1.name.value
			strRedirURL=strRedirURL + "&ServicePhone=" + document.IndexForm1.DSLPhoneAreaCode.value + document.IndexForm1.DSLPhoneFirst.value +document.IndexForm1.DSLPhoneLast.value

			strRedirURL=strRedirURL + "&Email=" + document.IndexForm1.shopper_email.value
			strRedirURL=strRedirURL + "&ContactPhone=" + document.IndexForm1.DSLPhoneAreaCode2.value + document.IndexForm1.DSLPhoneFirst2.value +document.IndexForm1.DSLPhoneLast2.value

			if (nocallback == "true"){
            	if (nocallbackhome == "true"){
                        strRedirURL = strRedirURL+"&call_back=N";}
            else {
					strRedirURL = strRedirURL+"&call_back=Y";}	}
			
			if (nocallback == "false"){
			strRedirURL=strRedirURL +"&call_back=" + str_call_back;
		}


			strRedirURL=strRedirURL + "&RecentMove=yes" 
			strRedirURL=strRedirURL + "&fname=" +sFirstName
	 		strRedirURL=strRedirURL + "&lname=" + sLastName
			strRedirURL=strRedirURL + "&Type=" + strhidSection
			strRedirURL=strRedirURL + "&referring_partner=" +partnerID
			strRedirURL=strRedirURL +"&targusflag=no"
			strRedirURL=strRedirURL +"&autophoneflag=no"
		    strRedirURL=strRedirURL +"&FilterOnly=" + filter
		    strRedirURL=strRedirURL +"&logo=" + logo
		    strRedirURL=strRedirURL +"&salesteam=" + salesteam

				
				RedirectPage(strRedirURL);
		
			}
			if (strhidSection.toLowerCase()=="business")
			{	 
			strRedirURL="http://" + test + "/index.asp?section=business&layout=long&file=businessindex"		
	 		strRedirURL=strRedirURL + "&YourName=" + document.IndexForm1.name.value
			strRedirURL=strRedirURL + "&ServicePhone=" + document.IndexForm1.DSLPhoneAreaCode.value + document.IndexForm1.DSLPhoneFirst.value +document.IndexForm1.DSLPhoneLast.value

			strRedirURL=strRedirURL + "&Email=" + document.IndexForm1.shopper_email.value
			strRedirURL=strRedirURL + "&ContactPhone=" + document.IndexForm1.DSLPhoneAreaCode2.value + document.IndexForm1.DSLPhoneFirst2.value +document.IndexForm1.DSLPhoneLast2.value

			strRedirURL=strRedirURL + "&RecentMove=yes" 
			strRedirURL=strRedirURL + "&fname=" +sFirstName
	 		strRedirURL=strRedirURL + "&lname=" + sLastName
			if (document.IndexForm1.rbhome.checked==true && document.IndexForm1.rbbusiness.checked==true)
			{
				strRedirURL=strRedirURL + "&Type=" + "Business"
			}
			else
			{
				if (document.IndexForm1.rbhome.checked==true)
				{
					strRedirURL=strRedirURL + "&Type=" + "Home"
				}
				if (document.IndexForm1.rbbusiness.checked==true)
				{
					strRedirURL=strRedirURL + "&Type=" + "Business"
				}
			}
			strRedirURL=strRedirURL + "&referring_partner="+partnerID
			strRedirURL=strRedirURL +"&targusflag=no"
			strRedirURL=strRedirURL +"&autophoneflag=no"
		    strRedirURL=strRedirURL +"&FilterOnly=" + filter
			
			if (nocallback == "true"){
				if (nocallbackbusiness == "true"){
					strRedirURL = strRedirURL+"&call_back=N";}
	            else {
					strRedirURL = strRedirURL+"&call_back=Y";}	}
					
			if (nocallback == "false"){
			strRedirURL=strRedirURL +"&call_back=" + str_call_back;
		}
		    strRedirURL=strRedirURL +"&logo=" + logo
		    strRedirURL=strRedirURL +"&salesteam=" + salesteam


				RedirectPage(strRedirURL);
			}
	}
	else
	{	
//  checkHomePageInputValues validation function is called 	from validation.js  file //////////  
	  if(checkHomePageInputValues(strhidSection))
	 {
 		var sFullName="";
		var sFirstName="";
		var sLastName="";
		var ss="";
		sFullName= document.IndexForm1.name.value
		if(sFullName.length>0)
		{
			sFullName=sFullName.replace(/^\s*(.*)/, "$1");
			sFullName=sFullName.replace(/(.*?)\s*$/, "$1");
			arr1=sFullName.split(" ");
			count=1;
			sFirstName=arr1[0];	 
			while(count < arr1.length)
			{
				ss=ss + " " + arr1[count];
				count = count+1;
			}
			 sLastName=ss;
		}


	 	strRedirURL="targus.asp"
	 	strRedirURL=strRedirURL + "&yourname=" + document.IndexForm1.name.value
		strRedirURL=strRedirURL + "&fname=" +sFirstName
 		strRedirURL=strRedirURL + "&lname=" + sLastName
		strRedirURL=strRedirURL + "&ServicePhone=" + document.IndexForm1.DSLPhoneAreaCode.value + document.IndexForm1.DSLPhoneFirst.value +document.IndexForm1.DSLPhoneLast.value

		strRedirURL=strRedirURL + "&Email=" + document.IndexForm1.shopper_email.value
		strRedirURL=strRedirURL + "&ContactPhone=" + document.IndexForm1.DSLPhoneAreaCode2.value + document.IndexForm1.DSLPhoneFirst2.value +document.IndexForm1.DSLPhoneLast2.value
		
		strRedirURL=strRedirURL + "&RecentMove=" + document.IndexForm1.RecentMove.value
		if (document.IndexForm1.rbhome.checked==true)
		{
			strRedirURL=strRedirURL + "&Type=" + "Home"
				if (nocallback == "true"){
            		if (nocallbackhome == "true"){
                        strRedirURL = strRedirURL+"&call_back=N";}
           			 else {
						strRedirURL = strRedirURL+"&call_back=Y";}	}

		
		}
		if (document.IndexForm1.rbbusiness.checked==true)
		{
			strRedirURL=strRedirURL + "&Type=" + "Business"
			
			if (nocallback == "true"){
				if (nocallbackbusiness == "true"){
					strRedirURL = strRedirURL+"&call_back=N";}
	            else {
					strRedirURL = strRedirURL+"&call_back=Y";}	}

		}
		strRedirURL=strRedirURL + "&referring_partner=" +partnerID
		strRedirURL=strRedirURL + "&id=" +partnerID
		strRedirURL=strRedirURL +"&targusflag=yes"
		strRedirURL=strRedirURL +"&autophoneflag=no"
		strRedirURL=strRedirURL +"&FilterOnly=" + filter
		
		if (nocallback == "false"){
			strRedirURL=strRedirURL +"&call_back=" + str_call_back;
		}
		    strRedirURL=strRedirURL +"&logo=" + logo
		    strRedirURL=strRedirURL +"&salesteam=" + salesteam
		

				
// function called to show popup window 
	  // TimedPopup("winpopup.asp",400,300,10);
 RedirectPage("http://" + test + "/winpopup.asp?Redirfile="+strRedirURL);		 
	  }
	} //else
 }
 
 function NoServicePhone()
{
	var str_call_back;
	str_call_back="N";
	
	if (isDefined(document.IndexForm1.call_back) == true)
	{
		if (document.IndexForm1.call_back.checked == true)
		{
			str_call_back = "Y";
		}
		else
		{
			str_call_back = "N";
		}
	}
	
	if (document.IndexForm1.rbhome.checked==false &&  document.IndexForm1.rbbusiness.checked==false)
	{
		alert("Please Select  'Qualify Service for'  ");
		document.IndexForm1.rbhome.focus();
		return;
	}
	if (document.IndexForm1.rbhome.checked==true)
	{
		strRedirURL="http://" + test + "/index.asp?section=home&layout=long&file=homeindex&hideflag=yes"		
		strRedirURL=strRedirURL + "&Type=Home"
	}
	if(document.IndexForm1.rbbusiness.checked==true)
	{
		strRedirURL="http://" + test + "/index.asp?section=business&layout=long&file=businessindex&hideflag=yes"
		strRedirURL=strRedirURL + "&Type=Business"
	}
		var sFullName="";
		var sFirstName="";
		var sLastName="";
		var ss="";
		sFullName= document.IndexForm1.name.value
		if(sFullName.length>0)
		{
			sFullName=sFullName.replace(/^\s*(.*)/, "$1");
			sFullName=sFullName.replace(/(.*?)\s*$/, "$1");
			arr1=sFullName.split(" ");
			count=1;
			sFirstName=arr1[0];	 
			while(count < arr1.length)
			{
				ss=ss + " " + arr1[count];
				count = count+1;
			}
			 sLastName=ss;
		}


	 		strRedirURL=strRedirURL + "&yourname=" + document.IndexForm1.name.value
			strRedirURL=strRedirURL + "&ServicePhone=" + document.IndexForm1.DSLPhoneAreaCode.value + document.IndexForm1.DSLPhoneFirst.value +document.IndexForm1.DSLPhoneLast.value

			strRedirURL=strRedirURL + "&Email=" + document.IndexForm1.shopper_email.value
			strRedirURL=strRedirURL + "&ContactPhone=" + document.IndexForm1.DSLPhoneAreaCode2.value + document.IndexForm1.DSLPhoneFirst2.value +document.IndexForm1.DSLPhoneLast2.value

			strRedirURL=strRedirURL + "&RecentMove=yes" 
			strRedirURL=strRedirURL + "&fname=" +sFirstName
	 		strRedirURL=strRedirURL + "&lname=" + sLastName
			strRedirURL=strRedirURL + "&referring_partner=" +partnerID
			strRedirURL=strRedirURL +"&targusflag=no"
			strRedirURL=strRedirURL +"&autophoneflag=no"
		    strRedirURL=strRedirURL +"&FilterOnly=" + filter
			strRedirURL=strRedirURL +"&call_back=" + str_call_back
		    strRedirURL=strRedirURL +"&logo=" + logo
		    strRedirURL=strRedirURL +"&salesteam=" + salesteam

				RedirectPage(strRedirURL);
		
}

// Function Name  : checkradioHome  
// Description    : This function makes radio button home appear as checked  and makes radio button business unchecked
//Author          : S.M.P.Gokulnath
//Created Date    :  Sep -09- 2004
function checkradioHome()
{
document.IndexForm1.rbhome.checked=true
document.IndexForm1.rbbusiness.checked=false
document.IndexForm1.rbmulti.checked=false

}

// Function Name  : checkradioBusiness
// Description    : This function makes radio button business appear as checked  and makes radio button home unchecked
//Author          : S.M.P.Gokulnath
//Created Date    :  Sep -09- 2004
function checkradioBusiness()
{
document.IndexForm1.rbhome.checked=false
document.IndexForm1.rbbusiness.checked=true
document.IndexForm1.rbmulti.checked=false
}

function multiinput()
{
    document.IndexForm1.rbhome.checked=false
    document.IndexForm1.rbbusiness.checked=false
    document.IndexForm1.rbmulti.checked=true
    RedirectPage("http://" + test + "/multi_body.asp" + "?referring_partner=" +partnerID + "&id=" +partnerID +"&FilterOnly=" + filter);
}


//========================================================================================
// Validation Script
//========================================================================================

////**********************************************************************************************************
////* Author		 :	S.M.P.Gokulnath
////* Start Date	 :	September ,9, 2004
////* Last Modified  :	 
////* Project Name	 :	BBN
////* File Name	     :	validation.js
////* LOC			 :	
////* Version No.	 :	1.0.0	
////* Developed By   :	S.M.P.Gokulnath
////* purpose / Functionality       : This File contains general common functions 
////    1. TimedPopup 		- To show a popup window for specified number of seconds
////    2. IsNumeric(sText) - Checks whether passed value is Numeric - returns true if all are numeric and false if any character is found in 					 
////						  passed parameter

var TimeOut = 1;    // Initial time to Close window after __ number of seconds?
var TimeRemain = 0;  // Remaining time to Close window after __ number of seconds?
var RefreshRate = 0; // Check to close window every __ number of seconds?
var ChildWin = null;
// function  TimedPopup takes 4 parameter
/// 1. url = physical files to be displayed in the popup window /  constructed html string content can also be passed that is to be displayed 
/// 2. w   = width of popup window
/// 3. h   = height of popup window 
/// 4.intsec = number of secs the window needs to be displayed 
//// Note : Though the window is displayed excatly for number of secs specified , the processing time for the page which shows results is
////        dynamic hence in body on unload of the calling page the opened popup window is made to close 
//Description     : displays popup window for specified number of secs
//Author          : S.M.P.Gokulnath
//Created Date    :  Sep -09- 2004   

function TimedPopup(url,w,h,intsec)
{ 
TimeOut = intsec
//var winl = (screen.width)/4;
//var wint = (screen.height)/4;
var winl = 200;
var wint = 200;
var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+winl+',';
      settings +='left='+wint+',';
      settings +='scrollbars=No,resizable=No,toolbar=no, location=no, directories=no';

 windowprops = settings; // May be adjusted according to your needs
 if (ChildWin)
     return false;
 ChildWin = window.open(url, "ChildWin", windowprops);
  if(parseInt(navigator.appVersion) >= 4){ChildWin.window.focus();}
 ResetTimer();
 if (TimeOut && RefreshRate)
    setTimeout("CheckClose();",RefreshRate * 1);
}
function ResetTimer()
{
 TimeRemain = TimeOut;
}
function CheckClose()
{
 TimeRemain -= (RefreshRate);
 if (TimeRemain > 0)
    {
    if (ChildWin && ChildWin.closed)
       {
 
	ChildWin = null;
       }
    else
    if (ChildWin)
       { 
	setTimeout("CheckClose();",RefreshRate * 1);
       }
    }
 else
 if (ChildWin)
    {
 
     if (ChildWin.closed)
	 ChildWin = null;
     else
	{
         ChildWin.close();
	 ChildWin = null;
        }
    }
}

// function  IsNumeric takes 1 parameter
/// 1. sText = value that is to be checked whether it contains all numeriuc characters
//Description     : returns true if valid numeric values are entered and false if wrong values are entered
//Author          : S.M.P.Gokulnath
//Created Date    :  Sep -09- 2004   
 function IsNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
   }
   
   // function  IsAlphabets takes 1 parameter
/// 1. sText = value that is to be checked whether it contains only Characters
//Description     : returns true if valid Characters are entered and false if wrong values are entered
//Author          : S.M.P.Gokulnath
//Created Date    :  Jan-11-2005 
 function IsAlphabets(sText)
{
   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
   var IsAlpha=true;
   var Char;
   sText=sText.replace(/^\s*(.*)/, "$1");
   sText=sText.replace(/(.*?)\s*$/, "$1");
	if (sText.length==0 )
	{
	IsAlpha = false;
	}
	else
	{
  	 for (i = 0; i < sText.length && IsAlpha == true; i++) 
      { 
    	  Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
    	     {
        	 IsAlpha = false;
	         }
      }
	}
   return IsAlpha;   
  }
  
 // Function Name  : checkNumbersonly
// Description    : This function checks whether numbers alone is entered into service and contact phone numbers
//Author          : S.M.P.Gokulnath
//Created Date    :  Jan-11-2004
function checkNumbersonly(thob)

{
	if (IsNumeric(thob.value)==false)
	{
	alert('Please enter numeric value');
	thob.value="";
	thob.focus();
	}
}
 // allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
function isValidName(str)
{	
   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ ";
   var Isok=true;
   var Char;
	str=str.replace(/^\s*(.*)/, "$1");
	str=str.replace(/(.*?)\s*$/, "$1");
	if (str.length==0 )
	{
	Isok = false;
	}
	else
	{
	   for (i = 0; i < str.length && Isok == true; i++) 
    	  { 
	      Char = str.charAt(i); 
    	  if (ValidChars.indexOf(Char) == -1) 
        	 {
	         Isok = false;
    	     }
	      }
	}
   return Isok;   
   }

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
function isValidEmailChar(str)
{	
   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@_.- ";
   var Isok=true;
   var Char;
	str=str.replace(/^\s*(.*)/, "$1");
	str=str.replace(/(.*?)\s*$/, "$1");
	if (str.length==0 )
	{
	Isok = false;
	}
	else
	{
	   for (i = 0; i < str.length && Isok == true; i++) 
    	  { 
	      Char = str.charAt(i); 
    	  if (ValidChars.indexOf(Char) == -1) 
        	 {
	         Isok = false;
    	     }
	      }
	}
   return Isok;   
   }

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
function isValidServiceAddress(str)
{	
   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_., ";
   var Isok=true;
   var Char;
	str=str.replace(/^\s*(.*)/, "$1");
	str=str.replace(/(.*?)\s*$/, "$1");
	if (str.length==0 )
	{
	Isok = false;
	}
	else
	{
	   for (i = 0; i < str.length && Isok == true; i++) 
    	  { 
	      Char = str.charAt(i); 
    	  if (ValidChars.indexOf(Char) == -1) 
        	 {
	         Isok = false;
    	     }
	      }
	}
   return Isok;   
   }
// function  isValidEmail takes 1 parameter
/// 1. str = value that is to be checked for email address
//Description     : returns true if valid email values is enteres and false if wrong values are entered
function isValidEmail(emailAddress)
{
   /* Check for empty address or invalid characters */
   if (hasInvalidChar(emailAddress))//emailAddress == "" ||
   {
      return false;
   }
   /* Check for invalid characters */
   if (isValidEmailChar(emailAddress)==false)//emailAddress == "" ||
   {
      return false;
   }

   /* check for presence of the @ character */
   var atPos = emailAddress.indexOf("@", 1)
   if (atPos == -1)
   {
      return false;
   }

   /* Check that there are no more @ characters */
   if (emailAddress.indexOf("@", atPos + 1) > -1)
   {
      return false;
   }

   /* Check for the presence of a dot somewhere after @ */
   var dotPos = emailAddress.indexOf(".", atPos + 1);
   if (dotPos == -1)
   {
      return false;
   }

   /* Check for presence of two or more characters after last dot */
   var lastDotPos = emailAddress.lastIndexOf(".");
   if (lastDotPos + 3 >  emailAddress.length)
   {
      return false;
   }

   return true;
}

// function  isValidEmailAddress takes 1 parameter
/// 1. str = value that is to be checked for email address
//Description     : returns true if valid email values is enteres and false if wrong values are entered
function isValidEmailAddress(emailAddress)
{
   /* Check for empty address or invalid characters */
   if (hasInvalidChar(emailAddress))//emailAddress == "" ||
   {
      return false;
   }
   /* Check for invalid characters */
   if (isValidEmailChar(emailAddress)==false)//emailAddress == "" ||
   {
      return false;
   }

   /* check for presence of the @ character */
   var atPos = emailAddress.indexOf("@", 1)
   if (atPos == -1)
   {
      return false;
   }

   /* Check that there are no more @ characters */
   if (emailAddress.indexOf("@", atPos + 1) > -1)
   {
      return false;
   }

   /* Check for the presence of a dot somewhere after @ */
   var dotPos = emailAddress.indexOf(".", atPos + 1);
   if (dotPos == -1)
   {
      return false;
   }

   /* Check for presence of two or more characters after last dot */
   var lastDotPos = emailAddress.lastIndexOf(".");
   if (lastDotPos + 3 >  emailAddress.length)
   {
      return false;
   }

   return true;
}

/*
   Return true if the given email address has an invalid character
   in it, else return false.
*/
function hasInvalidChar(emailAddress)
{
   var invalidChars = "/;:,"; // this list is not complete
   for (var k = 0; k < invalidChars.length; k++)
   {
      var ch = invalidChars.charAt(k);
      if (emailAddress.indexOf(ch) > -1)
      {
         return true;
      }
   }
   return false;
}

	



// function  checkHomePageInputValues  
///  Note : This Function is called from two pages
///           1. homepage.asp
///           2. input.asp
///      since the control name and validation are same
/// this is done to avoid code repetation and for ease of maintanence      
// Description    : This function checks whether the form values entered are proper 
//					and gives appropriate error message if any value is found invalid or left blank
//                  The function returns true if all values are found correct and false if any value is found invalid or left blank
//Author          : S.M.P.Gokulnath
//Created Date    :  Sep -09- 2004   
function checkHomePageInputValues1() {
	if (!chk_Radiobutton(document.IndexForm1.rbintention)) {
		alert("Please Select  'Qualify Service for'  ");
		return false;
	}
	var strSec,Typelabel;
	if (document.IndexForm1.rbintention[0].checked==true) {
		strSec = "home"
		Typelabel = "Home"
	}
	else {
		strSec = "business"
		Typelabel = "Business"
	}
	/////// ///   Name   ////////////////////////
	if((strSec.toLowerCase()=="home")) {
		if(document.IndexForm1.name.value!='') {
			if(isValidName(document.IndexForm1.name.value)==false) {
				alert('Please do not enter special characters with your name');
				document.IndexForm1.name.focus();
				return false;
			}
		}			
		fname = "";
		lname = "";
	}
	else {
		if(document.IndexForm1.name.value=='') {
			alert('Please enter your Full Name ');
			document.IndexForm1.name.focus();
			return false;
		}
		if(isValidName(document.IndexForm1.name.value)==false) {
			alert('Please do not enter special characters with your name');
			document.IndexForm1.name.focus();
			return false;
		}
		fullname = document.IndexForm1.name.value
		namearr = fullname.split(" ")
		if(namearr.length>1) {
			fname = namearr[0]
			lname = namearr[1]
		}
	} 

	/// ///   Service Phone    ////////////////////////
	if (document.IndexForm1.DSLPhoneAreaCode.value=='')  
	{
		alert('Please enter your Service telephone number');
		document.IndexForm1.DSLPhoneAreaCode.focus();
		return false;
	}
	var num1,newTerm1 
	if (parseInt(document.IndexForm1.DSLPhoneAreaCode.value) != document.IndexForm1.DSLPhoneAreaCode.value)  {
		num1 = document.IndexForm1.DSLPhoneAreaCode.value;
        while (num1.charAt(0) == "0")  {
			newTerm1 = num1.substring(1, num1.length);
			num1 = newTerm1;
		}
	    if (parseInt(num1) != num1) {
			alert('Please enter a Service telephone number, numbers only');
			document.IndexForm1.DSLPhoneAreaCode.focus();
			return false;
		}
	}
	if (document.IndexForm1.DSLPhoneAreaCode.value.length < 3 || document.IndexForm1.DSLPhoneAreaCode.value.length > 3 )   {
		alert('Please enter your Service telephone Area Code  3 digits number Eg(123) ');
		document.IndexForm1.DSLPhoneAreaCode.focus();
		return false;
	} 
	if  (document.IndexForm1.DSLPhoneFirst.value=='') {
		alert('Please enter your Service telephone number');
		document.IndexForm1.DSLPhoneFirst.focus();
		return false;
	}
	var num2,newTerm2
	if (parseInt(document.IndexForm1.DSLPhoneFirst.value) != document.IndexForm1.DSLPhoneFirst.value) {
        num2 = document.IndexForm1.DSLPhoneFirst.value;
        while (num2.charAt(0) == "0") {
	    	newTerm2 = num2.substring(1, num2.length);
			num2 = newTerm2;
	    }
	    if (parseInt(num2) != num2) {
			alert('Please enter a Service telephone number, numbers only');
			document.IndexForm1.DSLPhoneFirst.focus();
			return false;
	    }
	}
	if (document.IndexForm1.DSLPhoneFirst.value.length < 3 || document.IndexForm1.DSLPhoneFirst.value.length > 3 ) {
		alert('Please enter your Service telephone first 3 digits number Eg(123) ');
		document.IndexForm1.DSLPhoneFirst.focus();
		return false;
	}
	if (document.IndexForm1.DSLPhoneLast.value=='') {
		alert('Please enter your Service telephone number');
		document.IndexForm1.DSLPhoneLast.focus();
		return false;
	}
 	var num3,newTerm3
	if (parseInt(document.IndexForm1.DSLPhoneLast.value) != document.IndexForm1.DSLPhoneLast.value)  {
		num3 = document.IndexForm1.DSLPhoneLast.value;
        while (num3.charAt(0) == "0")  {
	    	newTerm3 = num3.substring(1, num3.length);
 	    	num3 = newTerm3;
	    }
	    if (parseInt(num3) != num3)  {
			alert('Please enter a Service telephone number, numbers only');
			document.IndexForm1.DSLPhoneLast.focus();
			return false;
	    }									
	}			
	if (document.IndexForm1.DSLPhoneLast.value.length < 4 || document.IndexForm1.DSLPhoneLast.value.length > 4 ) {
		alert('Please enter your Service telephone last 4 digits number Eg(1234) ');
		document.IndexForm1.DSLPhoneLast.focus();
		return false;
	}
 
	/// ///   Mail Check Code ////////////////////////
	if (document.IndexForm1.shopper_email.value=='' ||  (! isValidEmailAddress(document.IndexForm1.shopper_email.value) ) ) {
		alert('Please enter a valid e-mail address so you will receive confirmation of your registration.  E-Mail addresses must be in a valid e-mail format (e.g. yourname@domain.com)');
		document.IndexForm1.shopper_email.focus();
		return false;
	}
	if((strSec.toLowerCase()=="home"))
	{
	}
	else
	{
		/// ///   Contact Phone  ////////////////////////
		if(document.IndexForm1.DSLPhoneAreaCode2.value=='') 
		{
			alert('Please enter your Contact telephone number');
			document.IndexForm1.DSLPhoneAreaCode2.focus();
			return false;
		}
		
		var num1,newTerm1
		if (parseInt(document.IndexForm1.DSLPhoneAreaCode2.value) != document.IndexForm1.DSLPhoneAreaCode2.value) 
		{
            num1 = document.IndexForm1.DSLPhoneAreaCode2.value;
            while (num1.charAt(0) == "0") 
		    {
		    	newTerm1 = num1.substring(1, num1.length);
			    num1 = newTerm1;
	    	}
		    if (parseInt(num1) != num1)
		    {
				alert('Please enter a Contact telephone number, numbers only');
				document.IndexForm1.DSLPhoneAreaCode2.focus();
				return false;
	       }
		}

		if(document.IndexForm1.DSLPhoneAreaCode2.value.length < 3 || document.IndexForm1.DSLPhoneAreaCode2.value.length > 3 ) 
		{
		alert('Please enter your Contact telephone Area Code  3 digits number Eg(123) ');
			document.IndexForm1.DSLPhoneAreaCode2.focus();
			return false;
		}


		if (document.IndexForm1.DSLPhoneFirst2.value=='') 
		{
			alert('Please enter your Contact telephone number');
			document.IndexForm1.DSLPhoneFirst2.focus();
			return false;
		}

		var num2,newTerm2
		if (parseInt(document.IndexForm1.DSLPhoneFirst2.value) != document.IndexForm1.DSLPhoneFirst2.value)
		{
            num2 = document.IndexForm1.DSLPhoneFirst2.value;
            while (num2.charAt(0) == "0") 
		    {
		    	newTerm2 = num2.substring(1, num2.length);
				num2 = newTerm2;
		    }
		    if (parseInt(num2) != num2) 
		    {
			alert('Please enter a Contact  telephone number, numbers only');
			document.IndexForm1.DSLPhoneFirst2.focus();
			return false;
		    }
		}

		if (document.IndexForm1.DSLPhoneFirst2.value.length < 3 || document.IndexForm1.DSLPhoneFirst2.value.length > 3 ) 
		{
		alert('Please enter your Contact telephone First 3 digits number Eg(123) ');
			document.IndexForm1.DSLPhoneFirst2.focus();
			return false;
		}
		
		if (document.IndexForm1.DSLPhoneLast2.value=='')  
		{
			alert('Please enter your Contact telephone number');
			document.IndexForm1.DSLPhoneLast2.focus();
			return false;
		}

		var num3,newTerm3
		if (parseInt(document.IndexForm1.DSLPhoneLast2.value) != document.IndexForm1.DSLPhoneLast2.value) 
		{
	        num3 = document.IndexForm1.DSLPhoneLast2.value;
	        while (num3.charAt(0) == "0") 
		    {
		    	newTerm3 = num3.substring(1, num3.length);
	 	    	num3 = newTerm3;
		    }
		    if (parseInt(num3) != num3) 
		    {
			alert('Please enter a Contact telephone number, numbers only');
			document.IndexForm1.DSLPhoneLast2.focus();
			return false;
		    }									
		}
		if (document.IndexForm1.DSLPhoneLast2.value.length < 4 || document.IndexForm1.DSLPhoneLast2.value.length > 4 )  
		{
		alert('Please enter your Contact telephone Last 4 digits number Eg(1234) ');
			document.IndexForm1.DSLPhoneLast2.focus();
			return false;
		}
	}   
	redirecturl = "http://www.broadbandnational.com/winpopup.asp?Redirfile=targus.asp"
	redirecturl = redirecturl + "&yourname="+document.IndexForm1.name.value
	redirecturl = redirecturl + "&fname="+fname
	redirecturl = redirecturl + "&lname= "+lname
	redirecturl = redirecturl + "&ServicePhone="+document.IndexForm1.DSLPhoneAreaCode.value+document.IndexForm1.DSLPhoneFirst.value+document.IndexForm1.DSLPhoneLast.value
	redirecturl = redirecturl + "&Email="+document.IndexForm1.shopper_email.value
	redirecturl = redirecturl + "&ContactPhone="+document.IndexForm1.DSLPhoneAreaCode2.value+document.IndexForm1.DSLPhoneFirst2.value+document.IndexForm1.DSLPhoneLast2.value
	redirecturl = redirecturl + "&Type="+Typelabel
	redirecturl = redirecturl + "&referring_partner=BBN&id=BBN&targusflag=yes&autophoneflag=no&FilterOnly=&call_back=Y&logo=1000&salesteam=N"
	location.href = redirecturl;
	return false;
	//document.IndexForm1.action="http://www.broadbandnational.com/winpopup.asp?Redirfile=targus.asp&";
}
// This is part of code for auto tab in phone number fields
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
	try {
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	catch(er){
		
	}
}
function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
	found = true;
	else
	index++;
	return found;
}
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
	}
	return true;
}

//	Checking Radio button
	function chk_Radiobutton(rdobtn){
		var flag=false;
		for (i=0;i<rdobtn.length;i++) {
			if (rdobtn[i].checked==true) 
				flag=true;
		}
		return flag;
	}