﻿// JScript File

 
//      if(history.length)
//      {
//      
//        document.location.href="http://www.google.com";
//      }
function disp_prompt()
{
//var r = window.showModalDialog('default.aspx','','resizable=no;dialogWidth:510px;dialogHeight:350px');
//return false;
var pwd=prompt("Please enter your password","");
if (pwd!=null && pwd!="")
  {
//  document.write("Hello " + pwd + "! How are you today?");
  document.getElementById("ctl00_mainContent_CheckPasswordTextBox").value=pwd;
  return false;
  }
}

function OnFloatDivCloseButton()
{
    document.getElementById('floatlayer').style.display="none";

}

function OnupdateEmailPwdChangeButtonClick()
{
//            alert("hi");
            var ContactEmail    = document.getElementById("ctl00_mainContent_ChangeEmailTextBox");
            var ConfirmEmail = document.getElementById("ctl00_mainContent_ConfirmEmailTextBox");
            var Password        = document.getElementById("ctl00_mainContent_ChangePasswordTextBox");
            var ConfirmPassword = document.getElementById("ctl00_mainContent_ChangeConPasswordTextBox");

            if(Password != null)
            {            
                if(Password.value != "")
                {
//                alert("hi");
                    if(Password.value.length < 6)
                    {
                        alert("password cannot be less than 6 characters");
                        Password.focus();
                        return false;
                    }
                    if(ConfirmPassword.value == "")
                    {
                        alert("Please confirm password");
                        ConfirmPassword.focus();
                        return false;
                    }  
                    if(Password.value != ConfirmPassword.value)
                    {
                        alert("Please confirm the password");
                        ConfirmPassword.focus();
                        return false;
                    }
                     
                }   
            } 
            
            if(ContactEmail != null)
            {
                if(ContactEmail.value != "")
                {
                    if(ConfirmEmail.value == "")
                    {
                        alert("Please confirm email");
                        ConfirmEmail.focus();
                        return false;
                    }  
                    if(ContactEmail.value != ConfirmEmail.value)
                    {
                        alert("Please confirm the email");
                        ConfirmEmail.focus();
                        return false;
                    }
                }
            }  

}

function OnChangeEmailPasswordButtonClick()
{
    document.getElementById("ctl00_mainContent_trCheckPassword").style.display="";
    return false;
}
function LicensedCheckListValidate(cb) 
{
    if(cb == 0)
    {
        document.getElementById("ctl00_mainContent_LicensedCheckList_1").checked = false;
    }
    if(cb == 1)
    {
        document.getElementById("ctl00_mainContent_LicensedCheckList_0").checked = false;
    }
}

function InsuredCheckListValidate(cb) 
{
    if(cb == 0)
    {
        document.getElementById("ctl00_mainContent_InsuredCheckList_1").checked = false;
    }
    if(cb == 1)
    {
        document.getElementById("ctl00_mainContent_InsuredCheckList_0").checked = false;
    }
}


    function OnChangeLicensedCheckList()
    {
//    alert('hi');
        if(document.getElementById("ctl00_mainContent_LicensedCheckList_0").checked==true)
        {
            document.getElementById("ctl00_mainContent_LicensedCheckList_1").checked=false;
        }
        else if(document.getElementById("ctl00_mainContent_LicensedCheckList_1").checked==true)
        {
            document.getElementById("ctl00_mainContent_LicensedCheckList_0").checked=false;
        }
    
    }
    
  function CloseTabs(controlname)
  {
//      alert(controlname);
    document.getElementById("ctl00_mainContent_" + controlname).style.display="none";
    
    scrolldocument()
  }
  
  function CheckAllPaymentMethods()
  {
    for(var i=0; i<=6; i++)
    {
        if(document.getElementById("ctl00_mainContent_CheckAllPaymentMethods").checked == true)
        {
            document.getElementById("ctl00_mainContent_AcceptedMethodsOfPayment_"+i).checked = true;
        }
        else if(document.getElementById("ctl00_mainContent_CheckAllPaymentMethods").checked == false)
        {
            document.getElementById("ctl00_mainContent_AcceptedMethodsOfPayment_"+i).checked = false;
        }
    }
  }
  
  function EnableCouponExpDate(controlName)
  {
//      alert(controlName.checked);
  if(controlName.checked == true)
  {
    document.getElementById('ctl00_mainContent_CouponExpDateTextBox').disabled="";
  }
  else if(controlName.checked == false)
  {
    document.getElementById('ctl00_mainContent_CouponExpDateTextBox').disabled="true";
  }
  
          
  }
  function ClosePriceMenu()
  {
    
    document.getElementById("ctl00_mainContent_PriceMenuTab").style.display="none";
    document.getElementById("ctl00_mainContent_FeatureList").options[1].selected=true;
  
  }
      function ResetScrollPosition(str)
      {
        window.scrollTo(str);
        return false;
      }

function cursorPosition()
{
    var textarea = document.getElementById("ctl00_mainContent_CityZipList");
    textarea.focus();
	
    // get selection in firefox, opera, ...

    if (typeof(textarea.selectionStart) == 'number')
    {	
    alert(textarea.selectionStart);
    }
    else if(document.selection)
    {
	    var selection_range = document.selection.createRange().duplicate();

	    if (selection_range.parentElement() == textarea) {    // Check that the selection is actually in our textarea
	    // Create three ranges, one containing all the text before the selection,
	    // one containing all the text in the selection (this already exists), and one containing all
	    // the text after the selection.
	    var before_range = document.body.createTextRange();
	    before_range.moveToElementText(textarea);                    // Selects all the text
	    before_range.setEndPoint("EndToStart", selection_range);     // Moves the end where we need it

	    var after_range = document.body.createTextRange();
	    after_range.moveToElementText(textarea);                     // Selects all the text
	    after_range.setEndPoint("StartToEnd", selection_range);      // Moves the start where we need it

	    var before_finished = false, selection_finished = false, after_finished = false;
	    var before_text, untrimmed_before_text, selection_text, untrimmed_selection_text, after_text, untrimmed_after_text;

	    // Load the text values we need to compare
	    before_text = untrimmed_before_text = before_range.text;
	    selection_text = untrimmed_selection_text = selection_range.text;
	    after_text = untrimmed_after_text = after_range.text;

	    // Check each range for trimmed newlines by shrinking the range by 1 character and seeing
	    // if the text property has changed.  If it has not changed then we know that IE has trimmed
	    // a \r\n from the end.
	    do {
	      if (!before_finished) {
	          if (before_range.compareEndPoints("StartToEnd", before_range) == 0) {
	              before_finished = true;
	          } else {
	              before_range.moveEnd("character", -1)
	              if (before_range.text == before_text) {
	                  untrimmed_before_text += "\r\n";
	              } else {
	                  before_finished = true;
	              }
	          }
	      }
	      if (!selection_finished) {
	          if (selection_range.compareEndPoints("StartToEnd", selection_range) == 0) {
	              selection_finished = true;
	          } else {
	              selection_range.moveEnd("character", -1)
	              if (selection_range.text == selection_text) {
	                  untrimmed_selection_text += "\r\n";
	              } else {
	                  selection_finished = true;
	              }
	          }
	      }
	      if (!after_finished) {
	          if (after_range.compareEndPoints("StartToEnd", after_range) == 0) {
	              after_finished = true;
	          } else {
	              after_range.moveEnd("character", -1)
	              if (after_range.text == after_text) {
	                  untrimmed_after_text += "\r\n";
	              } else {
	                  after_finished = true;
	              }
	          }
	      }

	    } 
	    while ((!before_finished || !selection_finished || !after_finished));

	    // Untrimmed success test to make sure our results match what is actually in the textarea
	    // This can be removed once you're confident it's working correctly
	    var untrimmed_text = untrimmed_before_text + untrimmed_selection_text + untrimmed_after_text;
	    var untrimmed_successful = false;
	    if (textarea.value == untrimmed_text) 
	    {
	      untrimmed_successful = true;
	    }
	    // ** END Untrimmed success test

	    var startPoint = untrimmed_before_text.length;
//		    alert(startPoint);
//		alert(textarea.value);
        textarea.value=textarea.value.trim() +" ";

	    var sel1 = textarea.value.substring(startPoint);
	    
	    var sel2 = textarea.value.substring(0,startPoint);
//    	    alert(sel1 + " :::: " + sel2);
//    alert(textarea.value.substring(sel2.lastIndexOf(" ")-2,startPoint+sel1.indexOf(" ")));
        if(sel1.indexOf("-") != -1)
        {
	        setSelRange(textarea,sel2.lastIndexOf("-")-1, startPoint+sel1.indexOf("-")-1)
	        document.getElementById("ctl00_mainContent_RemoveItemFromCityZip").value=textarea.value.substring(sel2.lastIndexOf("-")-1,startPoint+sel1.indexOf("-")-1);

	    }
	    else
	    {
	        setSelRange(textarea,sel2.lastIndexOf("-")-1, startPoint+sel1.length)
	        document.getElementById("ctl00_mainContent_RemoveItemFromCityZip").value=textarea.value.substring(sel2.lastIndexOf("-")-1,startPoint+sel1.length);

	    }
	    }
    }
}

