// JavaScript Document
var Array1= new Array(110001, 110002, 110003, 110004, 110005, 110006, 110007, 110008, 110009, 110010, 110011, 110012, 110013, 110014, 110015, 110016, 110017, 110018, 110019, 110020, 110021, 110022, 110023, 110024, 110025, 110026, 110027, 110028, 110029, 110030, 110031, 110032, 110033, 110034, 110035, 110036, 110037, 110038, 110039, 110040, 110041, 110042, 110043, 110044, 110045, 110046, 110047, 110048, 110049, 110051, 110052, 110053, 110054, 110055, 110056, 110057, 110058, 110059, 110060, 110061, 110062, 110063, 110064, 110065, 110066, 110067, 110068, 110070, 110071, 110072, 110073, 110075, 110081, 110082, 110083, 110084, 110085, 110087, 110088, 110091, 110092, 110092, 110093, 110094, 110095, 110096, 121000, 121001, 121002, 121003, 121004, 121005, 121006, 121007, 121008, 121101, 121107, 122000, 122001, 122002, 122003, 122004, 122005, 122006, 122007, 122008, 122009, 122010, 122011, 122012, 122013, 122014, 122015, 122016, 122017, 122051, 122101, 122102, 122103, 122105, 122106, 122109, 123401, 123501, 124001, 132103, 132104, 132105, 132106, 132108, 140001, 140504, 141001, 141002, 141003, 141004, 141005, 141006, 141007, 141008, 141009, 141010, 141011, 141020, 141301, 141401, 141402, 143000, 143001, 143002, 143003, 143004, 143005, 143006, 143104, 143105, 144001, 144002, 144003, 144004, 144005, 144006, 144007, 144008, 147001, 147002, 147021, 160001, 160002, 160003, 160004, 160005, 160006, 160007, 160008, 160009, 160010, 160011, 160012, 160013, 160014, 160015, 160016, 160017, 160018, 160019, 160020, 160021, 160022, 160023, 160024, 160025, 160026, 160027, 160028, 160029, 160030, 160031, 160032, 160033, 160034, 160035, 160036, 160037, 160038, 160039, 160040, 160041, 160042, 160043, 160044, 160045, 160046, 160047, 160048, 160049, 160050, 160051, 160052, 160053, 160054, 160055, 160061);

var Array2= new Array(206001, 206122, 206244, 206244, 208001, 208002, 208003, 208004, 208005, 208006, 208007, 208008, 208009, 208010, 208011, 208012, 208013, 208014, 208015, 208016, 208017, 208018, 208019, 208020, 208021, 208022, 208023, 208024, 208025, 209025, 209311, 209601, 209625, 211001, 211002, 211003, 211004, 211005, 211006, 211007, 211008, 211009, 211010, 211011, 211012, 211014, 211016, 211017, 211019, 212403, 221002, 221003, 221004, 221005, 221006, 221007, 221507, 222202, 225001, 225002, 226001, 226002, 226003, 226004, 226005, 226006, 226007, 226008, 226009, 226010, 226011, 226012, 226013, 226014, 226015, 226016, 226017, 226018, 226019, 226020, 226021, 226022, 226023, 226024, 241001, 246701, 246701, 246763, 247776, 250001, 250002, 250002, 250103, 250110, 250221, 250342, 250401, 250402, 251201, 282001, 282002, 282003, 282004, 282005, 282006, 282007, 282008, 282009, 282010, 283110);

var Array3= new Array(302001, 302002, 302003, 302004, 302005, 302006, 302007, 302008, 302009, 302010, 302011, 302012, 302013, 302014, 302015, 302016, 302017, 302018, 302019, 302020, 303101, 360001, 360002, 360003, 360004, 360005, 360006, 360035, 380001, 380002, 380003, 380004, 380005, 380006, 380007, 380008, 380009, 380012, 380013, 380014, 380015, 380016, 380018, 380019, 380021, 380022, 380023, 380024, 380025, 380026, 380027, 380028, 380050, 380051, 380052, 380053, 380054, 380055, 380058, 380059, 380061, 382011, 382012, 382013, 382014, 382015, 382016, 389001, 390001, 390002, 390003, 390004, 390005, 390006, 390007, 390008, 390009, 390010, 390011, 390012, 390013, 390014, 390015, 390016, 390017, 390018, 390019, 390020, 390021, 390022, 390023, 394221, 394230, 394651, 395003);

