/***************************************************   Public site validation **************************************/



function displayImage(carid,imageid){
	var count_image = document.getElementById(carid).value;
	for(i=1;i<=count_image;i++){
		if(imageid==i){
			document.getElementById(carid+"_"+i).style.display = 'block';
		}else{
			document.getElementById(carid+"_"+i).style.display = 'none';
		}
	
	}
}

function displaySlideImage(carid,imageid){
	var count_image = document.getElementById(carid).value;
	for(i=1;i<=count_image;i++){
		if(imageid==i){
			document.getElementById('car_'+i).style.display = 'block';
		}else{
			document.getElementById('car_'+i).style.display = 'none';
		}
	
	}
	
}



/***************************************************  Control Panel Validation ************************************/
function validateCar(){
	if(OptValidate(document.frmWeddingcar.car_category,'the Category')==false) { 
		document.frmWeddingcar.car_category[0].focus();
		return false;
	}
	if(SelectValidate(document.frmWeddingcar.car_brand,"the Car Brand")==false) {
			document.frmWeddingcar.car_brand.focus();		
			return false;
	}
	
	if(OptValidate(document.frmWeddingcar.car_drivemode,'the Drive Mode')==false) { 
		document.frmWeddingcar.car_drivemode[0].focus();
		return false;
	}
	
	if(TextValidate(document.frmWeddingcar.car_model,'the Car Model')==false){ return false };
	if(TextValidate(document.frmWeddingcar.car_color,'the Car Color')==false){ return false };	
	
	document.frmWeddingcar.action = "cardetails.php";
	document.frmWeddingcar.submit();
	
}

function priceChecking(value){
	if(value == 6 || value == 7){
		document.getElementById('price_rom').style.display='block';
		document.getElementById('price').style.display='none';
	} else {
		document.getElementById('price').style.display='block';	
		document.getElementById('price_rom').style.display='none';	
	}
}

function deleteCar(id,cat){
	if(confirm("Are you sure to delete this Car?")) {
	    
		window.location="cardetails.php?action=Delete&id="+id+"&catId="+cat;
 	}  			
}
function ClearUser() {
		if(document.form.frmuser.value == "User name"){
				document.form.frmuser.value = "";
		}
}
function ClearPass() {
		if(document.form.frmpass.value == "Password"){
				document.form.frmpass.value = "";
		}
}

function validateTerm(){
	if(document.form2.TC[0].checked == false && document.form2.TC[1].checked == false){
		alert("Please select the terms and condition");
	}else{
		window.location='customerDetails.php';	
	}
}
function updateBasket(page,args) {
			
			var url = page+"?action=update";
			if(args) { url += "&"+args}
			document.form2.action = url;
			document.form2.submit();
}

function validateDBSearch() {
	if (document.searchfrm.searchtxt.value == '') {
		alert("Pleass enter the search value")
		return false;
	} else {
		searchvalue = document.searchfrm.searchtxt.value
		document.searchfrm.action = "search.php"
		document.searchfrm.submit();
	}
}
function enterkey(evt) {
			var evt = (evt) ? evt : event
			var charCode = (evt.which) ? evt.which : evt.keyCode
			if (charCode == 13) {
				validateLogin();
			}
		}

//Member Login
function validateLogin() {
	if(TextValidate(document.form1.username,'the user name')==false) return false;
	if(document.form1.password.value == "")
	{
		document.form1.action ='memberLogin.php?action=mail';
		document.form1.submit(); 
	}else{
		document.form1.action = 'modules/loginProcess.php';
		document.form1.submit(); 
	}
	
}

function validateLoginMain() {
	if(TextValidate(document.form2.username,'the user name')==false) return false;
	if(document.form2.password.value == "")
	{
		document.form2.action ='memberLogin.php?action=mail';
		document.form2.submit(); 
	}else{
		document.form2.action = 'modules/loginProcess.php';
		document.form2.submit(); 
	}
}
// Function to validate the Login Form
function validateLoginCP() {
	if(TextValidate(document.frmlogin.username,'the user name')==false) return false;
	if(TextValidate(document.frmlogin.password,'the password')==false) return false;
	//document.form1.action = 'loginProcess.php';
	//document.form1.submit(); 
}

function validatePage() {
	
	if(TextValidate(document.frmPage.page_title,'the Page title')==false) return false;
	if(isProper(document.frmPage.page_title,'Page title')==false) return false;
	if(document.frmPage.page_banner.value != ''){
		if(fileValidate(document.frmPage.page_banner) == false) { return false; }
	}
	document.frmPage.action = 'page.php';
	document.frmPage.submit(); 
}

function validateWingImage(id,action) {
	if(action == "Add"){
		if(fileValidate(document.form1.wingimage_image) == false) { return false; }
	}else{
		if(document.form1.wingimage_image.value != ''){
			if(fileValidate(document.form1.wingimage_image) == false) { return false; }	
		}
	}
	document.form1.action = 'wingimages.php?id='+id;
	document.form1.submit(); 
}
function validateEventImage(id,action) {
	if(action == "Add"){
		if(fileValidate(document.form1.eventimage_image) == false) { return false; }
	}else{
		if(document.form1.eventimage_image.value != ''){
			if(fileValidate(document.form1.eventimage_image) == false) { return false; }	
		}
	}
	document.form1.action = 'eventimages.php?id='+id;
	document.form1.submit(); 
}
function validateImage(id,action) {
	
	if(TextValidate(document.form1.image_title,'the Image title')==false) return false;
	if(action == "Add"){
		if(fileValidate(document.form1.image_image) == false) { return false; }
	}else{
		if(document.form1.image_image.value != ''){
			if(fileValidate(document.form1.image_image) == false) { return false; }	
		}
	}
	document.form1.action = 'images.php?id='+id;
	document.form1.submit(); 
}





