// JavaScript Document

function makeObject(){
	var x; 
	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer"){
		x = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		x = new XMLHttpRequest();
	}
	
	return x;
}
function refresh_main_page(){
	opener.location.reload();
	return true;
	
}

var request = makeObject();
var md="";
var popupwindow;
function details(ls,ne){
	
	if((ls=="add_location_cat")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=400,scrollbars=yes');}
	if((ls=="add_tour_cat")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=400,scrollbars=yes');}
	
	if(ls=="edit_tourcat"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=140,width=435,scrollbars');}
	if(ls=="delete_tourcat"){popupwindow=window.open('delete_tourcat.php?val='+ne,'popup','height=140,width=420,scrollbars');}
	
	if(ls=="edit_location_cat"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=140,width=435,scrollbars');}
	if(ls=="delete_location_cat"){popupwindow=window.open('delete_location_cat.php?val='+ne,'popup','height=140,width=420,scrollbars');}
	
	if((ls=="add_location")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_location"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,status=yes,scrollbars');}
	if(ls=="delete_location"){popupwindow=window.open('delete_location.php?val='+ne,'popup','height=700,width=750,scrollbars');}
	
	if((ls=="add_activity")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_activity"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,status=yes,scrollbars');}
	if(ls=="delete_activity"){popupwindow=window.open('delete_activity.php?val='+ne,'popup','height=700,width=750,scrollbars');}
	if((ls=="set_top")||(ls=="remove_top")){popupwindow=window.open('set_top.php?val='+ne+'','popup','height=250,width=500,status=yes,scrollbars');}
	if((ls=="set_priority")){popupwindow=window.open('set_priority.php?val='+ne+'','popup','height=250,width=500,status=yes,scrollbars');}
	
	if((ls=="add_budget")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=400,status=yes,scrollbars=yes');}
	if(ls=="edit_budget"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=140,width=435,scrollbars');}
	if(ls=="delete_budget"){popupwindow=window.open('delete_budget.php?val='+ne,'popup','height=140,width=420,scrollbars');}
	
	if((ls=="add_hotel_cat")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=400,status=yes,scrollbars=yes');}
	if(ls=="edit_hotel_cat"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=140,width=435,scrollbars');}
	if(ls=="delete_hotel_cat"){popupwindow=window.open('delete_hotel_cat.php?val='+ne,'popup','height=140,width=420,scrollbars');}
	
	if((ls=="add_hotel")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,status=yes,scrollbars=yes');}
	if(ls=="edit_hotel"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,status=yes,scrollbars');}
	if(ls=="delete_hotel"){popupwindow=window.open('delete_hotel.php?val='+ne,'popup','height=900,width=800,scrollbars');}
	
	if((ls=="add_holiday_idea")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_holiday_idea"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,status=yes,scrollbars');}
	if(ls=="delete_holiday_idea"){popupwindow=window.open('delete_holiday_idea.php?val='+ne,'popup','height=700,width=750,scrollbars');}
	
	if((ls=="add_sp_offer")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,status=yes,scrollbars=yes');}
	if(ls=="edit_sp_offer"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,scrollbars');}
	if(ls=="delete_sp_offer"){popupwindow=window.open('delete_sp_offer.php?val='+ne,'popup','height=900,width=800,scrollbars');}
	if(ls=="add_top"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=650,width=470,scrollbars,status');}
	
	
	if((ls=="add_tour")&&(ne=="no")){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_tour"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,status=yes,scrollbars');}
	if(ls=="delete_tour"){popupwindow=window.open('delete_tour.php?val='+ne,'popup','height=900,width=800,scrollbars');}

	if(ls=="edit_day"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=900,width=800,scrollbars');}
	if(ls=="delete_day"){popupwindow=window.open('delete_day.php?val='+ne,'popup','height=900,width=800,scrollbars');}
	
	if(ls=="add_suggested"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=200,width=425,scrollbars,status');}
	
	if(ls=="add_user"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=400,scrollbars=yes');}
	if(ls=="edit_user"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=250,width=400,scrollbars');}
	if(ls=="delete_user"){popupwindow=window.open('delete_user.php?val='+ne,'popup','height=250,width=400,scrollbars');}
	
	if(ls=="edit_home"){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_aboutus"){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_contact"){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="edit_lanka"){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	
	if(ls=="edit_index"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_destination"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_hotel_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_tour_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_activity_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_aboutus_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_contact_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_offer_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	if(ls=="edit_holiday_page"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=440,scrollbars=yes');}
	
	if(ls=="rate_hotel"){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="rate_tour"){popupwindow=window.open(ls+'.php','popup','status=yes,height=900,width=800,scrollbars=yes');}
	
	if(ls=="add_pdf_file"){popupwindow=window.open(ls+'.php','popup','status=yes,height=250,width=500,scrollbars=yes');}
	if(ls=="view_files"){popupwindow=window.open(ls+'.php?val='+ne,'popup','status=yes,height=250,width=400,scrollbars=yes');}
	if(ls=="delete_files"){popupwindow=window.open('delete_files.php?val='+ne,'popup','height=250,width=440,scrollbars');}
	
	if(ls=="view_upload"){popupwindow=window.open(ls+'.php?val='+ne,'popup','status=yes,height=250,width=400,scrollbars=yes');}
	/*
	if(ls=="edit_files"){popupwindow=window.open(ls+'.php?val='+ne+'','popup','height=140,width=435,scrollbars');}
	if(ls=="delete_files"){popupwindow=window.open('delete_files.php?val='+ne,'popup','height=140,width=420,scrollbars');}*/
	popupwindow.focus();
}
function details2(ls,id,day){
	if(ls=="add_day"){popupwindow=window.open('add_day.php?days='+day+'&t_id='+id+'','popup','status=yes,height=900,width=800,scrollbars=yes');}
	if(ls=="day_tour"){popupwindow=window.open('day_tour.php?days='+day+'&t_id='+id+'','popup','status=yes,height=900,width=840,scrollbars=yes');}
	popupwindow.focus();
}
/*function details2(ls,day,id){
	if(ls=="add_day"){popupwindow=window.open(ls+'.php?days='+day+'&t_id='+id+'','popup','status=yes,height=900,width=800,scrollbars=yes');}
	popupwindow.focus();
}*/
function show_large(ne){
	popupwindow=window.open('view_large.php?val='+ne,'popup','height=600,width=600,scrollbars=yes');
	popupwindow.focus();
}
function show_large2(ne){
	popupwindow=window.open('view_large2.php?val='+ne,'popup','height=600,width=600,scrollbars=yes');
	popupwindow.focus();
}


//**************************** image delete *********************************************

function delete_image(tb,id,name){
	if (confirm('Are you sure you want to delete this image')){
	//confirm('Are you sure you want to delete this image'){
		request.open('get','process.php?val=delete_image&tb='+tb+'&id='+id+'&name='+name);
		request.onreadystatechange = del_img; 
		request.send('');
	}
}

function del_img(){
	
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";	
	}
	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="&nbsp;";

    	if (request.status == 200) {
			if(request.responseText!=""){
					alert(request.responseText);
					location.reload();
					
				}
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}
/*function retop_hotel(id){
	if (confirm("Do you want to remove this hotel from the top 6 ?")){
	request.open('get','../process.php?val=retop_hotel&id='+id);
	request.onreadystatechange = chk_top; 
	request.send('');
	}
}
*/
// **********************************   login functions	 **********************************************
function frontlogin_submit(){
	//alert(document.user_login.username.value);
	if((chk_empty(document.user_login.front_username))&&(chk_empty(document.user_login.front_password))){
		document.user_login.action="admin/process.php?frval=frontlogin";
		document.user_login.submit();
	}
	
	else{
	return false;
	}
}
//************** Add User ********************************
function add_user(){
	if(chk_empty(document.adduser.user_companyname)&&(chk_empty(document.adduser.user_email))&&(is_selected(document.adduser.user_level))&&(checkFormPw(document.adduser.user_username,document.adduser.user_password,document.adduser.user_repassword))){
			document.adduser.action="process.php?val=ADD_USER";
			document.adduser.submit();
			return true;
	}
	else{return false;}	
}
function edit_user(){
	if(chk_empty(document.edituser.edit_name)&&(chk_empty(document.edituser.edit_mail))&&(is_selected(document.edituser.edit_level))){
			document.edituser.action="process.php?val=EDIT_USER";
			document.edituser.submit();
			return true;
	}
	else{return false;}	
}
function delete_user(){
	document.deleteuser.action="process.php?val=DELETE_USER";
	document.deleteuser.submit();
	return true;
}
//************** Add Contact **************************

function add_contacts(){
	
	
	if((chk_empty(document.contact.contact_Name))&&(chk_empty(document.contact.contact_Email))&&(chk_empty(document.contact.contact_phn))&&(chk_empty(document.contact.contact_inquiry))){
	document.contact.action="process.php?val=send_mail";
	document.contact.submit();
	return true;
	}
	else{return false;}
}
//**************** Add Query Hotel******************************
function add_query_hotel(){
	
	if((chk_empty(document.contact.contact_title))&&(chk_empty(document.contact.contact_Name))&&(chk_empty(document.contact.contact_Email))&&(chk_empty(document.contact.contact_phn))&&(chk_empty(document.contact.contact_inquiry))){
	document.contact.action="process.php?val=send_query_hotel";
	document.contact.submit();
	return true;
	}
	else{return false;}
}
//**************** Add Query Tour******************************
function add_query_tour(){
	
	if((chk_empty(document.contact.contact_title))&&(chk_empty(document.contact.contact_Name))&&(chk_empty(document.contact.contact_Email))&&(chk_empty(document.contact.contact_phn))&&(chk_empty(document.contact.contact_inquiry))){
	document.contact.action="process.php?val=send_query_tour";
	document.contact.submit();
	return true;
	}
	else{return false;}
}
//**************** Add Query Special Offer******************************
function add_query_offer(){
	
	if((chk_empty(document.contact.contact_title))&&(chk_empty(document.contact.contact_Name))&&(chk_empty(document.contact.contact_Email))&&(chk_empty(document.contact.contact_phn))&&(chk_empty(document.contact.contact_inquiry))){
	document.contact.action="process.php?val=send_query_offer";
	document.contact.submit();
	return true;
	}
	else{return false;}
}
//************** location_cat *****************************
function add_location_cat1(){
	if(chk_empty(document.add_location_cat.location_category)){
			document.add_location_cat.action="process.php?val=ADD_CAT";
			document.add_location_cat.submit();
			return true;
	}
	else{return false;}	
}
function edit_cat_name(){
	if(chk_empty(document.edit_cat.cat_name)){
			document.edit_cat.action="process.php?val=EDIT_CAT";
			document.edit_cat.submit();
			return true;
	}
	else{return false;}	
}
function delete_cat1(){
	document.delete_cat.action="process.php?val=DELETE_CAT";
	document.delete_cat.submit();
	return true;
}

function set_topact(){
	//alert(document.settop.order);
	if(is_selected1(document.settop.order,document.settop.mgs)){
	document.settop.action="process.php?val=SET_TOP";
	document.settop.submit();
	return true;
	}
	else{return false;}	
}
function set_topact2(bx){
	request.open('get', 'process.php?val=chk_priority&number='+bx.value);
	request.onreadystatechange = chk_priority; 
	request.send('');	
}
function chk_priority(){
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		document.all.aj_button.disabled="Disabled";
		
	}
	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="&nbsp;";
		document.all.aj_button.disabled=false;
    	if (request.status == 200) {
				if(request.responseText!=""){
					document.activeElement.select();
					document.all.aj_button.disabled="Disabled";
					alert(request.responseText);
				}
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}	


function set_priority(){

	document.setpriority.action="process.php?val=SET_PRIORITY";
	document.setpriority.submit();
	return true;
}
function remove_top(){
	document.settop.action="process.php?val=REMOVE_TOP";
	document.settop.submit();
	return true;
}
//********************** Location ***********************
function add_location(){
	if((chk_empty(document.addlocation.location_name))&&(chk_empty_new(document.addlocation.location_colombo,document.addlocation.colombo_mgs))&&(chk_empty_new(document.addlocation.location_airport,document.addlocation.airport_mgs))&&(chk_empty(document.addlocation.location_duration))&&(chk_empty(document.addlocation.location_mainimage))&&(chk_empty(document.addlocation.location_map))){
		
		if (document.getElementById('location_mainimage').value!=""){
			var filename = document.getElementById('location_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		if (document.getElementById('location_map').value!=""){
			var filename = document.getElementById('location_map').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<11; x++){
			var name='location_image'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    }
						
					} 
			}
			 if (all_jpg!=0){	
			document.addlocation.action="process.php?val=ADD_LOCATION";
			document.addlocation.submit();
			return true;
	     }
	}
	else{return false;}	
}
function edit_location1(){
	
	if((chk_empty(document.edit_location.edit_name))){
	
		if (document.getElementById('edit_main_image').value!=""){
			
			var filename = document.getElementById('edit_main_image').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg main image is invalid "); 
				return ;
				} 
		}
		if (document.getElementById('edit_map').value!=""){
		
			var filename = document.getElementById('edit_map').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<11; x++){
			var name='location_image'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    }
						
					} 
			}
			 if (all_jpg!=0){	
			document.edit_location.action="process.php?val=EDIT_LOCATION";
			document.edit_location.submit();
			return true;
			 }
	}
	else{return false;}	
}
function delete_location1(){
	document.delete_location.action="process.php?val=DELETE_LOCATION";
	document.delete_location.submit();
	return true;
}

//*********************** Activity ******************************
function add_act(){
	if((chk_empty(document.addact.act_name))&&(is_selected(document.addact.act_base))&&(chk_empty(document.addact.act_mainimage))){
		if (document.getElementById('act_mainimage').value!=""){
			var filename = document.getElementById('act_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		if (document.getElementById('act_map').value!=""){
			var filename = document.getElementById('act_map').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<11; x++){
			var name='act_image'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    }
						
					} 
			}
			 if (all_jpg!=0){	
			document.addact.action="process.php?val=ADD_ACTIVITY";
			document.addact.submit();
			return true;
			 }
	}
	else{return false;}	
}
function edit_act1(){
	if((chk_empty(document.edit_act.edit_title))){
		if (document.getElementById('edit_mainimage').value!=""){
			var filename = document.getElementById('edit_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		if (document.getElementById('edit_map').value!=""){
			var filename = document.getElementById('edit_map').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<11; x++){
			var name='addphoto_img'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    }
						
					} 
			}
			 if (all_jpg!=0){	
			document.edit_act.action="process.php?val=EDIT_ACTIVATE";
			document.edit_act.submit();
			return true;
	   }
	}
	else{return false;}	
}
function delete_activity(){
	document.delete_act.action="process.php?val=DELETE_ACTIVITY";
	document.delete_act.submit();
	return true;
}
//*********************  Budget Range  **********************
function add_budget1(){
	if(chk_empty(document.addbudget.add_budget)){
			document.addbudget.action="process.php?val=ADD_BUDGET";
			document.addbudget.submit();
			return true;
	}
	else{return false;}	
}
function edit_budget1(){
	if(chk_empty(document.editbudget.edit_budget)){
			document.editbudget.action="process.php?val=EDIT_BUDGET";
			document.editbudget.submit();
			return true;
	}
	else{return false;}	
}
function delete_budget1(){
	document.deletebudget.action="process.php?val=DELETE_BUDGET";
	document.deletebudget.submit();
	return true;
}
//*********************  Hotel Category  **********************
function add_hotel_cat1(){
	if(chk_empty(document.add_hotel_cat.addcat_name)){
			document.add_hotel_cat.action="process.php?val=ADD_HOTEL_CAT";
			document.add_hotel_cat.submit();
			return true;
	}
	else{return false;}	
}
function edit_hotel_cat1(){
	if(chk_empty(document.edit_hotel_cat.addcat_name)){
			document.edit_hotel_cat.action="process.php?val=EDIT_HOTEL_CAT";
			document.edit_hotel_cat.submit();
			return true;
	}
	else{return false;}	
}
function delete_hotel_cat1(){
	document.delete_hotel_cat.action="process.php?val=DELETE_HOTEL_CAT";
	document.delete_hotel_cat.submit();
	return true;
}
//*********************** Hotel  *******************************


function edit_hotel1(){
	//alert("asdas");
	if((chk_empty(document.edit_hotel.edit_name))&&(is_selected(document.edit_hotel.edit_location))){
		if (document.getElementById('edit_main_image').value!=""){
			var filename = document.getElementById('edit_main_image').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<11; x++){
			var name='addphoto_img'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    }
						
					} 
			}
			 if (all_jpg!=0){	
			document.edit_hotel.action="process.php?val=EDIT_HOTEL";
			document.edit_hotel.submit();
			return true;
			 }
	}
	else{return false;}	
}



function add_hotel(){
	if((chk_empty(document.addhotel.hotel_name))&&(is_selected(document.addhotel.hotel_location))&&(chk_empty(document.addhotel.hotel_mainimage))&&(chk_empty(document.addhotel.hotel_image1))){
		if (document.getElementById('hotel_mainimage').value!=""){
			var filename = document.getElementById('hotel_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  main image is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<11; x++){
			var name='hotel_image'+x;
			/*alert(name);*/
				if (document.getElementById(name).value==""){
					img1_emty=0;
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	   
						return false; 
						}
					} 
			}
			
			
		if (document.getElementById('hotel_file').value!=""){
		var filename = document.getElementById('hotel_file').value;
		var fileext = filename.substring(filename.lastIndexOf('.')+1);
		
		var b = String(fileext).toUpperCase();
			 if ((b != 'DOC')&&(b != 'PDF')&&(b != 'JPG')&&(b != 'DOCX')) {
				alert ("You can only upload  .doc & .pdf files  fact sheet is invalid "); 
			    return ;
			} 
		}
		
		var i=1;
		var all_doc=1;
		var img1_emty=1;
		for( x=1; x<3; x++){
			var name='hotel_rate'+x;
			//if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			//}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);				
						var b = String(fileext).toUpperCase();
						//alert(b);
					 if ((b != 'DOC')&&(b != 'PDF')&&(b != 'JPG')&&(b != 'DOCX')) {
						  all_doc=0;
						alert("You can only upload  .doc & .pdf files , File \'"+name+"\' is invalid ");
						return false;
						
						}
						
					} 
			}
			if ((all_jpg!=0)&&(all_doc!=0)){	
			document.addhotel.action="process.php?val=ADD_HOTEL";
			document.addhotel.submit();
			return true;
			 }
	}
	else{return false;}	
}

function delete_hotel(){
	document.delete_location.action="process.php?val=DELETE_HOTEL";
	document.delete_location.submit();
	return true;
}
//*********************** Holiday Ideas ******************************
function add_holiday(){
	if((chk_empty(document.addholiday.holiday_name))&&(chk_empty(document.addholiday.holiday_image1))){
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<5; x++){
			var name='holiday_image'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    }
						
					} 
			}
			 if (all_jpg!=0){	
			document.addholiday.action="process.php?val=ADD_HOLIDAY";
			document.addholiday.submit();
			return true;
			 }
	}
	else{return false;}	
}
function edit_holiday1(){
	if((chk_empty(document.edit_holiday.edit_title))){
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<5; x++){
			var name='addphoto_img'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	  
						}
						
					} 
			}
			 if (all_jpg!=0){
			document.edit_holiday.action="process.php?val=EDIT_HOLIDAY";
			document.edit_holiday.submit();
			return true;
			 }
	}
	else{return false;}	
}
function delete_holiday1(){
	document.delete_holiday.action="process.php?val=DELETE_HOLIDAY";
	document.delete_holiday.submit();
	return true;
}
//*********************** Special Offer  *******************************
function add_offer(){
	if((chk_empty(document.addoffer.offer_name))&&(chk_empty(document.addoffer.offer_mainimage))){
		if (document.getElementById('offer_mainimage').value!=""){
			var filename = document.getElementById('offer_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<7; x++){
			var name='offer_image'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	    
						}
						
					} 
			}
			
		
			 if (all_jpg!=0){	
			document.addoffer.action="process.php?val=ADD_OFFER";
			document.addoffer.submit();
			return true;
			 }
	}
	else{return false;}	
}
function edit_offer1(){
	if((chk_empty(document.edit_offer.edit_name))){
		if (document.getElementById('edit_main_image').value!=""){
			var filename = document.getElementById('edit_main_image').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<7; x++){
			var name='addphoto_img'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid "); }
						
					} 
			}
			 if (all_jpg!=0){
			document.edit_offer.action="process.php?val=EDIT_OFFER";
			document.edit_offer.submit();
			return true;
			 }
	}
	else{return false;}	
}
function delete_offer1(){
	document.delete_offer.action="process.php?val=DELETE_OFFER";
	document.delete_offer.submit();
	return true;
}
//*********************** Tours ******************************
function add_tourcat(){
	
	
	if(chk_empty(document.add_tour_cat.tour_category)){
			document.add_tour_cat.action="process.php?val=ADD_TOURCAT";
			document.add_tour_cat.submit();
			return true;
	}
	else{return false;}	
}


function edit_cat_tour(){	
	if(chk_empty(document.edit_cat.cat_name)){
			document.edit_cat.action="process.php?val=EDIT_TOURCAT";
			document.edit_cat.submit();
			return true;
	}
	else{return false;}	
}

function delete_tourcat(){
	document.delete_tour_cat.action="process.php?val=DELETE_TOUR_CAT";
	document.delete_tour_cat.submit();
	return true;
}
//*********************** Tour cats ******************************

function add_tour(ax){
	var day=ax.value;
	if((chk_empty(document.addtour.tour_name))&&(is_selected(document.addtour.tour_days))&&(chk_empty(document.addtour.tour_mainimage))){
		if (document.getElementById('tour_mainimage').value!=""){
			var filename = document.getElementById('tour_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  tour main image is invalid "); 
				return ;
				} 
		}
		
		if (document.getElementById('tour_map').value!=""){
			var filename = document.getElementById('tour_map').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  tour map is invalid "); 
				return ;
				} 
		}		
		if (document.getElementById('tour_file').value!=""){
			var filename = document.getElementById('tour_file').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			
			var b = String(fileext).toUpperCase();
				 if ((b != 'DOC')&&(b != 'PDF')&&(b != 'JPG')&&(b != 'DOCX')) {
					alert ("You can only upload  .doc & .pdf files  fact sheet is invalid "); 
				return ;
				} 
		}
		
		var i=1;
		var all_doc=1;
		var img1_emty=1;
		for( x=1; x<3; x++){
			var name='tour_rate'+x;
			//if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			//}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);				
						var b = String(fileext).toUpperCase();
						//alert(b);
					 if ((b != 'DOC')&&(b != 'PDF')&&(b != 'JPG')&&(b != 'DOCX')) {
						  all_doc=0;
						alert("You can only upload  .doc & .pdf files , File \'"+name+"\' is invalid ");
						return false;
						
						}
						
					} 
			}
	     
		 if (all_doc!=0){	
			document.addtour.action="process.php?val=ADD_TOURS&day="+day+"";
			document.addtour.submit();
			return true;
			 }
	}
	else{return false;}	
}
function delete_tour1(){
	document.delete_tour.action="process.php?val=DELETE_TOUR";
	document.delete_tour.submit();
	return true;
}
function set_suggested(){
	
	document.sugest_tour.action="process.php?val=SET_SUGGEST";
	document.sugest_tour.submit();
	
}
function edit_tour1(){
	if((chk_empty(document.edit_day.edit_title))&&(is_selected(document.edit_day.edit_days))&&(chk_empty(document.edit_day.edit_mainimage))){
		if (document.getElementById('edit_mainimage').value!=""){
			var filename = document.getElementById('edit_mainimage').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		if (document.getElementById('edit_map').value!=""){
			var filename = document.getElementById('edit_map').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'JPG')) {
				alert ("You can only upload .jpg & .jpeg images  brand logo is invalid "); 
				return ;
				} 
		}
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<10; x++){
			var name='addphoto_img'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	
						}
						
					} 
			}
			 if (all_jpg!=0){	
			document.edit_day.action="process.php?val=EDIT_TOUR";
			document.edit_day.submit();
			return true;
			 }
	}
	else{return false;}	
}
//********************** Tour Day ******************************
function add_day1(){
	if(chk_empty(document.add_day.day_title)){
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<4; x++){
			var name='day_image'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	  
						}
						
					} 
			}
			 if (all_jpg!=0){	
			document.add_day.action="process.php?val=ADD_DAY";
			document.add_day.submit();
			return true;
			 }
	}
	else{return false;}	
}
function edit_day1(){
	if((chk_empty(document.edit_day.edit_title))){
		var i=1;
		var all_jpg=1;
		var img1_emty=1;
		for( x=1; x<4; x++){
			var name='addphoto_img'+x;
			if(x==1){
				if (document.getElementById(name).value==""){
					img1_emty=0;
				}
				
			}
			if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);
											
						var b = String(fileext).toUpperCase();
					 if ((b != 'JPG')) {
						  all_jpg=0;
						alert("You can only upload .jpg & .jpeg images , Image \'"+name+"\' is invalid ");                 	   
						}
						
					} 
			}
			 if (all_jpg!=0){	
			document.edit_day.action="process.php?val=EDIT_DAY";
			document.edit_day.submit();
			return true;
			 }
	}
	else{return false;}	
}
function delete_day1(){
	document.delete_day.action="process.php?val=DELETE_DAY";
	document.delete_day.submit();
	return true;
}
//************** Top of special Offer **********************
function set_top(){
	document.top_offer.action="process.php?val=set_top";
	document.top_offer.submit();
}
//************** PDF Files *****************************
function add_file1(){
	if((chk_empty(document.addfile.file_file))&&(chk_empty(document.addfile.file_title))){
		var all_doc=1;
		var name='file_file';
		if (document.getElementById(name).value!=""){
					  var filename = document.getElementById(name).value;
					  var fileext = filename.substring(filename.lastIndexOf('.')+1);				
						var b = String(fileext).toUpperCase();
						//alert(b);
					 if (b != 'PDF'){
						  all_doc=0;
						alert("You can only upload   .pdf files , File type is invalid ");
						return false;
						
						}
						
					} 
			
			if (all_doc!=0){	
			document.addfile.action="process.php?val=ADD_FILE";
			document.addfile.submit();
			 }
	}
	else{return false;}	
}
function edit_file1(){
	if(chk_empty(document.editfile.file_name)){
			document.editfile.action="process.php?val=EDIT_FILE";
			document.editfile.submit();
			return true;
	}
	else{return false;}	
}
function delete_file1(){
	document.deletefile.action="process.php?val=DELETE_FILE";
	document.deletefile.submit();
	return true;
}
//********************* Search of pages *********************