var Array4= new Array(400001, 400002, 400003, 400004, 400005, 400006, 400007, 400008, 400009, 400010, 400011, 400012, 400013, 400014, 400015, 400016, 400017, 400018, 400019, 400020, 400021, 400022, 400023, 400024, 400025, 400026, 400027, 400028, 400029, 400031, 400032, 400033, 400034, 400035, 400036, 400037, 400038, 400039, 400042, 400043, 400046, 400049, 400050, 400051, 400052, 400053, 400054, 400055, 400056, 400057, 400058, 400059, 400060, 400061, 400062, 400063, 400064, 400065, 400066, 400067, 400068, 400069, 400070, 400071, 400072, 400074, 400075, 400076, 400077, 400078, 400079, 400080, 400081, 400082, 400083, 400084, 400085, 400086, 400087, 400088, 400089, 400090, 400091, 400092, 400093, 400094, 400095, 400096, 400097, 400098, 400099, 400101, 400102, 400103, 400104, 401105, 411001, 411002, 411006, 411007, 411008, 411011, 411012, 411014, 411015, 411016, 411017, 411018, 411020, 411026, 411027, 411028, 411029, 411030, 411031, 411032, 411033, 411034, 411035, 411037, 411038, 411039, 411040, 411041, 411042, 411043, 411044, 411046, 411053, 412105, 412207, 440001, 440002, 440003, 440004, 440005, 440006, 440007, 440008, 440009, 440010, 440011, 440012, 440013, 440014, 440015, 440016, 440017, 440018, 440019, 440020, 440021, 440022, 440023, 440024, 440025, 440026, 440027, 440028, 440029, 440030, 452001, 452002, 452003, 452004, 452005, 452006, 462001, 462002, 462003, 462004, 462007, 462008, 462012, 462013, 462016, 462021, 462022, 462023, 462024, 462026, 462027, 462028, 462030, 462031, 462032, 462036, 462039, 462041, 482001, 482002, 482003, 482007, 482008, 482009, 482010, 492001, 492004, 492005, 492006, 492007, 492008, 492009, 492010, 492015, 492042, 492099, 493221);

var Array5= new Array(500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015, 500016, 500017, 500018, 500019, 500020, 500021, 500022, 500023, 500024, 500025, 500026, 500027, 500028, 500029, 500030, 500031, 500032, 500033, 500034, 500035, 500036, 500037, 500038, 500039, 500040, 500041, 500042, 500043, 500044, 500045, 500046, 500047, 500048, 500049, 500050, 500051, 500052, 500053, 500054, 500055, 500056, 500057, 500058, 500059, 500060, 500061, 500062, 500063, 500064, 500065, 500066, 500067, 500068, 500069, 500070, 500071, 500072, 500073, 500074, 500075, 500076, 500077, 500080, 500082, 500087, 500093, 500094, 500095, 501510, 502324, 520003, 520004, 520007, 520012, 520013, 520015, 530006, 530010, 530021, 533020, 534206, 535001, 535002, 535005, 560001, 560002, 560003, 560004, 560005, 560006, 560007, 560008, 560009, 560010, 560011, 560012, 560013, 560014, 560015, 560016, 560017, 560018, 560019, 560020, 560021, 560022, 560023, 560024, 560025, 560026, 560027, 560028, 560029, 560030, 560031, 560032, 560033, 560034, 560035, 560036, 560037, 560038, 560039, 560040, 560041, 560042, 560043, 560044, 560045, 560046, 560047, 560048, 560049, 560050, 560051, 560052, 560053, 560054, 560055, 560056, 560057, 560058, 560059, 560060, 560061, 560062, 560063, 560064, 560065, 560066, 560067, 560068, 560069, 560070, 560071, 560072, 560073, 560074, 560075, 560076, 560077, 560078, 560079, 560080, 560081, 560082, 560083, 560084, 560085, 560086, 560087, 560088, 560089, 560090, 560091, 560092, 560093, 560094, 560095, 560096, 560097, 560098, 560099, 560100, 562128, 562158, 570001, 570002, 570004, 570006, 570007, 570009, 570011, 570012, 570013, 570014, 570015, 570016, 570018, 570019, 570020, 570021, 570022, 570023, 570024, 570025, 570301, 571186, 571301, 574158, 574159, 575001, 575002, 575003, 575004, 575005, 575006);

