﻿// JScript File

//Function to check user name available or not for advertiser
    function AdvertiserUserCallBack(UserID)
    {
     var strUserID=document.getElementById(UserID).value;
     if(strUserID!="")
     {
        var xmlRequest = DoCallback("advertiserreg.aspx?UserFlag=Y","UserID=" + strUserID);
    
        if(xmlRequest.readyState == 4)
        {
            if(xmlRequest.status == 200)
            {
                if (xmlRequest.responseText!="")
                {
                    document.getElementById('tdUserName').innerHTML=xmlRequest.responseText;
                    document.getElementById(UserID).value="";
                }
                else
                {
                    document.getElementById('tdUserName').innerHTML="";
                }
            }
            else
            {
                alert("Process was not completed due to some problem on server" );
            }
        }
      }
      else
      {
        document.getElementById('tdUserName').innerHTML="";
      }
    }
    
    var strServices="";
    //Function To gather selected services
    function AddToServiceList(addremove,service)
    {
        if(addremove.checked==true)
        {
            strServices=strServices + service + "~";
        }
        else if(addremove.checked==false)
        {
            strServices=strServices.replace(service + "~",'');
        }
    }
    
    function SaveAdvertiserCallBack(strUrl,arr)
    {
          if(Page_ClientValidate("reg")==true)
          {               
            var ctrlArr=new Array();
            var ctrlArr=arr;
            var txtUser=document.getElementById(ctrlArr[0]);
            var txtPassword=document.getElementById(ctrlArr[1]);
            var txtCPassword=document.getElementById(ctrlArr[2]);
            var txtHintQuestion=document.getElementById(ctrlArr[3]);
            var txtAnswer=document.getElementById(ctrlArr[4]);
            var txtAdvertiser=document.getElementById(ctrlArr[5]);
            var txtOtherIndustry=document.getElementById(ctrlArr[6]);
            var txtOtherProducts=document.getElementById(ctrlArr[7]);
            var txtAddress=document.getElementById(ctrlArr[8]);
            var chkCountry=document.getElementById(ctrlArr[9]);
            var ddlCountry=document.getElementById(ctrlArr[10]);
            var txtOCountry=document.getElementById(ctrlArr[11]);
            var chkState=document.getElementById(ctrlArr[12]);
            var ddlState=document.getElementById(ctrlArr[13]);
            var txtOState=document.getElementById(ctrlArr[14]);
            var chkCity=document.getElementById(ctrlArr[15]);
            var ddlCity=document.getElementById(ctrlArr[16]);
            var txtOCity=document.getElementById(ctrlArr[17]);
            var txtZip=document.getElementById(ctrlArr[18]);
            var txtTel1=document.getElementById(ctrlArr[19]);
            var txtTel2=document.getElementById(ctrlArr[20]);
            var txtFax1=document.getElementById(ctrlArr[21]);
            var txtFax2=document.getElementById(ctrlArr[22]);
            var txtEmail1=document.getElementById(ctrlArr[23]);
            var txtEmail2=document.getElementById(ctrlArr[24]);
            var txtWeb=document.getElementById(ctrlArr[25]);
            var txtContactName=document.getElementById(ctrlArr[26]);
            var txtDesignation=document.getElementById(ctrlArr[27]);
            var txtContactNo=document.getElementById(ctrlArr[28]);
            var txtContEmail=document.getElementById(ctrlArr[29]);
            var chkOfferEmail=document.getElementById(ctrlArr[30]);
            var txtProfile=document.getElementById(ctrlArr[31]);
           
            var Country="";                        
            if(chkCountry.checked==true)
            {
                Country=txtOCountry.value;
            }
            else
            {
                Country=ddlCountry.value;
            }

            var State="";                        
            if(chkState.checked==true)
            {
                State=txtOState.value;
            }
            else
            {
                State=ddlState.value;
            }

            var City="";                        
            if(chkCity.checked==true)
            {
                City=txtOCity.value;
            }
            else
            {
                City=ddlCity.value;
            }
             
            var OfferEmail="";                        
            if(chkOfferEmail.checked==true)
            {
                OfferEmail="Y";
            }
            else
            {
                OfferEmail="N";
            }
           
            var strData="User=" + txtUser.value + "&Password=" + txtPassword.value + "&HintQuestion=" + txtHintQuestion.value + "&Answer=" + txtAnswer.value + "&Advertiser=" + txtAdvertiser.value +
                        "&OtherIndustry=" + txtOtherIndustry.value + "&OtherProducts=" + txtOtherProducts.value + "&Address=" + txtAddress.value + "&Country=" + Country + "&State=" + State + "&City=" + City +
                        "&Zip=" + txtZip.value + "&Tel1=" + txtTel1.value + "&Tel2=" + txtTel2.value + "&Fax1=" + txtFax1.value + "&Fax2=" + txtFax2.value +
                        "&Email1=" + txtEmail1.value + "&Email2=" + txtEmail2.value + "&Web=" + txtWeb.value + "&ContactName=" + txtContactName.value +
                        "&Designation=" + txtDesignation.value + "&ContactNo=" + txtContactNo.value + "&ContEmail=" + txtContEmail.value + "&OfferEmail=" + OfferEmail +
                        "&Profile=" + txtProfile.value + "&Services=" + strServices;
            
            var xmlRequest = DoCallback(strUrl + "?SaveFlag=Y",strData);
            
            if(xmlRequest.readyState == 4)
            {
                if(xmlRequest.status == 200)
                {
                        if (xmlRequest.responseText!="")
	                    {
	                        window.location=xmlRequest.responseText;
	                    }
	                    else
	                    {
	                        alert("Data not loaded");
	                    }
    	        }
    	        else
                {
                    alert("Process was not completed due to some problem on server" );
                }
            }
          }
    }
    
    function SetServiceList(strServiceList)
    {
        strServices=strServiceList;
    }