function search_hotels(){

	document.get_hotels.submit();
}
function search_budget(){

	document.get_budget.submit();
}
function search_name(){
    var h_id=document.getname.hotel_id.value;
	document.getname.action="hotel_detail.php?hotel_id="+h_id;
	document.getname.submit();
}
function search_hotel_cat1(){
  
	document.get_cat1.submit();
}
function search_hotel_act(){
   //alert("cat");
	document.get_act1.submit();
}
function get_location(x){
    
	var name='myForm'+x;
	var loc_id=document.getElementById(name).loc_id.value;
	document.getElementById(name).action="location_detail.php?loc_id="+loc_id;
	/*document.getElementById(name).action="location_alpha.php";*/
	document.getElementById(name).submit();
	
}
function get_tour_list(){
	var t_id=document.gettour.tour_id.value;
	document.gettour.action="tour_details.php?tour_id="+t_id;
	/*document.gettour.action="process.php?val=tour_detail$tour_id=t_id";*/
	document.gettour.submit();
}
function get_tourcat_list(){
	document.gettourcat.submit();
}
function get_water_list(){
	var act_id=document.Base_Water.act_id.value;
	document.Base_Water.action="activity_detail.php?act_id="+act_id;
	document.Base_Water.submit();
}
function get_land_list(){
	var act_id=document.Base_Land.act_id.value;
	document.Base_Land.action="activity_detail.php?act_id="+act_id;
	document.Base_Land.submit();
}
//***********  display drop down of special offer page ******************
function display_hotel(){
	document.all.hotel.style.display="inline";
	
}
function hide_hotel(){
	document.all.hotel.style.display="none";
	
}
function display_tour(){
	document.all.tour.style.display="inline";
	
}
function hide_tour(){
	document.all.tour.style.display="none";
	
}
//*********************** edit pages *******************************
function edit_home1(){
			document.edit_home.action="process.php?val=EDIT_HOME";
			document.edit_home.submit();
			return true;
}
function edit_lanka1(){
			document.edit_lanka.action="process.php?val=EDIT_LANKA";
			document.edit_lanka.submit();
			return true;
}
function edit_aboutus1(){
			document.edit_about.action="process.php?val=EDIT_ABOUT";
			document.edit_about.submit();
			return true;
}
function edit_contact1(){
			document.edit_contact.action="process.php?val=EDIT_CONTACT";
			document.edit_contact.submit();
			return true;
}
//******************* Add Flash Banner  ************************
function add_index_banner(){
	if(chk_empty(document.addhome.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addhome.action="process.php?val=ADD_HOME_BANNER";
	document.addhome.submit();
		return true;
	}
	else{return false;}	
}
function add_loc_banner(){
	if(chk_empty(document.addloc.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addloc.action="process.php?val=ADD_LOC_BANNER";
	document.addloc.submit();
	return true;
	}
	else{return false;}	
}
function add_hotel_banner(){
	if(chk_empty(document.addhotel.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addhotel.action="process.php?val=ADD_HOTEL_BANNER";
	document.addhotel.submit();
	return true;
	}
	else{return false;}	
}
function add_tour_banner(){
	if(chk_empty(document.addtour.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addtour.action="process.php?val=ADD_TOUR_BANNER";
	document.addtour.submit();
	return true;
	}
	else{return false;}	
}

function add_act_banner(){
	if(chk_empty(document.addact.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addact.action="process.php?val=ADD_ACT_BANNER";
	document.addact.submit();
	return true;
	}
	else{return false;}	
}
function add_aboutus_banner(){
	if(chk_empty(document.addabout.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addabout.action="process.php?val=ADD_ABOUTUS_BANNER";
	document.addabout.submit();
	return true;
	}
	else{return false;}	
}
function add_contact_banner(){
	if(chk_empty(document.addcontact.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addcontact.action="process.php?val=ADD_CONTACT_BANNER";
	document.addcontact.submit();
	return true;
	}
	else{return false;}	
}
function add_offer_banner(){
	if(chk_empty(document.addoffer.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addoffer.action="process.php?val=ADD_OFFER_BANNER";
	document.addoffer.submit();
	return true;
	}
	else{return false;}	
}
function add_holiday_banner(){
	if(chk_empty(document.addholiday.add_flash)){
		if (document.getElementById('add_flash').value!=""){
			var filename = document.getElementById('add_flash').value;
			var fileext = filename.substring(filename.lastIndexOf('.')+1);
			var b = String(fileext).toUpperCase();
				if ((b != 'SWF')) {
				alert ("You can only upload .swf banners"); 
				return ;
				} 
		}
	document.addholiday.action="process.php?val=ADD_HOLIDAY_BANNER";
	document.addholiday.submit();
	return true;
	}
	else{return false;}	
}
//******************** display hidden areas***********************
function display_query(){
	document.all.hotel_query.style.display="inline";
	
}
//*********************** chk duplicate ***********************



function check_duplicate_cat(bx){
	request.open('get', 'process.php?val=chk_cat_name&prsn='+bx.value);
	request.onreadystatechange = chk_duplicate; 
	request.send('');	
}
function check_duplicate_hotel_cat(bx){
	
	request.open('get', 'process.php?val=chk_hotel_cat&prsn='+bx.value);
	request.onreadystatechange = chk_duplicate; 
	request.send('');	
}
function check_duplicate_username(bx){
	request.open('get', 'process.php?val=chk_username&user='+bx.value);
	request.onreadystatechange = chk_duplicateuser; 
	request.send('');	
}
function chk_duplicateuser(){
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		document.all.aj_button.disabled="Disabled";
		
	}
	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="&nbsp;";
		document.all.aj_button.disabled=false;
    	if (request.status == 200) {
				if(request.responseText!=""){
					document.activeElement.select();
					document.all.aj_button.disabled="Disabled";
					alert(request.responseText);
				}
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}	
function chk_duplicate(){
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		document.all.aj_button.disabled="Disabled";
		
	}
	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="&nbsp;";
		document.all.aj_button.disabled=false;
    	if (request.status == 200) {
			if(request.responseText!=""){
					document.activeElement.select();
					document.all.aj_button.disabled="Disabled";
					alert(request.responseText);
				}
				
				
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}
function check_no_of_days(ax,bx){
	request.open('get', 'process.php?val=chk_curent_days&days='+ax.value+'&add_day='+bx.value);
	request.onreadystatechange = chk_current_dates; 
	request.send('');	
}
function chk_current_dates(){
	//alert(request.responseText);
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		document.all.aj_button.disabled="Disabled";
		
	}
	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="&nbsp;";
		document.all.aj_button.disabled=false;
    	if (request.status == 200) {
			//current_password.focus();
				if(request.responseText!=""){
					alert(request.responseText);
					document.all.aj_button.value="Update";
					//document.new_password.focus();
					//document.activeElement.select();
					//document.all.aj_button.disabled="Disabled";
				}
				else{
					document.edit_tour.action="process.php?val=EDIT_TOUR";
	                document.edit_tour.submit();
				}
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}
function check_priority(ax){
    //alert(ax.value);
	request.open('get', 'process.php?val=chk_priority_no&num='+ax.value);
	request.onreadystatechange = chk_priority; 
	request.send('');	
}
function chk_priority(){
	//alert(request.responseText);
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		document.all.aj_button.disabled=true;
		
		
		
	}
	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="&nbsp;";
		//document.all.aj_button.disabled=false;
    	if (request.status == 200) {
				if(request.responseText!=""){
					document.all.aj_button.disabled=true;
					alert(request.responseText);
					
				}
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}

//*******************       Change Password     *************************

function change_pword(){
	
	document.password_form.action="process.php?val=CHANGE_PASSWORD";
	document.password_form.submit();
	return true;
}
//**************************  Common Validation to forms *******************************
function chk_empty(bx){
	if(bx.value==""){
		var nm=bx.name.split("_");
		var b_nm=nm[1].toUpperCase();
		alert("The field \'"+b_nm+"\' cannot be empty. Please enter a valid value");
		bx.focus();
		return false;
	}
	else{return true;}	
}
function chk_empty_new(bx,mgs){
	if(bx.value==""){
	
		alert(mgs.value);
		bx.focus();
		return false;
	}
	else{return true;}	
}
function checkEmail(cho) {
   if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(cho.value)){
   return (true);
   }
	alert("Invalid E-mail Address! Please re-enter.");
	cho.focus();
	return (false);
}
function is_selected(cbo){
	if(cbo.value=="EMPTY"){
		var nm=cbo.name.split("_");
		var b_nm=nm[1].toUpperCase();
		alert("The field \'"+b_nm+"\' cannot be empty. Please select one form the drop down");
		cbo.focus();
		return false;
	}
	else{return true;}	
}
function is_selected1(bx,mgs){
	if(bx.value=="EMPTY"){
	
		alert(mgs.value);
		bx.focus();
		return false;
	}
	else{return true;}	
}
function check_blood_type(cbo){
	if(document.blood_donate.blood_knw[0].checked==true){
		
		if(cbo.value=="EMPTY"){
		alert("Select your blood type");
		cbo.focus();
		return false;
		}
		else{return true;}	
	}
	else{return true;}	
}
function is_checked1(cbo){
	if(cbo.checked==false){
		alert("Select type you needed");
		cbo.focus();
		return false;
	}
	else{return true;}	
}
function checkFormPw(username,password,repassword)
  {
	
   if(username.value == "") {
      alert("Error: Username cannot be blank!");
      front_adduser.username.focus();
      return false;
    }
    re = /^\w+$/;
    if(!re.test(username.value)) {
      alert("Error: Username must contain only letters, numbers and underscores!");
     front_adduser.username.focus();
      return false;
    }
	if(username.value.length < 6) {
        alert("Error: Username must contain at least six characters!");
        front_adduser.username.focus();
        return false;
      }

    if(password.value != "" && password.value == repassword.value) {
      if(password.value.length < 6) {
        alert("Error: Password must contain at least six characters!");
        password.focus();
        return false;
      }
      if(password.value == username.value) {
        alert("Error: Password must be different from Username!");
        password.focus();
        return false;
      }
      
    } else {
      alert("Error: Please check that you've entered and confirmed your password!");
      password.focus();
      return false;
    }

    //alert("You entered a valid password: " + addemployer.addemployer_password.value);
    return true;
  }