var Array6= new Array(600001, 600002, 600003, 600004, 600005, 600006, 600007, 600008, 600009, 600010, 600011, 600012, 600013, 600014, 600015, 600016, 600017, 600018, 600019, 600020, 600021, 600022, 600023, 600024, 600025, 600026, 600027, 600028, 600029, 600030, 600031, 600032, 600033, 600034, 600035, 600036, 600037, 600038, 600039, 600040, 600041, 600042, 600043, 600044, 600045, 600046, 600047, 600048, 600049, 600050, 600051, 600052, 600053, 600054, 600055, 600056, 600057, 600058, 600059, 600060, 600061, 600062, 600063, 600064, 600065, 600066, 600067, 600068, 600069, 600070, 600071, 600072, 600073, 600074, 600075, 600076, 600077, 600078, 600079, 600080, 600081, 600082, 600083, 600084, 600085, 600086, 600087, 600088, 600089, 600090, 600091, 600092, 600093, 600094, 600095, 600096, 600097, 600098, 600099, 600100, 600101, 600102, 600103, 600104, 600105, 600106, 600107, 600108, 600109, 600110, 600111, 600112, 600113, 600114, 600115, 600116, 600117, 600118, 600119, 600120, 600121, 601101, 601102, 601202, 601203, 601204, 601206, 601212, 601301, 601302, 602001, 602002, 602003, 602004, 602021, 602024, 602025, 602102, 602105, 602107, 602108, 602109, 603001, 603002, 603048, 603103, 603104, 603109, 603111, 603112, 603202, 603203, 603204, 603209, 603306, 603308, 625001, 625002, 625003, 625004, 625005, 625006, 625007, 625009, 625010, 625011, 625012, 625014, 625015, 625016, 625017, 625018, 625019, 625020, 625021, 625022, 625104, 625107, 625122, 631203, 641001, 641002, 641003, 641004, 641005, 641006, 641007, 641008, 641009, 641010, 641011, 641012, 641013, 641015, 641016, 641017, 641018, 641019, 641020, 641021, 641022, 641023, 641024, 641025, 641026, 641027, 641028, 641029, 641030, 641031, 641032, 641033, 641034, 641035, 641036, 641037, 641038, 641039, 641040, 641040, 641042, 641043, 641044, 641045, 641046, 641047, 641062, 641104, 641105, 641106, 641107, 641108, 641109, 641301, 641402, 641406, 642001, 642002, 642003, 642004, 642005, 642114, 682001, 682001, 682002, 682002, 682004, 682004, 682005, 682005, 682006, 682006, 682009, 682009, 682011, 682011, 682012, 682012, 682013, 682013, 682014, 682014, 682015, 682015, 682016, 682016, 682017, 682017, 682018, 682018, 682019, 682019, 682020, 682020, 682021, 682021, 682022, 682022, 682023, 682023, 682024, 682024, 682025, 682025, 682026, 682026, 682027, 682027, 682028, 682028, 682029, 682029, 682030, 682030, 682031, 682031, 682032, 682032, 682033, 682033, 682035, 682035, 683101, 683101, 683104, 683104, 683501, 683501);