function validatePrice(id) {
	if(TextValidate(document.form1.eventprice_price,'the Event price')==false) return false;
	if(TextAreaValidateS(document.form1.eventprice_description,'the Price description')==false) return false;
	document.form1.action = 'price.php?id='+id;
	document.form1.submit(); 
}
function validatePriority() {
	//if(TextAreaValidateS(document.frmpriority.priorities_introtext,'the priority text')==false) return false;
	//if(TextAreaValidateS(document.frmpriority.priorities_details,'the  priority details')==false) return false;
	
	document.frmpriority.action = 'priority.php';
	document.frmpriority.submit(); 
}

function validateBooking() {
	
	document.frmbooking.action = 'booking.php?action=confirm';
	document.frmbooking.submit(); 
}

function validateSubcription() {
	if(TextValidate(document.frmSubscription.subscription_name,'the Name')==false) return false;
	if(TextValidate(document.frmSubscription.subscription_company,'the Company')==false) return false;
	if(TextValidate(document.frmSubscription.subscription_email,'the Email')==false) return false;
	if(EmailValidate(document.frmSubscription.subscription_email,"Email")==false){return false;}	
	/*if((document.frmSubscription.subscription_news.checked==false) && (document.frmSubscription.subscription_pressrelease.checked==false))     {
		alert("Please select any one Subscription");
		//document.frmSubscription.subscription_news.focus();
		return false;
	  }*/

	
	document.frmSubscription.action = 'newsRoom.php';
	document.frmSubscription.submit(); 
}

function popup(type){
	
	window.open("fullMember.php?type="+type,"Window1","menubar=no,width=800,height=600,scrollbars=yes");

}
function alpa(type){
	var val="";
	for(charCode = 65;charCode <= 90; charCode ++){
		val = val +" "+ "<a href='popupWindow.php?order="+String.fromCharCode(charCode)+"'>"+String.fromCharCode(charCode)+"</a>";
	}
	if(type == 1){
		val = val +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='popupWindow.php'> List all Full Members </a>"; 
	}else if(type == 2){
		val = val +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='popupWindow.php'> List all Associate Members </a>"; 
	}
	document.getElementById("order").innerHTML=val;
}