function setSelRange(inputEl, selStart, selEnd) 
{  
    if (inputEl.setselectionRange) 
    {   
        inputEl.focus();   
        inputEl.setselectionRange(selStart, selEnd);  
    } 
    else if (inputEl.createTextRange) 
    {   
        var range = inputEl.createTextRange();   
        range.collapse(true);   
        range.moveEnd('character', selEnd);   
        range.moveStart('character', selStart);   
        range.select();  
    } 
}

function RemoveSelectedText()
{
//        alert(document.getElementById("ctl00_mainContent_RemoveItemFromCityZip").value);
    document.getElementById("ctl00_mainContent_CityZipList").value=document.getElementById("ctl00_mainContent_CityZipList").value.replace(document.getElementById("ctl00_mainContent_RemoveItemFromCityZip").value,"");
}


    
//     function TreeNodeCheck() 
//      {  
//       var o = window.event.srcElement;  
//       if (o.tagName == 'INPUT' && o.type == 'checkbox')  
//       { 
//       var hiddenValue = o.nextSibling;  
//        // do something here with hiddenValue.value  
//       }  
//      }
    function createjsDOMenu(){} 
    
    
    
    
    
      function outcopy()
      {
          if(document.getElementById("ctl00_mainContent_tcitystate").value.length > document.getElementById("ctl00_mainContent_City1").value.length)
          {
            document.getElementById("ctl00_mainContent_tcitystate").value=document.getElementById("ctl00_mainContent_City1").value;
          }
      
      }
  function copy()
  {
//      if(document.getElementById("ctl00_mainContent_City1").value == "")
//      {
//        document.getElementById("ctl00_mainContent_tcitystate").value ="";
//      }
//      if(document.getElementById("ctl00_mainContent_tcitystate").value.length == 0)
//      {
//        document.getElementById("ctl00_mainContent_tcitystate").value=document.getElementById("ctl00_mainContent_City1").value;
//      }
//      else
//      {
//        document.getElementById("ctl00_mainContent_tcitystate").value=document.getElementById("ctl00_mainContent_tcitystate").value + "," + document.getElementById("ctl00_mainContent_City1").value;
//      }
//alert('hi');
//alert(document.getElementById("ctl00_mainContent_CityZipList").value.indexOf(":"));
      if(document.getElementById("ctl00_mainContent_CityZipList").value == "")
      {
        document.getElementById("ctl00_mainContent_CityZipList").value = document.getElementById("ctl00_mainContent_City1").value;
        addcheckbox();
      }
      else
      {
        if(document.getElementById('ctl00_mainContent_CityZipList').value.search(document.getElementById("ctl00_mainContent_City1").value) == -1)
            {
                document.getElementById("ctl00_mainContent_CityZipList").value = document.getElementById("ctl00_mainContent_CityZipList").value + " - " + document.getElementById("ctl00_mainContent_City1").value;
                addcheckbox();          
            }
            else
            {
                alert("Can not add same City.");
                document.getElementById("ctl00_mainContent_City1").value = "";
                document.getElementById("ctl00_mainContent_City1").focus();
            }
            
      }
      document.getElementById("ctl00_mainContent_City1").value ="";
      
//      document.getElementById("ctl00_mainContent_City1").value="";
//alert(document.getElementById("ctl00_mainContent_CityZipList").value.indexOf(":"));
  }
  //Utpal 28.08.08

  function scrolldocument()
  {
    window.scrollTo(0,0);
        window.scrollTo(0,150);
    
  }
  
  
  
   function  OnDblClickTree(st)
   { 
   
            document.getElementById("ctl00_mainContent_editclick").value="on";
            document.getElementById("ctl00_mainContent_FeatureList").selectedIndex=-1;
            document.getElementById("ctl00_mainContent_AddList").style.display="none";
            document.getElementById("ctl00_mainContent_spaddlist").style.display="";
            document.getElementById("ctl00_mainContent_AddBusinessInfoButton").value="Update";
            document.getElementById("ctl00_mainContent_AddHoursOfOperationInfoButton").value="Update";
            document.getElementById("ctl00_mainContent_AddPaymentInfoButton").value="Update";
            document.getElementById("ctl00_mainContent_AddAdvertiserDisplayInfoButton").value="Update";
            document.getElementById("ctl00_mainContent_AddServiceAreaButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddSubCategoryButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddPromotionButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddResumeButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddContactFeaturesButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddJackPotListingButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddSponsoredAdButton").innerText="Update";
            document.getElementById("ctl00_mainContent_AddVerticalBannerAdvertisementButton").innerText="Update";
            
            var txt=st;
            if(document.getElementById("ctl00_mainContent_testtree").value != "")
            {
            txt = document.getElementById("ctl00_mainContent_testtree").value;
            }
            document.getElementById("ctl00_mainContent_BusinessInfoTab").style.display="none";
            document.getElementById("ctl00_mainContent_HoursOperationTab").style.display="none";
            document.getElementById("ctl00_mainContent_AccMethodePaymentTab").style.display="none";
            document.getElementById("ctl00_mainContent_ServiceAreaTab").style.display="none";
            document.getElementById("ctl00_mainContent_BusinessCategoryTab").style.display="none";
            document.getElementById("ctl00_mainContent_AdvertiserDisplayTab").style.display="none";
            document.getElementById("ctl00_mainContent_CustomerContactFeaturesTab").style.display="none";
            document.getElementById("ctl00_mainContent_CouponsTab").style.display="none";
            
            document.getElementById("ctl00_mainContent_JackPotListingTab").style.display="none";
            document.getElementById("ctl00_mainContent_SponsoredAdvertisingTab").style.display="none";
            document.getElementById("ctl00_mainContent_SideBannerAdvertisementsTab").style.display="none";
            document.getElementById("ctl00_mainContent_PriceMenuTab").style.display="none";
        
//        var elname = txt.substring(0,txt.indexOf("$")).replace(/^\s+/, '').replace(/\s+$/, '');
   var elname = txt.replace(/^\s+/, '').replace(/\s+$/, '');
                if(elname=="Business Information")
                {
                    document.getElementById("ctl00_mainContent_BusinessInfoTab").style.display="";
                    document.getElementById("ctl00_mainContent_CompanyName").focus();
                }
                else if(elname=="Jackpot Listing")
                {
                    document.getElementById("ctl00_mainContent_JackPotListingTab").style.display="";
                }
                else if(elname=="Hours of Operation")
                {
                    document.getElementById("ctl00_mainContent_HoursOperationTab").style.display="";
                }
                else if(elname=="Accepted Methods of Payment")
                {
                    document.getElementById("ctl00_mainContent_AccMethodePaymentTab").style.display="";
                }
                else if(elname=="Advertiser Display Information")
                {
                    document.getElementById("ctl00_mainContent_AdvertiserDisplayTab").style.display="";
                }
                else if(elname=="Service Area")
                {
                    document.getElementById("ctl00_mainContent_ServiceAreaTab").style.display="";
                    document.getElementById("ctl00_mainContent_City1").focus();
                }
                else if(elname=="Business Category")
                {
                    document.getElementById("ctl00_mainContent_BusinessCategoryTab").style.display="";
                    document.getElementById("ctl00_mainContent_SubCategory1").focus();
                }
                else if(elname=="Customer Contact Features")
                {
                    document.getElementById("ctl00_mainContent_CustomerContactFeaturesTab").style.display="";
                    document.getElementById("ctl00_mainContent_PreferredEmailTextbox").focus();
                }
                else if(elname=="Coupons")
                {
                    document.getElementById("ctl00_mainContent_CouponsTab").style.display="";
                     document.getElementById("ctl00_mainContent_Promotions").focus();
                }
                else if(elname=="Sponsored Advertising")
                {
                    document.getElementById("ctl00_mainContent_SponsoredAdvertisingTab").style.display="";
                    document.getElementById("ctl00_mainContent_SponsorCompanyName").focus();
                }
                else if(elname=="Price Menu")
                {
                    document.getElementById("ctl00_mainContent_PriceMenuTab").style.display="";
                }  
                
                 scrollfeaturedocument();
addcheckbox();
   return false;
   }

