﻿// JScript File

function resolution()
{
var up = document.getElementById('div_flash');
var img = document.getElementById('flashcontent');
var browser = navigator.appName;
var ver = navigator.appVersion;
var id = ver.split(";");
var ie = id[1];
up.style.width="653";
up.style.position = "absolute";
up.style.top = "72px";
//up.style.left = "180px";

//alert(browser);
if(browser=="Netscape")
{
    if(screen.width<="1024")
    {
        up.style.left = "110px";
    }
    if(screen.width=="1280")
    {
        up.style.left = "250px";
    }
    if(screen.width>"1280")
    {
        up.style.left = "450px";
    }
}
else
{
    if(ie == "MSIE 7.0")
    {
        if(screen.width<="1024")
        {
            up.style.left = "110px";
        }
        if(screen.width=="1280")
        {
            up.style.left = "240px";
        }
        if(screen.width>"1280")
        {
            up.style.left = "450px";
        }
    }
    else
    {
        if(screen.width<="1024")
        {
            up.style.left = "110px";
        }
        if(screen.width=="1280")
        {
            up.style.left = "240px";
        }
        if(screen.width>"1280")
        {
            up.style.left = "450px";
        }
    }
}
//var so = new SWFObject("/swf/carinsurancewiperbig.swf", "4", "700", "450", "8", "#ffffff");
//so.addParam("allowScriptAccess", "sameDomain");
//so.addParam("quality", "high");
//so.addParam("allowFullScreen", "false");
//so.addParam("wmode", "transparent");
//so.write("flashcontent");
}

function eservice_go(link)
{
    window.location = link.value;
}



function livechatlink()
{
 var url_add="https://server.iad.liveperson.net/hc/44482436/?cmd=file&file=visitorWantsToChat&site=44482436&byhref=1&SESSIONVAR!&imageUrl=https://www.royalsundaram.in/chatonline/";
 //url_add="https://server.iad.liveperson.net/hc/44482436/?cmd=file&file=visitorWantsToChat&site=44482436&byhref=1&SESSIONVAR!opid=2&imageUrl=https://server.iad.liveperson.nethttp://www.royalsundaram.in/images/liveperson/";
 window.open(url_add,'welcome','width=400,height=475');
return false;
//window.open('https://server.iad.liveperson.net/hc/44482436/?cmd=file&file=visitorWantsToChat&site=44482436&imageUrl=https://server.iad.liveperson.nethttp://www.royalsundaram.in/images/liveperson/&referrer='+escape(document.location),'chat44482436','width=475,height=400,resizable=yes');
//return false;
}


function CheckProduct()
{
    if((document.getElementById("oncall").checked== false) && (document.getElementById("atdoor").checked== false))
    {
        alert('Please check how to contact you');
        document.getElementById("oncall").focus();
        return false; 
    }
if((document.getElementById("oncall").checked== true) || (document.getElementById("atdoor").checked== true))
{

    if(document.getElementById("txtname").value =="")
     {
             alert('Please enter your Name');
             document.getElementById("txtname").focus();
             return false;
     } 
 if (document.getElementById("txtname").value!="")
	{
	    if(!isAlphabet(document.getElementById("txtname"),'Please enter alphabets only'))
        {
            document.getElementById("txtname").value="";
            document.getElementById("txtname").focus();
            return false;
        }	   
	} 
 
 if (document.getElementById("txttel").value=="")
	{
	     alert("Please enter your Phone Number");
	     document.getElementById("txttel").focus();	      
	     return false;
	}  
	if (document.getElementById("txttel").value!="")
     {
         if(!IsNumeric(document.getElementById("txttel").value))
         {
             alert("Please enter numbers only ");
             document.getElementById("txttel").value = "";
             document.getElementById("txttel").focus();              
             return false;
         }
          else
            {
                if(!lengthRestrictionmax(document.getElementById("txttel"),6,16))
                {
                    return false;
                }
            }
    }
//     if(document.getElementById("txtEmail").value =="")
//     {
//         alert('Please enter your Email ID');
//         document.getElementById("txtEmail").focus();
//         return false;
//     } 
//      if (document.getElementById("txtEmail").value!="")
//		{
//		    if(!emailValidator(document.getElementById("txtEmail")))
//		    {
//		         alert("Please enter a valid Email ID");
//		         document.getElementById("txtEmail").focus();		          
//		         return false;
//		    }
//		}
		
    }
}

