/************************************************************************************************************
    *     filename      	: shadowboxAndValidation.js								                                                      		*
    *     Description 	: This javascript page has been developed for shadowbox and validation of the				*
								  customer's interest form to use in individual cars as per the model name						*
    *     Author        	: Biswajit Roy, Developer, Soft_Solutions4u, Chennai, India                                				*
    *     Date        		: 03.08.2009                                                                              										*
    *     LastModified	: 03.08.2009                                                                              										*
************************************************************************************************************/		


		window.onload = function(){
					Shadowbox.init();
					/**
					* Note: The following command is not necessary in your own project. It is
					* only used here to set up the demonstrations on this page.
					*/
					initDemos();
				};
				
				function initDemos(){
					Shadowbox.setup([
					document.getElementById('flash1'),
					document.getElementById('flash2'),
					document.getElementById('flash3')
					], {
						gallery:        'Flash',
						continuous:     true,
						counterType:    'skip',
						animSequence:   'sync'
						});
						
					Shadowbox.setup(document.getElementById('hongkongmap').getElementsByTagName('area'));
				};	
				
				function validate() {
					if(document.form1.txtFname.value==""){
						alert("Enter the Name");
						document.form1.txtFname.focus();
						document.form1.txtFname.value="";
						return false;
					}
					
				if (document.form1.txtFname.value!=""){
					if(!(/^([a-zA-Z]|[\s])+$/.test(document.form1.txtFname.value))){
						alert("Name should have characters only");
						document.form1.txtFname.focus();
						document.form1.txtFname.value="";
						return false;
					}
				}
				
				if(document.form1.txtHomePhone.value==""){
					alert("Enter the HomePhone");
					document.form1.txtHomePhone.focus();
					document.form1.txtHomePhone.value="";
					return false;
				}
				
				if(document.form1.txtHomePhone.value.search(/^[0-9]+$/)){
					alert("Please enter only numeric value for Phone number");
					document.form1.txtHomePhone.value="";
					document.form1.txtHomePhone.focus();
					return false;
				}
				
				if(document.form1.Email.value=="") {
					alert("Enter Email");
					document.form1.Email.focus();
					document.form1.Email.value="";
					return false;
				}
				
				custEmail=document.form1.Email.value;
				retVal=echeck(custEmail);
				if(retVal==false){
					alert("Invalid E-mail ID");
					document.getElementById("Email").focus(); 
					document.getElementById("Email").value = "";
					return false;
				}
				if(!(/^([a-zA-Z0-9]+[a-zA-Z0-9_\.\-])*([a-zA-Z0-9])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.									test(document.form1.Email.value))){
					alert("Please Enter The Valid Email ID");
					document.form1.Email.focus();
					document.form1.Email.value="";
					return false;
				}
				
				if(!document.form1.txtZip.value.match(/^[0-9]+$/)){
					alert("Please Enter Zip Code");
					document.form1.txtZip.value="";
					document.form1.txtZip.focus();
					return false;
				}
			}
			
			
			// Email dot check
	function echeck(str) {

		var at="@"
		var dot="."		
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var www=str.toLowerCase();
		var Iwww=www.indexOf("www")
		
		
		
		if (str.indexOf(at)==-1){		  
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		  
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){		   
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){		   
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){		   
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){		   
		    return false
		 }

		 if (str.indexOf(" ")!=-1){		   
		    return false
		 }
		
		if (Iwww==0){		   
		    return false
		} 		 
	}