
/************************************************************************************************************
    *     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        		: 13.08.2009                                                                              										*
    *     LastModified	: 14.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 validationOfForm1() {
					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.match(/^[0-9]+$/)){
					alert("Please Enter phone number in numeric value");
					document.form1.txtHomePhone.value="";
					document.form1.txtHomePhone.focus();
					return false;
				}
				
				cellLength=document.form1.txtHomePhone.value.length;		
				if(cellLength>14){
					alert("Please enter the phone number below 14 digit");
					document.form1.txtHomePhone.focus();
					document.form1.txtHomePhone.value="";
					return false;
				}			
						
				if(cellLength<10){
					alert("Please enter the phone number more then 10 digit");
					document.form1.txtHomePhone.focus();
					document.form1.txtHomePhone.value="";
					return false;
				}
				
				if(document.form1.Email.value=="") {
					alert("Enter Email");
					document.form1.Email.focus();
					document.form1.Email.value="";
					return false;
				}
				
				var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				var address = document.getElementById("Email").value;
				if(reg.test(address) == false) {
					alert("Please Enter The Valid Email ID");
					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(document.form1.txtZip.value == ""){
					alert("Please Enter Zip Code");
					document.form1.txtZip.value="";
					document.form1.txtZip.focus();
					return false;
				}
				
				if(!document.form1.txtZip.value.match(/^[0-9]+$/)){
					alert("Please Enter Zip Code in numeric value");
					document.form1.txtZip.value="";
					document.form1.txtZip.focus();
					return false;
				}
				
				zipCodeLength=document.form1.txtZip.value.length;		
				if(zipCodeLength>11){
					alert("Please enter the zip code below 11 digit");
					document.form1.txtZip.focus();
					document.form1.txtZip.value="";
					return false;
				}			
						
				if(zipCodeLength<5){
					alert("Please enter the zip code more then 5 digit");
					document.form1.txtZip.focus();
					document.form1.txtZip.value="";
					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
		} 		 
	}