function CheckRenew()
{
 if(document.getElementById("txtpolicyno").value == "")
    {
        alert('Please enter your policy number');
        document.getElementById("txtpolicyno").focus();
        return false; 
    }
    if (document.getElementById("txtpolicyno").value!="")
	    {
	    if(!isAlphanumeric(document.getElementById("txtpolicyno"),'Please enter alphanumeric values only'))
        {
            document.getElementById("txtpolicyno").value="";
            document.getElementById("txtpolicyno").focus();
            return false;
        }
	 }		 
    if ((document.getElementById("txtexpday").value==""))
		{
		     alert("Please enter the expiry day");
		     document.getElementById("txtexpday").focus();		      
		     return false;
		}     
	if (document.getElementById("txtexpday").value!="")
    {
         if(!IsNumeric(document.getElementById("txtexpday").value))
         {
             alert("Please enter numbers only");
             document.getElementById("txtexpday").value = "";
             document.getElementById("txtexpday").focus();             
             return false;
         }
         else
         {             
           if(!lengthRestrictiondate(document.getElementById("txtexpday"),2,2))
           {
                    return false;
            }           
         }
    }	   
    if ((document.getElementById("txtexpmonth").value==""))
		{
		     alert("Please enter the expiry month");
		     document.getElementById("txtexpmonth").focus();		      
		     return false;
		}     
	if (document.getElementById("txtexpmonth").value!="")
    {
         if(!IsNumeric(document.getElementById("txtexpmonth").value))
         {
             alert("Please enter numbers only");
             document.getElementById("txtexpmonth").value = "";
             document.getElementById("txtexpmonth").focus();             
             return false;
         }
         else
         {             
           if(!lengthRestrictiondate(document.getElementById("txtexpmonth"),2,2))
           {
                    return false;
            }           
         }
    }	    
    if ((document.getElementById("txtexpyear").value==""))
		{
		     alert("Please enter the expiry year");
		     document.getElementById("txtexpyear").focus();		      
		     return false;
		}     
	if (document.getElementById("txtexpyear").value!="")
    {
         if(!IsNumeric(document.getElementById("txtexpyear").value))
         {
             alert("Please enter numbers only");
             document.getElementById("txtexpyear").value = "";
             document.getElementById("txtexpyear").focus();             
             return false;
         }
         else
         {             
           if(!lengthRestrictiondate(document.getElementById("txtexpyear"),4,4))
           {
                    return false;
            }           
         }
    }	     
}

function objectcreate()
{
    var browser=navigator.appname;
    var objectres;
    if (browser=="Microsoft Internet Explorer")
    {
        objectres=new ActiveXObject("MicrosoftXMLHttp");
    }
    else
    {
        objectres=new XMLHttpRequest();
    }
    return objectres;
}

var newHTTP=getreq(); 
function getreq() { // returns false if exists
	if(window.ActiveXObject) { // if IE
		try {
		return new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
		return new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
		return;
			}
		}
	} else if(window.XMLHttpRequest) { // if Mozilla, Safari, etc.
		return new XMLHttpRequest();
		}
}

//var http=objectcreate();
var typevalue;
var catvalue;
var typevalue1;
var genvalue;
var http_section=getreq();
function loadproduct()
{

  var varcheck=CheckProduct();
    if(varcheck == false)
    return false;
    var Name=document.getElementById("txtname").value;
    var TelNo=document.getElementById("txttel").value;      
    //var Email=document.getElementById("txtEmail").value;     
    if((Name!="") && (TelNo !=""))
    {
         if(document.getElementById("oncall").checked== true)
         {           
         http_section.open("get","/Ajax/Product_Insert.aspx?name="+Name+"&telNo="+TelNo+"&contact=Dial a Policy",true);
          //alert(TelNo);     
         }
         else if(document.getElementById("atdoor").checked== true)
         {
         http_section.open("get","/Ajax/Product_Insert.aspx?name="+Name+"&telNo="+TelNo+"&contact=Meet Our Advisor",true);
         }   
             http_section.onreadystatechange=returnsection;
             http_section.send(null);    
   }    
}
function returnsection()
{
  if(http_section.readyState==4)
  {
       //alert(http_section.responseText);
        var res_section=http_section.responseText.split("$");  
        document.getElementById("txtname").value = "";
        document.getElementById("txttel").value = "";
        //document.getElementById("txtEmail").value = "";
        document.getElementById("oncall").checked == false;
        document.getElementById("atdoor").checked == false;
         alert('Thanks for your interest.We will get in touch with you shortly.');
    }
}