var Array7= new Array(700001, 700002, 700003, 700004, 700005, 700006, 700007, 700008, 700009, 700010, 700011, 700012, 700013, 700014, 700015, 700016, 700017, 700018, 700019, 700020, 700021, 700022, 700023, 700024, 700025, 700026, 700027, 700028, 700029, 700030, 700031, 700032, 700033, 700034, 700035, 700036, 700037, 700038, 700039, 700040, 700041, 700042, 700043, 700044, 700045, 700046, 700047, 700048, 700049, 700050, 700051, 700052, 700053, 700054, 700055, 700056, 700057, 700058, 700059, 700060, 700061, 700062, 700063, 700064, 700065, 700066, 700067, 700068, 700069, 700070, 700071, 700072, 700073, 700074, 700075, 700076, 700077, 700078, 700079, 700080, 700081, 700082, 700083, 700084, 700085, 700086, 700087, 700088, 700089, 700090, 700091, 700092, 700093, 700094, 700095, 700096, 700097, 700098, 700099, 700100, 700101, 700102, 700103, 700104, 700105, 700106, 700107, 700108, 700109, 700110, 700111, 700112, 700113, 700114, 700115, 700116, 700117, 700118, 700119, 700120, 700121, 700122, 700123, 700124, 700125, 700126, 700127, 700128, 700129, 700130, 700131, 700132, 700133, 700134, 700135, 700136, 700137, 700138, 700139, 700140, 700141, 700142, 700143, 700144, 700145, 700146, 700147, 700148, 700149, 700150, 751001, 751002, 751003, 751004, 751005, 751006, 751007, 751008, 751009, 751010, 751011, 751012, 751013, 751014, 751015, 751016, 751017, 751018, 751019, 751020, 751021, 751022, 751023, 751024, 751025, 751026, 751027, 751028, 751029, 751030, 751031, 781001, 781003, 781004, 781005, 781006, 781007, 781008, 781009, 781010, 781011, 781012, 781013, 781015, 781016, 781018, 781019, 781020, 781021, 781022, 781024, 781025, 781026, 781027, 781028, 781032);

var Array8= new Array(800001, 800002, 800003, 800004, 800005, 800006, 800007, 800008, 800009, 800010, 800011, 800012, 800013, 800014, 800015, 800016, 800017, 800018, 800019, 800020, 800021, 800022, 800023, 801503, 801505, 814112, 814142, 815353, 822101, 822102, 822114, 831001, 831002, 831003, 831004, 831005, 831006, 831007, 831008, 831009, 831010, 831011, 831012, 831013, 831014, 831015, 831016, 831017, 831018, 831019, 832106, 832107, 832108, 832109, 832110, 834001, 834002, 834003, 834004, 834005, 834006, 834007, 834008, 834009, 834010, 834011, 834012, 835103, 835215);

var nmIsFirst = true;
var add1IsFirst= true;

var cityIsFirst = true;
var emailIsFirst = true;
var add2IsFirst= true;

var pincodeIsFirst= true;

var mobileIsFirst= true;
var ageIsFirst = true;