function popupWindow(win,winWidth,winHeight,place,winName){
	
	leftPos = 0; topPos = 0; // default variables for old browsers

		if (screen){ 
		
		   // checks specified parameters are not outside screen area
		   
    		if (winWidth>screen.width){
    		   winWidth = screen.width;
    		}
    		
    		if (winHeight>screen.height){
    		   winHeight = screen.height - 55;
    		}
    		
    		if (winWidth <= 0){
    		   winWidth = screen.width;
    		}
    		
    		if (winHeight <= 0){
    		   winHeight = screen.height - 55;
    		}
    		
			// positions window by checking place parameter
					
			if (place == 'topleft'){ // positions window in top left corner
			leftPos = 0;
			topPos = 0;
			}
			
			if (place == 'centre'){ // centres window
			leftPos = screen.width/2 - winWidth/2;
			topPos = screen.height/2 - winHeight/2;
			}
			
			if (place == 'topright'){ // positions window in top right corner
			leftPos = screen.width - winWidth;
			topPos = 0;
			}
			
			if (place == 'botleft'){ // positions window in bottom left corner
			leftPos = 0;
			topPos = screen.height - (winHeight + 55); // add 55 to prevent bottom of window being obscured by taskbar
			}
			
			if (place == 'botright'){ // positions window in bottom right corner
			leftPos = screen.width - winWidth;
			topPos = screen.height - (winHeight+55); // add 55 to prevent bottom of window being obscured by taskbar
			}
					
		}

		newWindow = window.open(win,winName,'toolbar=no,location=no,scrollbars=yes,resizable=no,width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+'');
		newWindow.focus();
	}
	
	/*** tiny mce validator functions **/
	function Remove_Spaces_Editor(content,id,msg)
	{
		//alert("fi");
	  //alert("content="content);alert("msg="msg);
	  //content = content.replace("<p>&nbsp;</p><p>&nbsp;</p>", "");
	  content = content.replace("<p>&nbsp;</p>", "");
	  content = content.replace(/&nbsp;/g, "");
	  content = content.replace("<p></p>", "");
	  content = content.replace("<br />", "");
	  content = content.replace("<p></p>", "");
	  content = content.replace("<br>", "");
	  content = content.replace(" ", "");
	  content = content.replace("<p></p>", "");
	  //alert("."+content+".");
	  if (content == ""){
		  alert(msg);
		  //id.selection.selectNode(inst.getBody(), true, true);
		  id.contentWindow.focus();
		  return false;
	  }
	 }
 
 
	
	/**Deco validations*/
	function AddDeco(value) {
		if(TextValidate(document.frmDeco.deco_title,'Title')==false) return false;
		if(value == 1){
 		if(document.getElementById("hidden_deco_image_path").value == "" || document.getElementById("hidden_deco_image_path").value =="undefined"){
				alert("Please select a decoration image to upload");
 				document.getElementById("deco_image_path").focus();
				return false;
		}
		} else if(value == 0){
			if(document.getElementById("deco_image_path").value == "" ){
			alert("Please select a decoration image to upload");
 			document.getElementById("deco_image_path").focus();
			return false;
			}
		}
		document.frmDeco.action = "add_deco.php";
		document.frmDeco.submit();
 	}
	
	
	/**** validation for testimonial**/
	function deleteTesti(testi_id,path) {
		if(confirm("Are you sure you want to delete this Testimonial?")) {
			document.frmTestiList.action = path+"&id="+testi_id;
			document.frmTestiList.submit();
		}
	}
	
	function AddTesti() {
		if(TextValidate(document.frmTesti.testi_name,'Name of Couples')==false) return false;	
		if(TextValidate(document.frmTesti.testi_date,'Date')==false) return false;	
		if(TextValidate(document.frmTesti.testi_message,'Testimonial')==false) return false;
		if(SelectValidate(document.frmTesti.testi_car_brand,"Car Brand")==false) {
			document.frmTesti.testi_car_brand.focus();		
			return false;
		}
		if(TextValidate(document.frmTesti.testi_car_model,'Car Model')==false) return false;
		if(OptValidate(document.frmTesti.testi_car_ext,'Condition of Car (exterior )')==false) { 
			document.frmTesti.testi_car_ext[0].focus();
			return false;
		}

		if(OptValidate(document.frmTesti.testi_car_int,'Condition of Car (interior )')==false) { 
			document.frmTesti.testi_car_int[0].focus();
			return false;
		}
		if(OptValidate(document.frmTesti.testi_overall,'Overall Experience')==false) { 
			document.frmTesti.testi_overall[0].focus();
			return false;
		}
		
		document.frmTesti.action = "add_testimonial.php";
		document.frmTesti.submit();
 	}
	
	function booking_validation() {
		if(SelectValidate(document.frmCarBooking.hear,"How did you hear about us")==false) {
			document.frmCarBooking.hear.focus();		
			return false;
		}
		if(TextValidate(document.frmCarBooking.name,'Name')==false) return false;	
		if(TextValidate(document.frmCarBooking.contact,'Contact Number')==false) return false;	
		if(EmailValidate(document.frmCarBooking.email,"Email Address")==false){return false;}	
		if(TextValidate(document.frmCarBooking.additional_comment,'Additional Comment')==false) return false;	
		
		if(SelectValidate(document.frmCarBooking.dateRequired,"date")==false) {
			document.frmCarBooking.dateRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmCarBooking.monthRequired,"Month")==false) {
			document.frmCarBooking.monthRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmCarBooking.yearRequired,"Year")==false) {
			document.frmCarBooking.yearRequired.focus();		
			return false;
		}
		if(TextValidate(document.frmCarBooking.daysRequired,'Number of days required')==false) return false;	
		
		if(document.frmCarBooking.booking_check.checked == false){
			alert("Please check the terms and condition checkbox");
			document.frmCarBooking.booking_check.focus();
			return false;
		}
	
		document.frmCarBooking.action = "thank.php?booking=car";
		document.frmCarBooking.submit();
 	}
	
	function novelty_validation() {
		if(SelectValidate(document.frmBookingNovelty.hear,"How did you hear about us")==false) {
			document.frmBookingNovelty.hear.focus();		
			return false;
		}
		if(TextValidate(document.frmBookingNovelty.name,'Name')==false) return false;	
		if(TextValidate(document.frmBookingNovelty.contact,'Contact Number')==false) return false;	
		if(EmailValidate(document.frmBookingNovelty.email,"Email Address")==false){return false;}	
		
		document.frmBookingNovelty.action = "thank.php?booking=novelty";
		document.frmBookingNovelty.submit();
 	}
	
	function novelty_validate_onchange(){
		var totalPrice = 39;
		
		if (document.frmBookingNovelty.topStickerText.value != ""){
			 totalPrice = totalPrice + 6;
		}
	    	
		if (document.frmBookingNovelty.bottomStickerText.value != ""){
			 totalPrice = totalPrice + 6;
		}
		   
		if (document.frmBookingNovelty.isDelivery.checked == true){
			 totalPrice = totalPrice + 6;
		}
		
		/*document.frmBookingNovelty.totalPrice.value = totalPrice;
		document.frmBookingNovelty.total_Price.value = totalPrice;*/
	}
		
	function changePass(){
		if(TextValidate(document.frmpassword.administrator_username,'User Name')==false) return false;		
		if(TextValidate(document.frmpassword.old_password,'Old Password')==false) return false;		
		if(TextValidate(document.frmpassword.new_password,'New Password')==false) return false;		
		if(TextValidate(document.frmpassword.confirm_password,'Confirm Password')==false) return false;		
										
		document.frmpassword.action = "change_password.php";
		document.frmpassword.submit();
	}
	/* Leasing , motoring & corporate validations*/
	function AddLease() {
		if(TextValidate(document.frmLease.lease_title,'Title')==false) return false;	
		var editor_id_description = tinyMCE.getInstanceById('lease_message');
		if(Remove_Spaces_Editor((tinyMCE.getContent('lease_message')),editor_id_description,"Please enter Description")==false) {
			return false; 
		}
		document.frmLease.action = "add_leasing.php";
		document.frmLease.submit();
 	}
	
	
	/**** Delete validation for Leasing , motoring & corporate **/
	function deleteLease(lease_id,path) {
		if(confirm("Are you sure you want to delete?")) {
			document.frmLeaseList.action = path+"&id="+lease_id;
			document.frmLeaseList.submit();
		}
	}
	
	/* booking validation for transfer/disposal*/
	function transfer_booking_validation() {
		if(TextValidate(document.frmTransferBooking.name,'Name')==false) return false;	
		if(TextValidate(document.frmTransferBooking.company,'Company')==false) return false;	
		if(TextValidate(document.frmTransferBooking.contact,'Contact Number')==false) return false;	
		if(EmailValidate(document.frmTransferBooking.email,"Email Address")==false){return false;}	
		if(TextValidate(document.frmTransferBooking.additional_comment,'Additional Comment')==false) return false;	

		/*if(SelectValidate(document.frmTransferBooking.arr_transfer_type,'Type')==false) { 
			document.frmTransferBooking.arr_transfer_type.focus();
			return false;
		}
		if(SelectValidate(document.frmTransferBooking.dateRequired,"date")==false) {
			document.frmTransferBooking.dateRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmTransferBooking.monthRequired,"Month")==false) {
			document.frmTransferBooking.monthRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmTransferBooking.yearRequired,"Year")==false) {
			document.frmTransferBooking.yearRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmTransferBooking.startTime,"Start Time")==false) {
			document.frmTransferBooking.startTime.focus();		
			return false;
		}
		if(SelectValidate(document.frmTransferBooking.endTime,"End Time")==false) {
			document.frmTransferBooking.endTime.focus();		
			return false;
		}*/
		if(SelectValidate(document.frmTransferBooking.arr_msia_entry,'Msia Entry')==false) { 
			document.frmTransferBooking.arr_msia_entry.focus();
			return false;
		}
		
		if(document.frmTransferBooking.transfer_booking_check.checked == false){
			alert("Please check the terms and condition checkbox");
			document.frmTransferBooking.transfer_booking_check.focus();
			return false;
		}
	
		document.frmTransferBooking.action = "thank.php?booking=transfer&value=";
		document.frmTransferBooking.submit();
 	}
	
	
	var selectedCount=0;
	var orderValue = "";
	var sampleCount = 0;
	var orderImage = "";
	
  function decorations_order(val, count, sample,image,title){
	 var orderContent="";
	 var pic="";
	 var sample_pic ="";
	 var sampleContent ="";
     if (count == 1){
		if(document.getElementById(val).checked == true){
			if(selectedCount >= 3 ){
				document.getElementById(val).checked = false;
				alert("You can choose only three");
			}else{
				selectedCount +=1;
			}
		}else{
			selectedCount -=1;
		}
		if(document.getElementById(val).checked  == true){
			 orderContent += title;
			 pic += image;
			 alert(orderContent);
			 alert(pic);
		 
		 } else if(document.getElementById(val).checked  == false){
			 alert("inside false");
			 alert(document.decoration_form.orderCon.value);
			 alert(pic);			
 		 }
		  document.decoration_form.Pic.value = document.decoration_form.Pic.value+","+pic;
		  document.decoration_form.orderCon.value = document.decoration_form.orderCon.value+","+orderContent;
		 
     } else if(count == 'ribbon'){
	    document.decoration_form.orderVal.value = val;
		document.decoration_form.orderImg.value = image;
	 } else if(count == 'flower'){
	    document.decoration_form.flowerVal.value = title;
	 } else if((count == 'sample') && (sample == 1)){
	   if(document.getElementById(val).checked == true){
			if(sampleCount >= 1 ){
				document.getElementById(val).checked = false;
				alert("You can choose any one sample");
			}else{
				sampleCount +=1;
			}
		}else{
			sampleCount -=1;
		}
		 if (document.getElementById(val).checked == true){
			 sampleContent += title;
			 sample_pic += image;
		 }
		 document.decoration_form.SampPic.value = sample_pic;
		 document.decoration_form.SampCon.value = sampleContent;	 
 	 }

	 if(count == 'submit'){
		 window.open('decoration_popup_form.php?order='+document.decoration_form.orderCon.value +'&ribbon='+ document.decoration_form.orderVal.value +'&ribbonImage='+document.decoration_form.orderImg.value+'&samplePicture='+document.decoration_form.SampPic.value+'&sample_content='+document.decoration_form.SampCon.value+'&pic='+document.decoration_form.Pic.value+'&flower='+document.decoration_form.flowerVal.value,'decorationWindow','width=630,height=640');

	 }
   }
   
   function dceo_pop_validation(){
	  if(SelectValidate(document.frmDecoBooking.hear,"How did you hear about us")==false) {
			document.frmDecoBooking.hear.focus();		
			return false;
		}
		if(TextValidate(document.frmDecoBooking.name,'Name')==false) return false;	
		if(TextValidate(document.frmDecoBooking.contact,'Contact Number')==false) return false;	
		if(EmailValidate(document.frmDecoBooking.email,"Email Address")==false){return false;}	
		/*if(TextValidate(document.frmCarBooking.additional_comment,'Additional Comment')==false) return false;	*/
		
		if(SelectValidate(document.frmDecoBooking.dateRequired,"date")==false) {
			document.frmDecoBooking.dateRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmDecoBooking.monthRequired,"Month")==false) {
			document.frmDecoBooking.monthRequired.focus();		
			return false;
		}
		if(SelectValidate(document.frmDecoBooking.yearRequired,"Year")==false) {
			document.frmDecoBooking.yearRequired.focus();		
			return false;
		}
		
		document.frmDecoBooking.action = "thank.php?booking=decoration";
		document.frmDecoBooking.submit(); 
   }
   
   function advertise_validation(){
		if(TextValidate(document.frmAdvertiseBooking.name,'Name')==false) return false;	
		if(TextValidate(document.frmAdvertiseBooking.contact,'Contact Number')==false) return false;	
		if(EmailValidate(document.frmAdvertiseBooking.email,"Email Address")==false){return false;}	
		
		document.frmAdvertiseBooking.action = "thank.php?booking=advertise";
		document.frmAdvertiseBooking.submit(); 
   }
   
  function rent_validation(){
		if(TextValidate(document.frmRentBooking.name,'Name')==false) return false;	
		if(TextValidate(document.frmRentBooking.contact,'Contact Number')==false) return false;	
		if(EmailValidate(document.frmRentBooking.email,"Email Address")==false){return false;}	
		
		document.frmRentBooking.action = "thank.php?booking=rent";
		document.frmRentBooking.submit(); 
   }
   
  function contact_validation(){
		if(SelectValidate(document.frmContact.hear,"How did you hear about us")==false) {
			document.frmContact.hear.focus();		
			return false;
		}
		if(SelectValidate(document.frmContact.enquiry_type,"Enquiry Type")==false) {
			document.frmContact.enquiry_type.focus();		
			return false;
		}
		if(TextValidate(document.frmContact.name,'Name')==false) return false;	
		if(EmailValidate(document.frmContact.email,"Email Address")==false){return false;}	
		if(TextValidate(document.frmContact.contact,'Contact Number')==false) return false;	
		if(TextValidate(document.frmContact.additional_comment,'Comment')==false) return false;	

		document.frmContact.action = "thank.php?booking=contact";
		document.frmContact.submit(); 
   }
   
    function feedback_validation(){
		if(TextValidate(document.frmFeedBack.wedding_date,'Wedding Date')==false) return false;	
		if(TextValidate(document.frmFeedBack.name,'Name')==false) return false;	
		if(EmailValidate(document.frmFeedBack.email,"Email Address")==false){return false;}	
		if(SelectValidate(document.frmFeedBack.car_model,"Car Model")==false) {
			document.frmFeedBack.car_model.focus();		
			return false;
		}
		
		if(OptValidate(document.frmFeedBack.car_ext,'Condition of Car (exterior )')==false) { 
			document.frmFeedBack.car_ext[0].focus();
			return false;
		}
		if(OptValidate(document.frmFeedBack.car_int,'Condition of Car (interior )')==false) { 
			document.frmFeedBack.car_int[0].focus();
			return false;
		}
		if(OptValidate(document.frmFeedBack.service,'Punctuality of service')==false) { 
			document.frmFeedBack.service[0].focus();
			return false;
		}
		if(OptValidate(document.frmFeedBack.staff,' Professionalism of staff ')==false) { 
			document.frmFeedBack.staff[0].focus();
			return false;
		}
		if(OptValidate(document.frmFeedBack.experience,'Overall Experience')==false) { 
			document.frmFeedBack.experience[0].focus();
			return false;
		}
		
		if(TextValidate(document.frmFeedBack.message,'Message')==false) return false;	

		//document.frmFeedBack.action = "thank.php?booking=feedback";
		document.frmFeedBack.action = "thank.php?booking=feedback";
		document.frmFeedBack.submit(); 
   }
   
   function validateCarBrand(){
	   	if(TextValidate(document.frmCarBrand.brand_name,'Car Brand')==false) return false;	
		document.frmCarBrand.action = "add_car_brand.php";
		document.frmCarBrand.submit(); 
   }
   
   function deleteBrand(brand_id,path) {
		if(confirm("Are you sure you want to delete?")) {
			document.frmBrandList.action = path+"&id="+brand_id+"&cnfrm=1";
			document.frmBrandList.submit();
		}
	}
   
   function deleteBrandConfrm(brand_id,path,cnfrm){
	   if(cnfrm == '1'){
	   if(confirm("This car Brand is already in use.Are you sure you want to delete?")) {
			document.frmBrandList.action = path+"&id="+brand_id;
			document.frmBrandList.submit();
	 	} 
	   } else {
		   document.frmBrandList.action = path+"&id="+brand_id;
			document.frmBrandList.submit();
	   }
   }
   
   /************** for add row functionality **************/
   // Last updated 2006-02-21
	function addRowToTable()
	{
	  var tbl = document.getElementById('tblTransfer');
	  var lastRow = tbl.rows.length;
	  // if there's no header row in the table, then iteration = lastRow + 1
	  var iteration = lastRow;
	  var row = tbl.insertRow(lastRow);
	  
	  // left cell
	  /*var cellLeft = row.insertCell(0);
	  var textNode = document.createTextNode(iteration);
	  cellLeft.className = 'h3';
	  cellLeft.appendChild(textNode);*/
	  
	   // select cell
	  var cellRightSel = row.insertCell(0);
	  var sel = document.createElement('select');
	  sel.name = 'arr_transfer_type' + iteration;
	  sel.className = 'h3';
	  sel.options[0] = new Option('Select Type', 'arr_transfer_type');
	  sel.options[1] = new Option('Transfer', 'Transfer');
	  sel.options[2] = new Option('Disposal', 'Disposal');
	  cellRightSel.appendChild(sel);

	  var cellRightSelday = row.insertCell(1);
	  var selday = document.createElement('select');
	  selday.name = 'dateRequired' + iteration;
	  selday.className = 'h3';
	  selday.options[0] = new Option('Select Day', 'Select Day');
	  selday.options[1] = new Option('1', '1');
      selday.options[2] = new Option('2', '2');
	  selday.options[3] = new Option('3', '3');
	  selday.options[4] = new Option('4', '4');
	  selday.options[5] = new Option('5', '5');
	  selday.options[6] = new Option('6', '6');
	  selday.options[7] = new Option('7', '7');
	  selday.options[8] = new Option('8', '8');
	  selday.options[9] = new Option('9', '9');
	  selday.options[10] = new Option('10', '10');
	  selday.options[11] = new Option('11', '11');
	  selday.options[12] = new Option('12', '12');
	  selday.options[13] = new Option('13', '13');
	  selday.options[14] = new Option('14', '14');
	  selday.options[15] = new Option('15', '15');
	  selday.options[16] = new Option('16', '16');
	  selday.options[17] = new Option('17', '17');
	  selday.options[18] = new Option('18', '18');
	  selday.options[19] = new Option('19', '19');
	  selday.options[20] = new Option('20', '20');
	  selday.options[21] = new Option('21', '21');
	  selday.options[22] = new Option('22', '22');
	  selday.options[23] = new Option('23', '23');
	  selday.options[24] = new Option('24', '24');
	  selday.options[25] = new Option('25', '25');
	  selday.options[26] = new Option('26', '26');
	  selday.options[27] = new Option('27', '27');
	  selday.options[28] = new Option('28', '28');
	  selday.options[29] = new Option('29', '29');
	  selday.options[30] = new Option('30', '30');
	  selday.options[31] = new Option('31', '31');
	  
	 var selmonth = document.createElement('select');
	  selmonth.name = 'monthRequired' + iteration;
	  selmonth.className = 'h3';
	  selmonth.options[0] = new Option('Select Month', 'Select Month');
	  selmonth.options[1] = new Option('January', 'January');
      selmonth.options[2] = new Option('February', 'February');
	  selmonth.options[3] = new Option('March', 'March');
	  selmonth.options[4] = new Option('April', 'April');
	  selmonth.options[5] = new Option('May', 'May');
	  selmonth.options[6] = new Option('June', 'June');
	  selmonth.options[7] = new Option('July', 'July');
	  selmonth.options[8] = new Option('August', 'August');
	  selmonth.options[9] = new Option('September', 'September');
	  selmonth.options[10] = new Option('October', 'October');
	  selmonth.options[11] = new Option('November', 'November');
	  selmonth.options[12] = new Option('December', 'December');
	 
	  var selyear = document.createElement('select');
	  selyear.name = 'yearRequired' + iteration;
	  selyear.className = 'h3';
	  selyear.options[0] = new Option('Select Year', 'Select Year');
	  selyear.options[1] = new Option('2009', '2009');
      selyear.options[2] = new Option('2010', '2010');
	  selyear.options[3] = new Option('2011', '2011');
	  selyear.options[4] = new Option('2012', '2012');
	 
	  cellRightSelday.appendChild(selday);
	  cellRightSelday.appendChild(selmonth);
	  cellRightSelday.appendChild(selyear);
	
	  var cellSelStartTime = row.insertCell(2);
	  var selStartTime = document.createElement('select');
	  selStartTime.name = 'startTime' + iteration;
	  selStartTime.className = 'h3';
	  selStartTime.options[0] = new Option('Hour', 'Hour');
	  selStartTime.options[1] = new Option('1', '1');
      selStartTime.options[2] = new Option('2', '2');
	  selStartTime.options[3] = new Option('3', '3');
	  selStartTime.options[4] = new Option('4', '4');
	  selStartTime.options[5] = new Option('5', '5');
	  selStartTime.options[6] = new Option('6', '6');
	  selStartTime.options[7] = new Option('7', '7');
	  selStartTime.options[8] = new Option('8', '8');
	  selStartTime.options[9] = new Option('9', '9');
	  selStartTime.options[10] = new Option('10', '10');
	  selStartTime.options[11] = new Option('11', '11');
	  selStartTime.options[12] = new Option('12', '12');
	  selStartTime.options[13] = new Option('13', '13');
	  selStartTime.options[14] = new Option('14', '14');
	  selStartTime.options[15] = new Option('15', '15');
	  selStartTime.options[16] = new Option('16', '16');
	  selStartTime.options[17] = new Option('17', '17');
	  selStartTime.options[18] = new Option('18', '18');
	  selStartTime.options[19] = new Option('19', '19');
	  selStartTime.options[20] = new Option('20', '20');
	  selStartTime.options[21] = new Option('21', '21');
	  selStartTime.options[22] = new Option('22', '22');
	  selStartTime.options[23] = new Option('23', '23');
	  selStartTime.options[24] = new Option('24', '24');
	  
	  var selStartTimeMin = document.createElement('select');
	  selStartTimeMin.name = 'startTimeMin' + iteration;
	  selStartTimeMin.className = 'h3';
	  selStartTimeMin.options[0] = new Option('Min', 'Min');
	  selStartTimeMin.options[1] = new Option('1', '1');
      selStartTimeMin.options[2] = new Option('2', '2');
	  selStartTimeMin.options[3] = new Option('3', '3');
	  selStartTimeMin.options[4] = new Option('4', '4');
	  selStartTimeMin.options[5] = new Option('5', '5');
	  selStartTimeMin.options[6] = new Option('6', '6');
	  selStartTimeMin.options[7] = new Option('7', '7');
	  selStartTimeMin.options[8] = new Option('8', '8');
	  selStartTimeMin.options[9] = new Option('9', '9');
	  selStartTimeMin.options[10] = new Option('10', '10');
	  selStartTimeMin.options[11] = new Option('11', '11');
	  selStartTimeMin.options[12] = new Option('12', '12');
	  selStartTimeMin.options[13] = new Option('13', '13');
	  selStartTimeMin.options[14] = new Option('14', '14');
	  selStartTimeMin.options[15] = new Option('15', '15');
	  selStartTimeMin.options[16] = new Option('16', '16');
	  selStartTimeMin.options[17] = new Option('17', '17');
	  selStartTimeMin.options[18] = new Option('18', '18');
	  selStartTimeMin.options[19] = new Option('19', '19');
	  selStartTimeMin.options[20] = new Option('20', '20');
	  selStartTimeMin.options[21] = new Option('21', '21');
	  selStartTimeMin.options[22] = new Option('22', '22');
	  selStartTimeMin.options[23] = new Option('23', '23');
	  selStartTimeMin.options[24] = new Option('24', '24');
	  selStartTimeMin.options[25] = new Option('25', '25');
	  selStartTimeMin.options[26] = new Option('26', '26');
	  selStartTimeMin.options[27] = new Option('27', '27');
	  selStartTimeMin.options[28] = new Option('28', '28');
	  selStartTimeMin.options[29] = new Option('29', '29');
	  selStartTimeMin.options[30] = new Option('30', '30');
	  selStartTimeMin.options[31] = new Option('31', '31');
	  selStartTimeMin.options[32] = new Option('32', '32');
	  selStartTimeMin.options[33] = new Option('33', '33');
	  selStartTimeMin.options[34] = new Option('34', '34');
	  selStartTimeMin.options[35] = new Option('35', '35');
	  selStartTimeMin.options[36] = new Option('36', '36');
	  selStartTimeMin.options[37] = new Option('37', '37');
	  selStartTimeMin.options[38] = new Option('38', '38');
	  selStartTimeMin.options[39] = new Option('39', '39');
	  selStartTimeMin.options[40] = new Option('40', '40');
	  selStartTimeMin.options[41] = new Option('41', '41');
	  selStartTimeMin.options[42] = new Option('42', '42');
	  selStartTimeMin.options[43] = new Option('43', '43');
	  selStartTimeMin.options[44] = new Option('44', '44');
	  selStartTimeMin.options[45] = new Option('45', '45');
	  selStartTimeMin.options[46] = new Option('46', '46');
	  selStartTimeMin.options[47] = new Option('47', '47');
	  selStartTimeMin.options[48] = new Option('48', '48');
	  selStartTimeMin.options[49] = new Option('49', '49');
	  selStartTimeMin.options[50] = new Option('50', '50');
	  selStartTimeMin.options[51] = new Option('51', '51');
	  selStartTimeMin.options[52] = new Option('52', '52');
	  selStartTimeMin.options[53] = new Option('53', '53');
	  selStartTimeMin.options[54] = new Option('54', '54');
	  selStartTimeMin.options[55] = new Option('55', '55');
	  selStartTimeMin.options[56] = new Option('56', '56');
	  selStartTimeMin.options[57] = new Option('57', '57');
	  selStartTimeMin.options[58] = new Option('58', '58');
	  selStartTimeMin.options[59] = new Option('59', '59');
	  selStartTimeMin.options[60] = new Option('60', '60');
	  
	  cellSelStartTime.appendChild(selStartTime);
	  cellSelStartTime.appendChild(selStartTimeMin);


	  var cellSelEndTime = row.insertCell(3);
	  var selEndTime = document.createElement('select');
	  selEndTime.name = 'endTime' + iteration;
	  selEndTime.className = 'h3';
	  selEndTime.options[0] = new Option('Hour', 'Hour');
	  selEndTime.options[1] = new Option('1', '1');
      selEndTime.options[2] = new Option('2', '2');
	  selEndTime.options[3] = new Option('3', '3');
	  selEndTime.options[4] = new Option('4', '4');
	  selEndTime.options[5] = new Option('5', '5');
	  selEndTime.options[6] = new Option('6', '6');
	  selEndTime.options[7] = new Option('7', '7');
	  selEndTime.options[8] = new Option('8', '8');
	  selEndTime.options[9] = new Option('9', '9');
	  selEndTime.options[10] = new Option('10', '10');
	  selEndTime.options[11] = new Option('11', '11');
	  selEndTime.options[12] = new Option('12', '12');
	  selEndTime.options[13] = new Option('13', '13');
	  selEndTime.options[14] = new Option('14', '14');
	  selEndTime.options[15] = new Option('15', '15');
	  selEndTime.options[16] = new Option('16', '16');
	  selEndTime.options[17] = new Option('17', '17');
	  selEndTime.options[18] = new Option('18', '18');
	  selEndTime.options[19] = new Option('19', '19');
	  selEndTime.options[20] = new Option('20', '20');
	  selEndTime.options[21] = new Option('21', '21');
	  selEndTime.options[22] = new Option('22', '22');
	  selEndTime.options[23] = new Option('23', '23');
	  selEndTime.options[24] = new Option('24', '24');
	  
	  var selEndTimeMin = document.createElement('select');
	  selEndTimeMin.name = 'endTimeMin' + iteration;
	  selEndTimeMin.className = 'h3';
	  selEndTimeMin.options[0] = new Option('Min', 'Min');
	  selEndTimeMin.options[1] = new Option('1', '1');
      selEndTimeMin.options[2] = new Option('2', '2');
	  selEndTimeMin.options[3] = new Option('3', '3');
	  selEndTimeMin.options[4] = new Option('4', '4');
	  selEndTimeMin.options[5] = new Option('5', '5');
	  selEndTimeMin.options[6] = new Option('6', '6');
	  selEndTimeMin.options[7] = new Option('7', '7');
	  selEndTimeMin.options[8] = new Option('8', '8');
	  selEndTimeMin.options[9] = new Option('9', '9');
	  selEndTimeMin.options[10] = new Option('10', '10');
	  selEndTimeMin.options[11] = new Option('11', '11');
	  selEndTimeMin.options[12] = new Option('12', '12');
	  selEndTimeMin.options[13] = new Option('13', '13');
	  selEndTimeMin.options[14] = new Option('14', '14');
	  selEndTimeMin.options[15] = new Option('15', '15');
	  selEndTimeMin.options[16] = new Option('16', '16');
	  selEndTimeMin.options[17] = new Option('17', '17');
	  selEndTimeMin.options[18] = new Option('18', '18');
	  selEndTimeMin.options[19] = new Option('19', '19');
	  selEndTimeMin.options[20] = new Option('20', '20');
	  selEndTimeMin.options[21] = new Option('21', '21');
	  selEndTimeMin.options[22] = new Option('22', '22');
	  selEndTimeMin.options[23] = new Option('23', '23');
	  selEndTimeMin.options[24] = new Option('24', '24');
	  selEndTimeMin.options[25] = new Option('25', '25');
	  selEndTimeMin.options[26] = new Option('26', '26');
	  selEndTimeMin.options[27] = new Option('27', '27');
	  selEndTimeMin.options[28] = new Option('28', '28');
	  selEndTimeMin.options[29] = new Option('29', '29');
	  selEndTimeMin.options[30] = new Option('30', '30');
	  selEndTimeMin.options[31] = new Option('31', '31');
	  selEndTimeMin.options[32] = new Option('32', '32');
	  selEndTimeMin.options[33] = new Option('33', '33');
	  selEndTimeMin.options[34] = new Option('34', '34');
	  selEndTimeMin.options[35] = new Option('35', '35');
	  selEndTimeMin.options[36] = new Option('36', '36');
	  selEndTimeMin.options[37] = new Option('37', '37');
	  selEndTimeMin.options[38] = new Option('38', '38');
	  selEndTimeMin.options[39] = new Option('39', '39');
	  selEndTimeMin.options[40] = new Option('40', '40');
	  selEndTimeMin.options[41] = new Option('41', '41');
	  selEndTimeMin.options[42] = new Option('42', '42');
	  selEndTimeMin.options[43] = new Option('43', '43');
	  selEndTimeMin.options[44] = new Option('44', '44');
	  selEndTimeMin.options[45] = new Option('45', '45');
	  selEndTimeMin.options[46] = new Option('46', '46');
	  selEndTimeMin.options[47] = new Option('47', '47');
	  selEndTimeMin.options[48] = new Option('48', '48');
	  selEndTimeMin.options[49] = new Option('49', '49');
	  selEndTimeMin.options[50] = new Option('50', '50');
	  selEndTimeMin.options[51] = new Option('51', '51');
	  selEndTimeMin.options[52] = new Option('52', '52');
	  selEndTimeMin.options[53] = new Option('53', '53');
	  selEndTimeMin.options[54] = new Option('54', '54');
	  selEndTimeMin.options[55] = new Option('55', '55');
	  selEndTimeMin.options[56] = new Option('56', '56');
	  selEndTimeMin.options[57] = new Option('57', '57');
	  selEndTimeMin.options[58] = new Option('58', '58');
	  selEndTimeMin.options[59] = new Option('59', '59');
	  selEndTimeMin.options[60] = new Option('60', '60');
	  
	  
	  cellSelEndTime.appendChild(selEndTime);
	  cellSelEndTime.appendChild(selEndTimeMin);


	  // right cell
	  var fromLocation = row.insertCell(4);
	  var el = document.createElement('input');
	  el.type = 'text';
	  el.className = 'h3';
	  el.name = 'from_location' + iteration;
	  el.id = 'from_location' + iteration;
	  el.size = 25;
	
	  fromLocation.appendChild(el);
	  
	  var toLocation = row.insertCell(5);
	  var el = document.createElement('input');
	  el.type = 'text';
	  el.className = 'h3';
	  el.name = 'to_location' + iteration;
	  el.id = 'to_location' + iteration;
	  el.size = 25;

	  toLocation.appendChild(el);
	  
	  document.frmTransferBooking.row_value.value = iteration;
	}
	function removeRowFromTable()
	{
	  var tbl = document.getElementById('tblTransfer');
	  var lastRow = tbl.rows.length;
	  if (lastRow > 2) tbl.deleteRow(lastRow - 1);
	}
	
	
	function TotalRow()
	{
	  var tbl = document.getElementById('tblTransfer');
	  var TotalRows = tbl.rows.length;
	  return TotalRows;
	}

   /*******************************************************/
   /**Validae Decorations Page*/
    function Validate_Decorations_Oncheck(flowercount){
 	   //synthetic Flowers
	   var count = 0;
	   var syntheticflowers = "",flowerimages="";
 		for(var i=1;i<=flowercount;i++){
				var ctrl = "synthetic_"+i;
  				if(document.getElementById(ctrl).checked==true){
					    count++;
 				}
				if(count>3){
 					document.getElementById(ctrl).checked = false;
					return false;
					
				}
		}
		 
	}
   function Validate_Decorations(flowercount,decocount){
	   //Typfe of flower	   
	  if(document.decoration_form.flower_op_type[0].checked==true){
		   document.decoration_form.flower_type.value = document.decoration_form.flower_op_type[0].value;
	  } else if(document.decoration_form.flower_op_type[1].checked==true){ 
	  	   document.decoration_form.flower_type.value = document.decoration_form.flower_op_type[1].value;
	  }
	  
	   //synthetic Flowers
	   var count = 0;
	   var syntheticflowers = "",flowerimages="";
 		for(var i=1;i<=flowercount;i++){
				var ctrl = "synthetic_"+i;
				var imgctrl = "synthetic_img_"+i;
 				if(document.getElementById(ctrl).checked==true){
					    count++;
 						if(syntheticflowers!=""){
							syntheticflowers = syntheticflowers+","+document.getElementById(ctrl).value;
							flowerimages     = flowerimages+","+document.getElementById(imgctrl).value ;
						} else {
							syntheticflowers = document.getElementById(ctrl).value;	
							flowerimages = document.getElementById(imgctrl).value;	
						}					
				}
		}
		if(count>3){
			alert("You can only select 3 flower color");
			return false;
			
		}
		document.getElementById("syntheticflowers").value = syntheticflowers;
		document.getElementById("flowerimages").value = flowerimages;
		//alert(document.getElementById("flowerimages").value);
		//Ribbon
		var ribbonoptions =  document.decoration_form.ribbon.length;
  		for (var i=0; i<ribbonoptions; i++)  
  		{  
			if(document.decoration_form.ribbon[i].checked==true){	
				var ribbonarray = document.decoration_form.ribbon[i].value.split("#");
				document.getElementById("ribbonname").value = ribbonarray[0];
				document.getElementById("ribbonimage").value = ribbonarray[1];
			}
		}
		//decoration
		var deccnt = 0;
		var decoration = "",decorationimages="";
		for(var i=1;i<=decocount;i++){
				var ctrl = "deco_"+i;
				var imgctrl = "deco_img_"+i;
				
				if(document.getElementById(ctrl).checked==true){
						deccnt++;
						if(decoration!=""){
							decoration = decoration+","+document.getElementById(ctrl).value;
							decorationimages = decorationimages+","+document.getElementById(imgctrl).value;
						} else {
							decoration = document.getElementById(ctrl).value;
							decorationimages = document.getElementById(imgctrl).value;
						}
				}
		}
		if(deccnt>=2){
			alert("You can any one decoration design");
			return false;
			
		}
		document.getElementById("decoration").value = decoration;
		document.getElementById("decorationimages").value = decorationimages;
		//alert(document.getElementById("decorationimages").value);
  		
		if(document.getElementById("flower_type").value=="" && document.getElementById("syntheticflowers").value=="" && 
		   document.getElementById("ribbonname").value=="" && document.getElementById("decoration").value==""){
 				alert("Please select any of the decorations options");
				return false;
		}
		window.open('decoration_popup_form.php?flower_type='+document.decoration_form.flower_type.value+'&flowerimages='+document.decoration_form.flowerimages.value +'&syntheticflowers='+document.decoration_form.syntheticflowers.value +'&ribbonimage='+document.decoration_form.ribbonimage.value+'&ribbonname='+document.decoration_form.ribbonname.value+'&decoration='+document.decoration_form.decoration.value+'&decorationimages='+document.decoration_form.decorationimages.value,'decorationWindow','width=630,height=680');
   }
   
   function friend_validation() {
		if(TextValidate(document.frmFriend.sender_name,'Sender Name')==false) return false;	
		if(EmailValidate(document.frmFriend.sender_email,"Sender Email Address")==false){return false;}	
		if(TextValidate(document.frmFriend.recipient_name,'Recipient Name')==false) return false;	
		if(EmailValidate(document.frmFriend.recipient_email,"Recipient Email Address")==false){return false;}	

		document.frmFriend.action = "thank.php?booking=friend";
		document.frmFriend.submit();
 	}
	function validateSearch(){
		if(OptValidate(document.frmsearch.car_price_duration,'Weekday or Weekend or Weekend Block')==false) {
			return false;	
		} else {
			document.frmsearch.action = "weddingcar-search.php";
			document.frmsearch.submit();
		}
	}
	
	function terms_self(){
		document.frmCarBooking.action = "terms_conditions.php";
		document.frmCarBooking.submit();
	}
	function terms_chauffer(){
		document.frmCarBooking.action = "terms_conditions_chauffer.php";
		document.frmCarBooking.submit();
	}
	
	function terms_trans(){
		document.frmTransferBooking.action = "terms_conditions2.php";
		document.frmTransferBooking.submit();
	}