function searchclick()
{
document.getElementById("srchvalue").value='';

//document.location='/pagesearch1.aspx?srchvalue='+document.getElementById('srchvalue').value;
}
function searchmouseout()
{
document.getElementById("srchvalue").value='        Search this Site';
}
function searchonkeypress(a)
{
var kc;
 if(document.all)
            {
                kc=event.keyCode; 
            }

            else if(document.getElementById)
            {
                kc=a;  
            }
            else if(document.layers)
            {
                 kc=a;                                                        

            }  
            
    if(kc==13)
    {       
    document.getElementById('srchvalue').value = document.getElementById('srchvalue').value;
    return false;
    }
}
function interest_product()
{ 
        var temp = true;
//        if (document.getElementById("ddproduct").value == 'Select')
//		{
//		     alert("Please select the interested in our products");
//		     document.getElementById("ddproduct").focus();
//		     temp = false;
//		     return false;
//		}   
//        if (document.getElementById("ddtitle").value == 'Select')
//		{
//		     alert("Please select the title");
//		     document.getElementById("ddtitle").focus();
//		     temp = false;
//		     return false;
//		}   
        if (document.getElementById("txtname").value=="")
		{
		     alert("Please enter your name");
		     document.getElementById("txtname").focus();
		     temp = false;
		     return false;
		}   
		if (document.getElementById("txtname").value!="")
	    {
	        if(!isAlphabet(document.getElementById("txtname"),'Please enter alphabets only'))
	        {
	            document.getElementById("txtname").value="";
	            document.getElementById("txtname").focus();
	            return false;
	        }
	    }	    
	    if (document.getElementById("txtemail").value=="")
		{
		     alert("Please enter your email id");
		     document.getElementById("txtemail").focus();
		     temp = false;
		     return false;
		}   	    
	     if (document.getElementById("txtemail").value!="")
		{
		    if(!emailValidator(document.getElementById("txtemail")))
		    {
		         alert("Please enter a valid Email id ");
		         document.getElementById("txtemail").focus();
		         temp = false;
		         return false;
		    }
		}	
		
			if ((document.getElementById("txtno").value=="") && (document.getElementById("txtMoblie").value==""))
		{
		     alert("Enter Either Phone/Mobile Number ");
		     document.getElementById("txtno").focus();
		     temp = false;
		     return false;
		}     
	if (document.getElementById("txtno").value!="")
    {
         if(!IsNumeric(document.getElementById("txtno").value))
         {
             alert("Please enter numbers only");
             document.getElementById("txtno").value = "";
             document.getElementById("txtno").focus();
             temp = false;
             return false;
         }
         else
         {
            if(document.getElementById("txtno").value.substring(0,1) != "0")
            {
                alert("STD Code should starts with 0");
                document.getElementById("txtno").value = "";
                document.getElementById("txtno").focus();
                temp = false;
                return false;
            }
            else
            {
                if(!lengthRestriction(document.getElementById("txtno"),6,16))
                {
                    return false;
                }
            }
         }
    }
    if (document.getElementById("txtMoblie").value!="")
    {
         if(!IsNumeric(document.getElementById("txtMoblie").value))
         {
             alert("Please enter numbers only");
             document.getElementById("txtMoblie").value = "";
             document.getElementById("txtMoblie").focus();
             temp = false;
             return false;
         }
         if(!ismobileno(document.getElementById("txtMoblie"),10))
        {
            return false;
        }
    }	
    if (document.getElementById("txtcity").value=="")
		{
		     alert("Please enter your city");
		     document.getElementById("txtcity").focus();
		     temp = false;
		     return false;
		}   
		if (document.getElementById("txtcity").value!="")
	    {
	        if(!isAlphabet(document.getElementById("txtcity"),'Please enter alphabets only'))
	        {
	            document.getElementById("txtcity").value="";
	            document.getElementById("txtcity").focus();
	            return false;
	        }
	    }	    
        if (document.getElementById("ddlhour").value == 'Select')
		{
		     alert("Please tell us preferred time to contact");
		     document.getElementById("ddlhour").focus();
		     temp = false;
		     return false;
		}  	
}