var isFindPincode= false;
var cityIsFirst = true;
var address1IsFirst = true;
var address2IsFirst = true;
var emailIsFirst = true;
var ageIsFirst=true;
function checkFirst(e){
//	alert("ddd" + e.id);
	if(e.id =="_nm") {
		if (nmIsFirst) {
			nmIsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_address1") {
		if (add1IsFirst) {
			add1IsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_city") {
		if (cityIsFirst) {
			cityIsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_mobile") {
		if (mobileIsFirst) {
			mobileIsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_email") {
		if (emailIsFirst) {
			emailIsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_address2") {
		if (add2IsFirst) {
			add2IsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_pincode") {
		if (pincodeIsFirst) {
			pincodeIsFirst = false;
			e.value= "";
		}
	}else if(e.id =="_age") {
		if (ageIsFirst) {
			ageIsFirst = false;
			e.value= "";
		}
	}
	
	
}
function checkBlank(e) {
	if(e.value=="") {
		if(e.id =="_nm") {
			e.value= "Name*";
			nmIsFirst = true;
		}
		if(e.id =="_address1") {
			e.value= "Address1*";
			add1IsFirst = true;
		}
		if(e.id =="_city") {
			e.value= "City*";
			cityIsFirst = true;
		}
		if(e.id =="_mobile") {
			e.value= "Mobile*";
			mobileIsFirst = true;
		}
		if(e.id =="_email") {
			e.value= "Email*";
			emailIsFirst = true;
		}
		if(e.id =="_address2") {
			e.value= "Address2*";
			add2IsFirst = true;
		}
		if(e.id =="_pincode") {
			e.value= "Pincode*";
			pincodeIsFirst = true;
		}
		if(e.id =="_age") {
			e.value= "Age*";
			ageIsFirst = true;
		}
	}
		
}
function data_change(field)
     {
          var check = true;
          var value = field.value; //get characters
          //check that all characters are digits, ., -, or ""
          for(var i=0;i < field.value.length; ++i)
          {
               var new_key = value.charAt(i); //cycle through characters
               if(((new_key < "0") || (new_key > "9")) && 
                    !(new_key == ""))
               {
                    check = false;
                    break;
               }
          }
          //apply appropriate colour based on value
          if(!check)
          {
               //field.style.backgroundColor = "red";
			   field.value = "";
			   
          }
          else
          {
               field.style.backgroundColor = "white";
          }
     }
function checkNumberInput(e) {
	
	//		alert(typeof(String(parseInt(e.value))));
	/*if(String(parseInt(e.value))=='NaN') {
			alert("Enter only Numbers 0 to 9");
			e.value ="";
	}*/
}
function checkStringInput(e) {
	
	alert(parseInt(e.value));
//	alert(parseInt(e.value));
	if(String(parseInt(e.value))=='NaN') {
			//alert("Enter only Numbers 0 to 9");
		//	e.value ="";
	}
}
function checkOthers(e) {
//	alert(document.getElementById('_city1').selected)

	if(document.getElementById('_city1').options[document.getElementById('_city1').selectedIndex].value =="Others") {
			alert("Sorry! We are not currently catering in your city, however we shall contact you when we run offers and promotions in your city.");
		document.getElementById('_city1').selectedIndex= 0;
	}
}
function validate(){
//	alert(document.getElementById('_city1').selectedIndex);
	//alert(document.getElementById('_city1').se)

//	return false;
	if ((nmIsFirst || add1IsFirst || document.getElementById('_city1').selectedIndex==0 || mobileIsFirst || emailIsFirst || add2IsFirst || pincodeIsFirst || ageIsFirst)) {
		alert("Sorry! All fields are Mandatory*");
		return false;
	}

		//alert("click" + document.getElementById('pincode').value.charAt(0));
		isFindPincode = false;
		
		var firstChar = document.getElementById('_pincode').value.charAt(0)
		var pincode1String= document.getElementById('_pincode').value;
		
		if (firstChar>0 && firstChar<9) {
//			alert("right: " + eval("Array"+1).length);
			
			//find array name
			for (var i = 1; i<=8; i++) {
				if (i == firstChar) {
					//alert("arra" + i +  " : "+ pincode1String);
					//find text from the array
					for (var j = 0; j<eval("Array"+i).length; j++) {
						if (pincode1String == eval("Array"+i)[j]) {
							//trace("find");
							//alert("find");
							isFindPincode = true;
							break;
						}
					}
					break;
				}
			}
		} else {
			//trace("wrong"+firstChar);
			//alert("wrong");
		}
		if(isFindPincode) {
			//alert("found");
//			window.location.target = "_blank";			
//			window.location = "thanks.html";
			
			//window.open("thank_you.html","_blank");
			document.getElementByName('form1').submit();
			return true;
//			
			//window.open("thanks.html","_blank","fullscreen=1");	
			alert("correct");
		}else {
			alert("Sorry! We are not currently catering in your city, however we shall contact you when we run offers and promotions in your city.");
			return false;
		}
		
	}