function OnClickTree(str,evt) 
{ 
    document.getElementById("ctl00_mainContent_editclick").value="on";
    document.getElementById("ctl00_mainContent_FeatureList").selectedIndex=-1;
    document.getElementById("ctl00_mainContent_AddList").style.display="none";
    document.getElementById("ctl00_mainContent_spaddlist").style.display="";
    
//        for (var i = 0; i < document.getElementById("ctl00_mainContent_FeatureList").options.length; i++ )
//        {
//            if (document.getElementById("ctl00_mainContent_FeatureList").options[i].selected) 
//            {
//            document.getElementById("ctl00_mainContent_FeatureList").selectedIndex=-1;

//            }
//        }
//        alert($get("ctl00_mainContent_editclick").name);
//        return false;
 var allelement = document.getElementsByTagName("span");
 for(var i = 0;i<= allelement.length - 1; i++)
 {
// if(allelement(i).id != "")
// {
// alert(allelement(i).name);
// alert($get(allelement(i).id).name);
 
// return false;
    if(allelement(i).name == "spanitem")
    {
//    alert(allelement(i).id)
    allelement(i).style.backgroundColor="white";
    }
// }
}
 
    evt.style.backgroundColor="yellow";
    
    var newstr = str.substring(0,str.indexOf("$")).replace(/^\s+/, '').replace(/\s+$/, '')
    document.getElementById("ctl00_mainContent_testtree").value = str;
    document.getElementById("ctl00_mainContent_EditList").style.display="";
    document.getElementById("ctl00_mainContent_speditlist").style.display="none";
    var srcstr = "Website Listing, My Resume, Customer Contact Features, Promotions/Coupons, Sponsored Advertising";
    if(srcstr.indexOf(newstr) != -1)
    {
        document.getElementById("ctl00_mainContent_RemoveList").style.display="";
        document.getElementById("ctl00_mainContent_spremovelist").style.display="none";
    }
    else
    {
        document.getElementById("ctl00_mainContent_RemoveList").style.display="none";
        document.getElementById("ctl00_mainContent_spremovelist").style.display="";
    }
   
        
} 
 function col(frm,evt)
{
     var allelement = document.getElementsByTagName("span");
 for(var i = 0;i<= allelement.length - 1; i++)
 {
    if(allelement(i).name == "spanitem")
    {
    allelement(i).style.backgroundColor="white";
    }
 }
    evt.style.backgroundColor="yellow";
    frm.style.backgroundColor="#C9C299";
    document.getElementById("ctl00_mainContent_EditList").style.display="none";
    document.getElementById("ctl00_mainContent_speditlist").style.display="";
    document.getElementById("ctl00_mainContent_RemoveList").style.display="none";
    document.getElementById("ctl00_mainContent_spremovelist").style.display="";
    return false; 
}

  function lstClicked()
  {
    document.getElementById("ctl00_mainContent_editclick").value=document.getElementById("ctl00_mainContent_FeatureList").selectedIndex;
    document.getElementById("ctl00_mainContent_AddList").style.display="";
    document.getElementById("ctl00_mainContent_spaddlist").style.display="none";
    CheckSelectedItem();
  }

 function CheckSelectedItem()
 {
    var select = document.getElementById('ctl00_mainContent_FeatureList'); 
    var seltreeNode = document.getElementById("ctl00_mainContent_TVListingToolbox"); 

    len = document.getElementById("ctl00_mainContent_FeatureList").length; 
    var itemtext;
    for(var j=0;j<len;j++)
    {
        if(document.getElementById("ctl00_mainContent_FeatureList").options[j].selected) 
        {
             select[j].focus(); 
             
             itemtext=select[j].value;
             if(itemtext == "Service Area" || itemtext == "Business Category" )
             {
                itemtext = "hello";
             }
            if(seltreeNode.innerHTML.indexOf(itemtext.replace("*","")) != -1)
            {
                    document.getElementById("ctl00_mainContent_AddList").style.display="none";
                    document.getElementById("ctl00_mainContent_spaddlist").style.display="";
                    return false;
            }
            else
            {
                return true;
            }
            
        }
    }
    
    if(select.selectvalue == "Service Area")
    {
//        alert("hi");
    }
       
    
 }

  function lstDblClicked()
  {
//  alert('start');
           document.getElementById("ctl00_mainContent_editclick").value=document.getElementById("ctl00_mainContent_FeatureList").selectedIndex;
           if(CheckSelectedItem())
           {
           document.getElementById("ctl00_mainContent_BusinessInfoTab").style.display="none";
            document.getElementById("ctl00_mainContent_HoursOperationTab").style.display="none";
            document.getElementById("ctl00_mainContent_AccMethodePaymentTab").style.display="none";
            document.getElementById("ctl00_mainContent_AdvertiserDisplayTab").style.display="none";
            document.getElementById("ctl00_mainContent_JackPotListingTab").style.display="none";
            document.getElementById("ctl00_mainContent_ServiceAreaTab").style.display="none";
//            alert('before BusinessCategoryTab');
            document.getElementById("ctl00_mainContent_BusinessCategoryTab").style.display="none";
//            alert('after BusinessCategoryTab');
            document.getElementById("ctl00_mainContent_CustomerContactFeaturesTab").style.display="none";
            document.getElementById("ctl00_mainContent_CouponsTab").style.display="none";
            document.getElementById("ctl00_mainContent_SponsoredAdvertisingTab").style.display="none";
            document.getElementById("ctl00_mainContent_SideBannerAdvertisementsTab").style.display="none";
            document.getElementById("ctl00_mainContent_PriceMenuTab").style.display="none";
//            alert('out of for');
        for (var i = 0; i < document.getElementById("ctl00_mainContent_FeatureList").options.length; i++ )
        {
            if (document.getElementById("ctl00_mainContent_FeatureList").options[i].selected) 
            {
                if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Business Information*")
                {
//                    alert(document.getElementById("ctl00_mainContent_BusinessInfoTab"));
                    document.getElementById("ctl00_mainContent_BusinessInfoTab").style.display="";
                    document.getElementById("ctl00_mainContent_CompanyName").focus();
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Hours of Operation")
                {
                    document.getElementById("ctl00_mainContent_HoursOperationTab").style.display="";
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Accepted Methods of Payment*")
                {
                    document.getElementById("ctl00_mainContent_AccMethodePaymentTab").style.display="";
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Advertiser Display Information")
                {
                    document.getElementById("ctl00_mainContent_AdvertiserDisplayTab").style.display="";
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Jackpot Listing")
                {
                    document.getElementById("ctl00_mainContent_JackPotListingTab").style.display="";
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Service Area")
                {
                    document.getElementById("ctl00_mainContent_ServiceAreaTab").style.display="";
                    document.getElementById("ctl00_mainContent_City1").focus();
                    addcheckbox();
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Business Category")
                {
//                
                    document.getElementById("ctl00_mainContent_BusinessCategoryTab").style.display="";
                    document.getElementById("ctl00_mainContent_Category1").focus();
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Customer Contact Features")
                {
                    document.getElementById("ctl00_mainContent_CustomerContactFeaturesTab").style.display="";
                    document.getElementById("ctl00_mainContent_PreferredEmailTextbox").focus();
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Coupons")
                {
                    document.getElementById("ctl00_mainContent_CouponsTab").style.display="";
                    document.getElementById("ctl00_mainContent_Promotions").focus();
                    
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Sponsored Advertising")
                {
                    document.getElementById("ctl00_mainContent_SponsoredAdvertisingTab").style.display="";
                    document.getElementById("ctl00_mainContent_SponsorCompanyName").value="";
                    document.getElementById("ctl00_mainContent_SponsorCompanyName").focus();
                }
                else if(document.getElementById("ctl00_mainContent_FeatureList").options[i].value=="Price Menu")
                {
                    document.getElementById("ctl00_mainContent_PriceMenuTab").style.display="";
                }
              
                
            }
        }
        scrollfeaturedocument();
    }
  }
  function scrollthisdoc()
  {
      if(document.getElementById('ctl00_mainContent_tvlist').value.length > 0)
      {
      window.scrollTo(0,0);
                window.scrollTo(0, 430);
                return false;
      }
  }
  function scrollfeaturedocument()
  {
//        alert("before login");
window.scrollTo(0,0);
        window.scrollTo(0, 430);
        return false;
  }
  //Utpal
  
    function OnSubmit()
    {
        var AddWebsiteButton = document.getElementById("ctl00_mainContent_AddWebsiteButton");
        var AddSubCategoryButton = document.getElementById("ctl00_mainContent_AddSubCategoryButton");
        var AddServiceAreaButton = document.getElementById("ctl00_mainContent_AddServiceAreaButton");
        var CompanyName = document.getElementById("ctl00_mainContent_CompanyName");
      
      if(CompanyName.value != "")  
      {
        if(AddWebsiteButton.disabled == true && AddServiceAreaButton.disabled == true && AddSubCategoryButton.disabled == true)
        {
            alert("please add personal and busines informations");
            return false;
        }
        else if(AddWebsiteButton.disabled == true && AddSubCategoryButton.disabled == true)
        {
            alert("please add atleast one city or zip information");
            return false;
        }
        else if(AddWebsiteButton.disabled == true)
        {
            alert("please add atleast one sub-category");
            return false;
        } 
     }
     if(CompanyName.value == "" && AddServiceAreaButton.disabled == true)   
     {
        alert("Please enter business information.");
        return false;
     }   
    }
   
    function ValidateCategory()
    {
       if(document.getElementById("ctl00_mainContent_ctl99_Category1").value == "0" || document.getElementById("ctl00_mainContent_ctl99_Category1").value == "")
       {
           alert("Please select category");
           document.getElementById("ctl00_mainContent_ctl99_Category1").focus();
           return false;
       }
       else if (document.getElementById("ctl00_mainContent_ctl99_SubCategory1").value == "0" || document.getElementById("ctl00_mainContent_ctl99_SubCategory1").value == "")
       {
           alert("Please select sub category");
           document.getElementById("ctl00_mainContent_ctl99_SubCategory1").focus();
           return false;
       }
       else
       {
            return OnClickCategoryLink();
       }
    }
    function ValidateZips()
    {
        var Zip1 = document.getElementById("ctl00_mainContent_Zip1");
        var Zip2 = document.getElementById("ctl00_mainContent_Zip2");
        var Zip3 = document.getElementById("ctl00_mainContent_Zip3");
        var Zip = document.getElementById("ctl00_mainContent_Zip");
        var ZipCount = 0;
        
       if(document.getElementById("ctl00_mainContent_Zip1").value == "" && document.getElementById("ctl00_mainContent_Zip2").value == "" && document.getElementById("ctl00_mainContent_Zip3").value == "")
       {
           alert("Please enter zip");
           Zip1.focus();
           return false;
       }
       else
       { 
            
           if(Zip1.value != "" && Zip2.value != "")
           {
               if(Zip1.value == Zip2.value){
                    alert("Cannot add same zipcode");
                    Zip2.focus();
                    return false;}
            }
            if(Zip1.value != "" && Zip3.value != "")
            {
               if(Zip1.value == Zip3.value){
                    alert("Cannot add same zipcode");
                    Zip3.focus();
                    return false;}
            }
            if(Zip2.value != "" && Zip3.value != "")
            {
               if(Zip2.value == Zip3.value){
                    alert("Cannot add same zipcode");
                    Zip3.focus();
                    return false;}
            }    
            var n = document.getElementById("ctl00_mainContent_gvSelectedZips");        
            if(document.getElementById("ctl00_mainContent_gvSelectedZips") != null)
            {
                if(n.rows.length > 0)
                {
                    for(i=0;i<n.rows.length;i++)
                    {
                       if(n.rows[i].cells[1].innerHTML == Zip1.value)
                       {
                           alert("Cannot add same zips");
                           Zip1.focus();
                           return false;
                       }
                       if(n.rows[i].cells[1].innerHTML == Zip2.value)
                       {
                           alert("Cannot add same zips");
                           Zip2.focus();
                           return false;
                       }
                       if(n.rows[i].cells[1].innerHTML == Zip3.value)
                       {
                           alert("Cannot add same zips");
                           Zip3.focus();
                           return false;
                       }
                    }
                }            
            }   

            if(Zip1.value !="")
            {
                if(Zip1.value.length <5 || Zip1.value.length >5)
                 {
                   alert("Zip cannot be more or less than 5");
                   Zip1.focus();
                   return false;
                 }
            }
            if(Zip2.value !="")
            {
             if(Zip2.value.length <5 || Zip2.value.length >5)
             {
               alert("Zip cannot be more or less than 5");
               Zip2.focus();
               return false;
             }
            }
            if(Zip3.value !="")
            {
             if(Zip3.value.length <5 || Zip3.value.length >5)
             {
               alert("Zip cannot be more or less than 5");
               Zip3.focus();
               return false;
             }
            }
       }
    }
    
    function ValidateCity()
    {
    var City = document.getElementById("ctl00_mainContent_City1");
    var City1 = City.value.split(' ');
       if(document.getElementById("ctl00_mainContent_City1").value == "")
       {
           alert("Please enter city");
           return false;
       }
       else
       {     
        var n = document.getElementById("ctl00_mainContent_gvSelectedCities");        
        if(document.getElementById("ctl00_mainContent_gvSelectedCities") != null)
        {
            if(n.rows.length > 0)
            {
                for(i=0;i<n.rows.length;i++)
                {
                   if(n.rows[i].cells[1].innerHTML + " " +n.rows[i].cells[2].innerHTML == City1[0]+" "+City1[City1.length-1])
                   {
                       alert("Cannot add same cities");
                       City.focus();
                       return false;
                   }
                }
            }
        }
      }
    }
    
    function ValidateCoupon()
    {      
       // var PromotionLogo = document.getElementById("ctl00_mainContent_ctl105_Logo");
       // var file = PromotionLogo.value; 
        if(document.getElementById("ctl00_mainContent_Promotions").value == "")
        {
           alert("Please enter Promotions");
           return false;
        } 
    }
    
    function CheckIsFile()
    {
          
          var Photo = document.getElementById("ctl00_mainContent_Photo");
          if(Photo.value=="")
          {
          alert("Please select an image");
          return false;
          }
    }
    function PopUp(ref)
    {	
	    var strFeatures="toolbar=no,status=no,menubar=no,location=no"
	    strFeatures=strFeatures+",scrollbars=yes,resizable=yes,height=320,width=500"
    	
	    newWin = window.open(ref,"TellObj",strFeatures);
           newWin.opener = top;
    }

//    function CheckKeyCode(controlName,strValue) //comma seperate
//    {		
//        controlName.value = (strValue);

//      
//	    if (( event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode < 46  ||  event.keyCode  > 46) && (event.keyCode < 45  ||  event.keyCode  > 45 || event.keyCode  == 45))
//	    {
//	        if (event.keyCode == 44)
//	        {
//	            return true;
//	        }
//	        else
//	        {
//		        event.keyCode=0;
//		        return false;
//		    }
//	    }
//	    
//    }
    function IgnoreEntry()
    {
         event.keyCode=0;
	     return false;
    
    }
    
    function CheckInputKeyCode(controlName,strValue,e) 
    {	
//    alert('hi');
    	var key; //= (window.event) ? event.keyCode : e.which;
        if (window.event)
          key = event.keyCode;
        else
          key = e.which;
        // Was key that was pressed a numeric character (0-9) or backspace (8)?
//        if(key==9)
//        {
//        alert(key);
//        }
    var keynew = e.keyCode;
//alert(keynew);
        if ( key > 47 && key < 58 || key == 8)
        {
            controlName.value = (strValue);
            return true;
        }
        else // otherwise, discard character
        {
                if (window.event) //IE
                {
                    window.event.returnValue = null; 
                }
                else //Firefox
                { 
                    if(keynew != 9)
                    e.preventDefault();
                }       
        }  
	    
    }

    function CheckKeyCode(controlName,strValue) 
    {		
        controlName.value = (strValue);

      
	    if (( event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode < 46  ||  event.keyCode  > 46) && (event.keyCode < 45  ||  event.keyCode  > 45 || event.keyCode  == 45))
	    {
	        event.keyCode=0;
	        return false;
	    }
	    else
        {
	        return true;
	    }
	    
    }
    
    
    function CheckContLength(controlName,strValue)
    {
    
        if(controlName.value.length > strValue)
        {
            event.keyCode=0;
	        return false;
        }
    }
    
    
    function CheckLengthAndAdd(controlName,strValue)
    {		
    
        controlName.value = (strValue);
        if(strValue.length == 5)
        {
            if(document.getElementById('ctl00_mainContent_CityZipList').value.search(strValue) == -1)
            {
                if(document.getElementById('ctl00_mainContent_CityZipList').value.length != 0)
                { 
                    document.getElementById('ctl00_mainContent_CityZipList').value=document.getElementById('ctl00_mainContent_CityZipList').value + " - " + strValue;
                    controlName.value="";
                }
                else
                {
                    document.getElementById('ctl00_mainContent_CityZipList').value= strValue;
                    controlName.value="";
                }
                document.getElementById('ctl00_mainContent_CityZipCheckBoxList').value = document.getElementById('ctl00_mainContent_CityZipList').value;
                addcheckbox();
            }
            else
            {
                alert("Can not add same ZIP code.");
                controlName.value="";
            }
        }
	  
    }
    function OnAddPromotionClick()
    {
//        scrolldocument();
        //Check expiration date format.. by utpal
        var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
        var errorMessage = 'Please enter valid date.';
        if(document.getElementById("ctl00_mainContent_CouponExpDateCheckBox").checked == true)
        {
        if ((document.getElementById("ctl00_mainContent_CouponExpDateTextBox").value.match(RegExPattern)) && (document.getElementById("ctl00_mainContent_CouponExpDateTextBox").value!='')) 
        {
        scrolldocument();
        document.getElementById('ctl00_mainContent_CouponsTab').style.display="none";
            return true;
        } 
        else
        {
        alert(errorMessage);
        return false;
        }
        }
        scrolldocument();
        document.getElementById('ctl00_mainContent_CouponsTab').style.display="none";
        
    }




    function OnChangeCategoryDropdown()
    {      
        var CategoryHidden =  document.getElementById("ctl00_mainContent_CategoryHidden");  
        var n = document.getElementById("ctl00_mainContent_gvSelectedCategories");
        if(document.getElementById("ctl00_mainContent_gvSelectedCategories") != null)
        {
            if(n.rows.length > 0)
            {
                if (confirm("Cannot add two different categories,\n for adding another categories, it will cancel the previously added subcategories.\n Are you sure to Cancel?")==true)
		            {
		                CategoryHidden.value ="0";
		                return true;
		             }
		        else
		        {
		            CategoryHidden.value ="1";
		            return false;
		        }
		
            
              //  alert("Cannot add two different categories,\n you can change and add all subcategories under the category you choose");
               
            }
        }
        else
        CategoryHidden.value = "";
    }

    function OnClickCategoryLink()
    {
        var n = document.getElementById("ctl00_mainContent_gvSelectedCategories");
        var subCat = document.getElementById("ctl00_mainContent_SubCategory1");
        var selectedIndex = subCat.selectedIndex
        if(document.getElementById("ctl00_mainContent_gvSelectedCategories") != null)
        {
            if(n.rows.length > 0)
            {
                for(i=0;i<n.rows.length;i++)
                {
                   if(n.rows[i].cells[1].innerHTML == subCat.options[selectedIndex].innerText)
                   {
                       alert("Cannot select same subcategories");
                       return false;
                   }
                }
            }
        }
    }
    

    
        
        function ShowModal()
        {    
            window.open ("ViewResume.aspx?","ViewSampleResume","width=750,height=600,status=1,toolbar=0,location=0,scrollbars=1"); 
            return false;
        }	
        
        function ShowSampleCoupons()
        {
        //sample coupons
            window.open ("ViewSampleCoupon.aspx","ViewSampleCoupon","width=410,height=230,status=0,toolbar=0,location=0,left=380,top=200,scrollbars=0"); 
            return false;
        }
        
         function PromotionPopUp(PromotionID)
        {
//        alert(PromotionID);
            window.open("PromotionCoupon.aspx?PromotionID="+PromotionID,'Promotion', 'width=420px,height=330px,left=300px,top=200px,status=1,toolbar=1,menubar=1'); 
        }
        
        function ShowSampleSponsoredAdd()
        {
        //sample sponsored advertising 
        window.open ("ViewSampleSponsoredAdd.aspx","ViewSampleSponsoredAdvertising","width=215,height=585,status=0,toolbar=0,location=0,left=400,top=100,scrollbars=0");
        return false;
        }
        function ShowMySponsoredAd()
        {
//        alert(spname + "," + sptext + "," + spwebsite);
            window.open("ViewMySponsoredAdd.aspx","MySponsoredAd","width=235,height=180,status=0,toolbar=0,location=0,left=400,top=100,scrollbars=0"); 
            return false;
        }
        function ShowMyCoupon(cpname,cptext,cpcode,cpexpdate)
        {
//        alert(cpname+", "+cptext+", "+cpcode+", "+cpexpdate);
            window.open("ViewMyCoupon.aspx?cpname="+cpname+"&cptext="+cptext+"&cpexpdate="+cpexpdate+"&cpcode="+cpcode,"MyCoupon","width=410,height=280,status=0,toolbar=0,location=0,left=380,top=200,scrollbars=0"); 
            return false;
        }

        function ValidateCertificate()
        {
            var ResumeYearReceived = document.getElementById("ctl00_mainContent_ResumeYearReceivedTextbox");
            var Certificate = document.getElementById("ctl00_mainContent_CertificateTextBox");
            if(ResumeYearReceived.value == "")
            {
                alert("Please enter resume year");
                ResumeYearReceived.focus();
                return false;
            }
            if(Certificate.value == "")
            {
                alert("Please enter type of certificate/degree/license");
                Certificate.focus();
                return false;
            }
           
        }
        
        function ValidateProffesional()
        {
            var ResumeProfessionalAssociation = document.getElementById("ctl00_mainContent_ResumeProfessionalAssociationTextBox");
            if(ResumeProfessionalAssociation.value == "")
            {
                alert("Please enter professional association/award");
                ResumeProfessionalAssociation.focus();
                return false;
            }
        }
        
        function ValidateReference()
        {
            var RefName     = document.getElementById("ctl00_mainContent_RefNameTextBox");
            var RefEmail    = document.getElementById("ctl00_mainContent_RefEmailTextBox");
            var RefCity     = document.getElementById("ctl00_mainContent_RefCityTextBox");
           
            if(RefName.value == "")
            {
                alert("Please enter reference name");
                RefName.focus();
                return false;
            }
            if(RefEmail.value == "")
            {
                alert("Please enter reference email");
                RefEmail.focus();
                return false;
            }
            if(RefCity.value == "")
            {
                alert("Please enter reference city");
                RefCity.focus();
                return false;
            }
        }
        
        function ValidateWebLink()
        {
            var ResumeAdditionalWeb = document.getElementById("ctl00_mainContent_ResumeAdditionalWebTextBox");
            if(ResumeAdditionalWeb.value == "")
            {
                alert("Please enter weblinks or articles");
                ResumeAdditionalWeb.focus();
                return false;
            }
        }
        function AddHoursOfOperationInfoClick()
        {
            scrolldocument();
            document.getElementById('ctl00_mainContent_HoursOperationTab').style.display="none";
            
        }
        function AddPaymentInfoClick()
        {
            scrolldocument();
            document.getElementById('ctl00_mainContent_AccMethodePaymentTab').style.display="none";
            
        }
        
        function OnAddSponsoredAd()
        {
            scrolldocument();
            document.getElementById('ctl00_mainContent_SponsoredAdvertisingTab').style.display="none";
            
        }
        
        function OnNextImageButtonClick()
        {
            var ContactFName    = document.getElementById("ctl00_mainContent_ContactFName");
            var ContactLName    = document.getElementById("ctl00_mainContent_ContactLName");
            var ContactNumber   = document.getElementById("ctl00_mainContent_ContactNumber");
            var ContactEmail    = document.getElementById("ctl00_mainContent_ContactEmail");
            var Password        = document.getElementById("ctl00_mainContent_Password");
            var ConfirmPassword = document.getElementById("ctl00_mainContent_ConfirmPassword");
            var Question        = document.getElementById("ctl00_mainContent_Question");
            var Hint            = document.getElementById("ctl00_mainContent_Hint");
//            alert(ContactEmail.value);
            if(ContactFName != null)
            {
                if(ContactFName.value == "")
                {
                    alert("Please enter first name");
                    ContactFName.focus();
                    return false;
                }
            }
            if(ContactLName != null)
            {
                if(ContactLName.value == "")
                {
                    alert("Please enter last name");
                    ContactLName.focus();
                    return false;
                }
            }
            if(ContactNumber != null)
            {
                if(ContactNumber.value == "")
                {
                    alert("Please enter contact number");
                    ContactNumber.focus();
                    return false;
                }
            }
            if(ContactEmail != null)
            {
                if(ContactEmail.value == "")
                {
                    alert("Please enter login email");
                    ContactEmail.focus();
                    return false;
                }
            }
            if(ContactEmail != null)
            {
                if(ContactEmail.value != "")
                {
                    if(emailcheck(ContactEmail.value)==false)
                    {
                       ContactEmail.focus();
                       return false;
                    }
//                    
                }
            }
            if(Password != null)
            {            
                if(Password.value == "")
                {
                    alert("Please enter password");
                    Password.focus();
                    return false;
                }
            }
            if(Password != null)
            { 
                if(Password.length < 6)
                {
                    alert("password cannot be less than 6 characters");
                    Password.focus();
                    return false;
                }
            }
            if(ConfirmPassword != null)
            {
                if(ConfirmPassword.value == "")
                {
                    alert("Please confirm password");
                    ConfirmPassword.focus();
                    return false;
                }  
            } 
            if(ConfirmPassword != null)
            {     
                if(Password.value != ConfirmPassword.value)
                {
                    alert("Please confirm the password");
                    ConfirmPassword.focus();
                    return false;
                }
            }  
            if(Question != null)
            {            
                if(Question.value == "0")
                {
                    alert("Please select security question");
                    Question.focus();
                    return false;
                }
            }
            if(Hint != null)
            { 
                if(Hint.value == "")
                {
                    alert("Please enter security answer");
                    Hint.focus();
                    return false;
                }
            }
            
            
            
        }
        
        function OnAddBusinessInfoClick()
        {
//        alert('hi');
//        return false;
            
            var CompanyName     = document.getElementById("ctl00_mainContent_CompanyName");
            var Address1        = document.getElementById("ctl00_mainContent_Address1");        
            var MCity           = document.getElementById("ctl00_mainContent_City");
            var State           = document.getElementById("ctl00_mainContent_State");
            var MZip            = document.getElementById("ctl00_mainContent_Zip");
            var Phone           = document.getElementById("ctl00_mainContent_Phone");
            
            if(CompanyName.value == "")
            {
                alert("Please enter company name");
                CompanyName.focus();
                return false;
            }
            if(Address1.value == "")
            {
                alert("Please enter address");
                Address1.focus();
                return false;
            }
            if(MCity.value == "")
            {
                alert("Please enter city");
                MCity.focus();
                return false;
            }
            if(State.value == "0")
            {
                alert("Please enter state");
                State.focus();
                return false;
            }
            if(MZip.value == "")
            {
                alert("Please enter zip");
                MZip.focus();
                return false;
            }
            if(Phone.value == "")
            {
                alert("Please enter phone");
                Phone.focus();
                return false;
            }
            
            var Zip = document.getElementById("ctl00_mainContent_Zip");
            
            if(Zip.value != "")
            {
                if(Zip.value.length < 5 || Zip.value.length >5)
                {alert("Zip cannot less or more than 5");Zip.focus();return false;}
            }     
            var chkAcceptedMethodsOfPayment = document.all("ctl00_mainContent_AcceptedMethodsOfPayment");
            var chkText = "";

            for(i = 0; i <= 6; i++)
            {
                objItem = document.getElementById('ctl00_mainContent_AcceptedMethodsOfPayment_' + i);
                if(objItem.checked)
                {
                chkText = "yes";
                }
            }
            if(chkText == "")
            {
//            alert("please select one payment type");
//            return false;
            } 
//            alert('hi');
            scrolldocument();
////            alert("Hi");
            document.getElementById('ctl00_mainContent_BusinessInfoTab').style.display="none";
            
        }
        
        function OnAddServiceAreaClick()
        {
            
            // Zip Code Validation on page submit
            var Zip1 = document.getElementById("ctl00_mainContent_Zip1");
            var Zip2 = document.getElementById("ctl00_mainContent_Zip2");
            var Zip3 = document.getElementById("ctl00_mainContent_Zip3");           
            
            if(Zip1.value != "" && Zip2.value != "")
               {    
                   if(Zip1.value == Zip2.value){
                        alert("Cannot add same zipcode");
                        Zip2.focus()
                        return false;
                        }
                }
               if(Zip1.value != "" && Zip3.value != "")
               {
                   if(Zip1.value == Zip3.value){
                        alert("Cannot add same zipcode");
                        Zip3.focus();
                        return false;
                        }
               }
               if(Zip2.value != "" && Zip3.value != "")
               {
                   if(Zip2.value == Zip3.value){
                        alert("Cannot add same zipcode");
                        Zip3.focus();
                        return false;} 
               }   
                    
                var n = document.getElementById("ctl00_mainContent_gvSelectedZips"); 

                if(document.getElementById("ctl00_mainContent_gvSelectedZips") != null)
                {
                   if(n.rows.length > 0)
                    { 
                    var flag = "0";
                        for(i=0;i<n.rows.length;i++)
                        {                       
                          if(n.rows[i].cells[1].innerHTML == Zip1.value)
                           {
                               alert("Cannot add same zips");
                               Zip1.focus();
                               return false;
                           }
                           if(n.rows[i].cells[1].innerHTML == Zip2.value)
                           {
                               alert("Cannot add same zips");
                               Zip2.focus();
                               return false;
                           }
                           if(n.rows[i].cells[1].innerHTML == Zip3.value)
                           {
                               alert("Cannot add same zips");
                               Zip3.focus();
                               return false;
                           }
                        }
                   }
                }
                //Check zip length by Utpal
                
                var ln = Zip1.value;
                var zipar = ln.split(',');
                if(Zip1.value !="")
                {
                var i;
                    for (i=0;i<=zipar.length-1;i++)
                    {
                         if(zipar[i].length <5 || zipar[i].length >5)
                         {
                           alert("Zip cannot be more or less than 5");
                           Zip1.focus();
                           return false;
                         }
                     }
                }
//                if(Zip1.value !="")
//                {
//                    if(Zip1.value.length <5 || Zip1.value.length >5)
//                     {
//                       alert("Zip cannot be more or less than 5");
//                       Zip1.focus();
//                       return false;
//                     }
//                }
                //Check zip length by Utpal
                if(Zip2.value !="")
                {
                     if(Zip2.value.length <5 || Zip2.value.length >5)
                     {
                       alert("Zip cannot be more or less than 5");
                       Zip2.focus();
                       return false;
                     }
                }
                if(Zip3.value !="")
                {
                     if(Zip3.value.length <5 || Zip3.value.length >5)
                     {
                       alert("Zip cannot be more or less than 5");
                       Zip3.focus();
                       return false;
                     }
                }
                                
               // City Validation on page submit
               
            var City = document.getElementById("ctl00_mainContent_City1");
            var CityZipList = document.getElementById("ctl00_mainContent_CityZipList");
            var City1 = City.value.split(' ');
            var n = document.getElementById("ctl00_mainContent_gvSelectedCities");        
            if(document.getElementById("ctl00_mainContent_gvSelectedCities") != null)
            {
                if(n.rows.length > 0)
                {
                    for(i=0;i<n.rows.length;i++)
                    {
                       if(n.rows[i].cells[1].innerHTML+" "+n.rows[i].cells[2].innerHTML == City1[0]+" "+City1[City1.length-1])
                       {
                           alert("Cannot add same cities");
                           City.focus();
                           return false;
                       }
                    }
                }           
            }  
           
            if(document.getElementById("ctl00_mainContent_gvSelectedCities") == null && document.getElementById("ctl00_mainContent_gvSelectedZips") == null)
            {      
                if(City.value == "" && Zip1.value == "" && Zip2.value == "" && Zip3.value == "" && CityZipList.value == "")
                {
                    alert("Please enter a City or at least one zip for the Service Area");
                    City.focus();
                    return false;
                }
            } 
            scrolldocument();
            document.getElementById('ctl00_mainContent_ServiceAreaTab').style.display="none";
            
        }
        
        function OnAddSubCategoryClick()
        {
            
            // Category Validation  on page submit
                       
            var n               = document.getElementById("ctl00_mainContent_gvSelectedCategories");
            var subCat          = document.getElementById("ctl00_mainContent_SubCategory1");
            var selectedIndex   = subCat.selectedIndex
            if(document.getElementById("ctl00_mainContent_gvSelectedCategories") != null)
            {
                if(n.rows.length > 0)
                {
                    for(i=0;i<n.rows.length;i++)
                    {
                       if(n.rows[i].cells[1].innerHTML == subCat.options[selectedIndex].innerText)
                       {
                           alert("Cannot select same subcategories");
                           subCat.focus();
                           return false;
                       }
                    }
                }
            }
            var subCat = document.getElementById("ctl00_mainContent_SubCategory1");
            var selectedIndex = subCat.selectedIndex
            if(document.getElementById("ctl00_mainContent_gvSelectedCategories") == null)
            {
                if(subCat.value == "" || subCat.value == "0")
                {
                alert("Please select at least one Business category.");
                subCat.focus();
                return false;
                }
            }   
            scrolldocument();
            document.getElementById('ctl00_mainContent_BusinesscategoryTab').style.display="none";      
        }
        //email validation by utpal 22.08.08
        function echeck(str) 
        {
        
          var at="@"
          var dot="."
          var lat=str.indexOf(at)
          var lstr=str.length
          var ldot=str.indexOf(dot)
          if (str.indexOf(at)==-1)
          {
             alert("Invalid E-mail ID or Mobile Telephone Number")
             return false 
          }

          if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
          {
             alert("Invalid E-mail ID or Mobile Telephone Number")
             return false
          }

          if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
          {
              alert("Invalid E-mail ID or Mobile Telephone Number")
              return false
          }

           if (str.indexOf(at,(lat+1))!=-1)
           {
              alert("Invalid E-mail ID or Mobile Telephone Number")
              return false
           }

           if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
           {
              alert("Invalid E-mail ID or Mobile Telephone Number")
              return false
           }

           if (str.indexOf(dot,(lat+2))==-1)
           {
              alert("Invalid E-mail ID or Mobile Telephone Number")
              return false
           }
          
           if (str.indexOf(" ")!=-1)
           {
              alert("Invalid E-mail ID or Mobile Telephone Number")
              return false 
           }

            return true     
         }
      //integer validation by utpal 22.08.08
      function isInteger (s)
       {
          var i;

          if (isEmpty(s))
          if (isInteger.arguments.length == 1) return 0;
          else return (isInteger.arguments[1] == true);

          for (i = 0; i < s.length; i++)
          {
             var c = s.charAt(i);

             if (!isDigit(c)) return false;
          }

          return true;
       }

   function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }

   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }


       //integer validation by utpal 22.08.08
    //email validation by utpal 22.08.08

        function OnAddContactFeatures()
        {
            var preferredEmail = document.getElementById("ctl00_mainContent_PreferredEmailTextbox");
            if(preferredEmail.value == "")
            {
                alert("Please enter email address or mobile telephone number.");
                document.getElementById("ctl00_mainContent_PreferredEmailTextbox").focus();
                return false;
            }
            else
            {
                if(document.getElementById("ctl00_mainContent_CallMeCheckBox").checked == false && document.getElementById("ctl00_mainContent_MakeApptCheckBox").checked == false && document.getElementById("ctl00_mainContent_QuoteRequestCheckBox").checked == false)
                {
                    alert("Please select one or more of the customer contact features. If you do not want to add any of the features please close the box by clicking \"X\" in the upper-right corner");
                    return false;
                }
                    
                if(isInteger(preferredEmail.value))
                {
                    scrolldocument();
                    document.getElementById('ctl00_mainContent_CustomerContactFeaturesTab').style.display="none";
                    return true;
                }
                else
                {
                      if (echeck(preferredEmail.value)==false)
                      {
                          document.getElementById("ctl00_mainContent_PreferredEmailTextbox").value="";
                          document.getElementById("ctl00_mainContent_PreferredEmailTextbox").focus();
                          return false;
                      }
                      else
                      {
                      scrolldocument();
                      document.getElementById('ctl00_mainContent_CustomerContactFeaturesTab').style.display="none";
                          return true;
                      }
                  }
                  
            }
            if(document.getElementById("ctl00_mainContent_CallMeCheckBox").checked == false && document.getElementById("ctl00_mainContent_MakeApptCheckBox").checked == false && document.getElementById("ctl00_mainContent_QuoteRequestCheckBox").checked == false)
            {
                alert("Please select any of the features");
                return false;
            }
            else
            {
            scrolldocument();
                document.getElementById('ctl00_mainContent_CustomerContactFeaturesTab').style.display="none";
                 return true;
            }
            scrolldocument();
            document.getElementById('ctl00_mainContent_CustomerContactFeaturesTab').style.display="none";
            
        }       
        
        function OnAddAdvertiserDisplayInfo()
        {
            scrolldocument();
            document.getElementById('ctl00_mainContent_AdvertiserDisplayTab').style.display="none";
        }
   
        function OnAddJackPotListing()
        {
            scrolldocument();
            document.getElementById('ctl00_mainContent_JackPotListingTab').style.display="none";
        }
        function OnAddResumeClick()
        {
            
            var Description = document.getElementById("ctl00_mainContent_ResumeDescriptionTextBox")
            if(Description.value.length>750)
            {
            alert("Description exceeds 750 characters");
            return false;
            }
            scrolldocument();
            document.getElementById('ctl00_mainContent_BusinessResumeTab').style.display="none";
            
        }
        
        function OnAddWebsiteClick()
        {
            
            var SponsorAdText = document.getElementById("ctl00_mainContent_SponsorAdText");
            if(SponsorAdText.value.length>73)
            {
            alert("Sponsor add text exceeds 72 characters");
            return false;
            }
            var SponsorCompanyName = document.getElementById("ctl00_mainContent_SponsorCompanyName");
            if(SponsorCompanyName.value.length>24)
            {
            alert("Sponsor Company Name exceeds 24 characters");
            return false;
            } 
            scrolldocument();
            document.getElementById('ctl00_mainContent_WebSiteListingTab').style.display="none";  
            
        }        
        
    
 
        var styleToSelect;
        function onOk() {
          //  $get('Paragraph1').className = styleToSelect;
        }
    

    
    var Count = 0;
    function trunctextlength(control,str)
    {
        var Count = control.value.length;
        var len = str;
        
        if(Count > str)
        {
//        alert(Count);
            if (( event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode < 46  ||  event.keyCode  > 46) && (event.keyCode < 45  ||  event.keyCode  > 45 || event.keyCode  == 45) )
	        {
		        event.keyCode=0;
		        return false;
	        }
        }
        
       /* alert(Count);
        if(Count > 5 && newLine == true)
        {
            document.getElementById("ctl00_mainContent_SponsorAdText").value = document.getElementById("ctl00_mainContent_SponsorAdText").value + "\n";
            newLine = false;
            Count = 0;
        }  
        else
            newLine = true; */
    }
    
  

    
    function GetDocumentHeight() // Fuction to get the window height and width. 
    {
        var scnWid,scnHei;
	    if(self.innerHeight) // all except Explorer
	    {
		    scnWid = self.innerWidth;
		    scnHei = self.innerHeight;
	    }
	    else if(document.documentElement && document.documentElement.clientHeight)
		    // Explorer 6 Strict Mode
	    {
		    scnWid = document.documentElement.clientWidth;
		    scnHei = document.documentElement.clientHeight;
	    }
	    else if(document.body) // other Explorers
	    {
		    scnWid = document.body.clientWidth;
		    scnHei = document.body.clientHeight;
	    }

        alert('Width = ' + scnWid + ', Height = ' + scnHei);
    }
    
    function alertSize() // Fuction to get the window height and width.
    {
          var myWidth = 0, myHeight = 0;
          if(typeof(window.innerWidth) == 'number')
          {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
          } 
          else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
          {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
          } 
          else if(document.body && (document.body.clientWidth || document.body.clientHeight))
          {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
          }
          window.alert('Width = ' + myWidth);
          window.alert('Height = ' + myHeight);
    }
    
    
    function getScrollXY() //Function to get how much you have scrolled vertically or horizontally
    {
          var scrOfX = 0, scrOfY = 0;
          if(typeof(window.pageYOffset) == 'number') 
          {
            //Netscape compliant
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
          } 
          else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) 
          {
            //DOM compliant
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
          } 
          else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) 
          {
            //IE6 standards compliant mode
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
          }
          return [scrOfX, scrOfY];
    }

