// JavaScript Document

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//# Validation Region #//

// change password validation

function changePwdvalidate()
{
	var form_name=document.frmpassword;
	if(TextValidate(form_name.old_password,"Old Password")==false){return false;}
	if(TextValidate(form_name.new_password,"New Password")==false){return false;}
	if(TextValidate(form_name.confirm_password,"Confirm Password")==false){return false;}
	if(Comparetextboxes(form_name.new_password,form_name.confirm_password)==false){return false;}
}

//To validate the portfolio large image record fields 

function productsimageValidate(){
	if(trimAll(document.frm_advertiseimage.products_image_largeimage.value) == "") {
		alert("Please browse the Image");
		document.frm_advertiseimage.products_image_largeimage.focus();		
		return false;	
	}
	if(trimAll(document.frm_advertiseimage.products_image_largeimage.value) != ""){
		if(File_Extentsion_Validate(document.frm_advertiseimage.products_image_largeimage," Image")== false){
			document.frm_advertiseimage.products_image_largeimage.focus();
			return false;
		}
	}	
	document.frm_advertiseimage.action = "products_largeimage.php";
	document.frm_advertiseimage.submit();	
}

function changeVoteOption(value) {
	window.location.href = "user-votes.php?voteoption="+value;	
}
function changeVoteOptionCMS(value,id) {
	window.location.href = "member.php?action=view&id="+id+"&voteoption="+value;	
}

//To validate the service record fields 

function pagecontentValidate(){
	var editor_id = tinyMCE.getInstanceById('txtacontent');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtacontent')),editor_id,"Please enter the Content")==false) {
		return false; 
	}			
	document.frmpagecontent.action = "pagecontent.php";
	document.frmpagecontent.submit();	
}

// To validate the Advertisement record fields
function advertiseValidate(){
  	Remove_Spaces(document.frm_advertise.txt_name)
	if(TextValidate(document.frm_advertise.txt_name,"the name")==false) {
		document.frm_advertise.txt_name.focus();		
		return false;	
	}	
	Remove_Spaces(document.frm_advertise.txt_email)
	if(EmailValidate(document.frm_advertise.txt_email,"the email")==false) {
		document.frm_advertise.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_advertise.txt_phone)
	if(TextValidate(document.frm_advertise.txt_phone,"the Phone Number")==false) {
		document.frm_advertise.txt_phone.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_advertise.txt_enquiry)
	if(TextAreaValidate(document.frm_advertise.txt_enquiry,"the Enquiry")==false) {
		document.frm_advertise.txt_enquiry.focus();		
		return false;	
	}
	document.frm_advertise.action = "add_advertisements.php";
	document.frm_advertise.submit();
}

/*// To validate the Upload Advertisement record fields
function uploadadvertiseValidate(){  	
	if(SelectValidate(document.frm_advertise.selpages,"the Page")==false) { return false; }
	if(trimAll(document.frm_advertise.fle_upload_advertise_top.value) == "" && document.frm_advertise.hid_upload_advertise_top.value == "") {
		alert("Please select the Top Advertise");
		document.frm_advertise.fle_upload_advertise_top.focus();		
		return false;	
	}
	if(trimAll(document.frm_advertise.fle_upload_advertise_top.value) != ""){
		if(File_Extentsion_Validate(document.frm_advertise.fle_upload_advertise_top,"Top Advertise")== false){
			document.frm_advertise.fle_upload_advertise_top.focus();
			return false;
		}
	}
	if(trimAll(document.frm_advertise.fle_upload_advertise_left.value) == "" && document.frm_advertise.hid_upload_advertise_left.value == "") {
		alert("Please select the Left Advertise");
		document.frm_advertise.fle_upload_advertise_left.focus();		
		return false;	
	}
	if(trimAll(document.frm_advertise.fle_upload_advertise_left.value) != ""){
		if(File_Extentsion_Validate(document.frm_advertise.fle_upload_advertise_left,"Left Advertise")== false){
			document.frm_advertise.fle_upload_advertise_left.focus();
			return false;
		}
	}
		
	document.frm_advertise.action = "add_upload_advertisements.php";
	document.frm_advertise.submit();
}*/

// To validate the Upload Advertisement record fields
function uploadadvertiseValidate(){  	
	if(SelectValidate(document.frm_advertise.selpages,"the Page")==false) { return false; }
	if(SelectValidate(document.frm_advertise.selpositions,"the Postion")==false) { return false; }
	
	/*if(trimAll(document.frm_advertise.fle_upload_advertise_image.value) == "" && document.frm_advertise.hid_upload_advertise_image.value == "") {
		alert("Please select the Image");
		document.frm_advertise.fle_upload_advertise_image.focus();		
		return false;	
	}
	if(trimAll(document.frm_advertise.fle_upload_advertise_image.value) != ""){
		if(File_Extentsion_Validate(document.frm_advertise.fle_upload_advertise_image,"Advertise")== false){
			document.frm_advertise.fle_upload_advertise_image.focus();
			return false;
		}
	}*/

	document.frm_advertise.action = "add_upload_advertisements.php";
	document.frm_advertise.submit();
}

// multiple select validate
function multiselect_validate(select) {
    var valid = false;
    for(var i = 0; i < select.options.length; i++) {
        if(select.options[i].selected) {
            valid = true;
            break;
        }
    }

    return valid;
}

// To validate the listing record fields
function listingsValidatePublic(){
 	Remove_Spaces(document.frm_listings.txt_club_name)
	if(TextValidate(document.frm_listings.txt_club_name,"the Club name")==false) {
		document.frm_listings.txt_club_name.focus();		
		return false;	
	}
	if(SelectValidate(document.frm_listings.sel_primary_town,"the Primary Town")==false) { return false;	}
	
	
	if(document.frm_listings.txt_email.value != ""){
		Remove_Spaces(document.frm_listings.txt_email)
		if(EmailValidate(document.frm_listings.txt_email,"the email")==false) {
			document.frm_listings.txt_email.focus();		
			return false;	
		}
	}
	if(document.frm_listings.txt_website.value != ""){
		Remove_Spaces(document.frm_listings.txt_website)
		if(WebsiteValidate(document.frm_listings.txt_website,"the website")==false) {
			document.frm_listings.txt_website.focus();		
			return false;	
		}
	}
	
	if(trimAll(document.frm_listings.fle_club_image.value) != ""){
		if(File_Extentsion_Validate(document.frm_listings.fle_club_image,"Club picture")== false){
			document.frm_listings.fle_club_image.focus();
			return false;
		}
	}	
	if(trimAll(document.frm_listings.fle_room1_picture.value) != ""){		
	 	if(File_Extentsion_Validate(document.frm_listings.fle_room1_picture,"Room1 picture")==false) { return false;	}
	}
	if(trimAll(document.frm_listings.fle_room2_picture.value) != ""){	
		if(File_Extentsion_Validate(document.frm_listings.fle_room2_picture,"Room2 picture")==false) { return false;	}
	}
	document.frm_listings.action = "nightclubs.php";
	document.frm_listings.submit();
}

function listingsValidate(){
 	Remove_Spaces(document.frm_listings.txt_club_name)
	if(TextValidate(document.frm_listings.txt_club_name,"the Club name")==false) {
		document.frm_listings.txt_club_name.focus();		
		return false;	
	}
	if(SelectValidate(document.frm_listings.sel_primary_town,"the Primary Town")==false) { return false;	}
	
	if(document.frm_listings.txt_website.value != ""){
		Remove_Spaces(document.frm_listings.txt_website)
		if(WebsiteValidate(document.frm_listings.txt_website,"the website")==false) {
			document.frm_listings.txt_website.focus();		
			return false;	
		}
	}
	/*Remove_Spaces(document.frm_listings.txt_phone)
	if(TextValidate(document.frm_listings.txt_phone,"the phone")==false) {
		document.frm_listings.txt_phone.focus();		
		return false;	
	}
	
	var optionvalues=new Array(document.getElementById("sel_musics[]"));
	if(optionvalues[0].value == "" || optionvalues[0].value == null || optionvalues[0].value == 0){
		alert("Please choose the music choice.");
		optionvalues[0].focus();
		return false;
	}
	var optionvalues=new Array(document.getElementById("sel_crowd[]"));
	if(optionvalues[0].value == "" || optionvalues[0].value == null || optionvalues[0].value == 0){
		alert("Please choose the dominant crowd.");
		optionvalues[0].focus();
		return false;
	}
	*/
	/*if(trimAll(document.frm_listings.fle_club_image.value) == "" && document.frm_listings.hid_club_image.value == "" && document.frm_listings.txt_club_image.value == "") {
		alert("Please select the club picture");
		document.frm_listings.fle_club_image.focus();		
		return false;	
	}
	if(trimAll(document.frm_listings.fle_club_image.value) != ""){
		if(File_Extentsion_Validate(document.frm_listings.fle_club_image,"only Image")== false){
			document.frm_listings.fle_club_image.focus();
			return false;
		}
	}
	if(trimAll(document.frm_listings.txt_club_image.value) != ""){
		if(File_Extentsion_Validate(document.frm_listings.txt_club_image,"only Image")== false){
			document.frm_listings.txt_club_image.focus();
			return false;
		}
	}*/
	if(trimAll(document.frm_listings.fle_club_image.value) == "" && document.frm_listings.hid_club_image.value == "") {
		alert("Please select the club picture");
		document.frm_listings.fle_club_image.focus();		
		return false;	
	}
	if(trimAll(document.frm_listings.fle_club_image.value) != ""){
		if(File_Extentsion_Validate(document.frm_listings.fle_club_image,"Club picture")== false){
			document.frm_listings.fle_club_image.focus();
			return false;
		}
	}	
	
	if(trimAll(document.frm_listings.fle_room1_picture.value) != ""){		
	 	if(File_Extentsion_Validate(document.frm_listings.fle_room1_picture,"Room1 picture")==false) { return false;	}
	}
	if(trimAll(document.frm_listings.fle_room2_picture.value) != ""){	
		if(File_Extentsion_Validate(document.frm_listings.fle_room2_picture,"Room2 picture")==false) { return false;	}
	}
	/*if(trimAll(document.frm_listings.fle_room1_picture.value) == "" && document.frm_listings.image1.value == ""){		
		alert("Please select the room1 Image");
		return false;
	}
 	if(File_Extentsion_Validate(document.frm_listings.fle_room1_picture,"only Image")==false) { return false;	}
	
Remove_Spaces(document.frm_listings.fle_room1_picture)
	if(FileValidate(document.frm_listings.fle_room1_picture,"the room1 picture")==false) {
		document.frm_listings.fle_room1_picture.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_listings.fle_room2_picture)
	if(FileValidate(document.frm_listings.fle_room2_picture,"the room2 picture")==false) {
		document.frm_listings.fle_room2_picture.focus();		
		return false;	
	}*/
	/*var dayArray = new Array("txt_monday","txt_tuesday","txt_wednesday","txt_thursday","txt_friday","txt_saturday","txt_sunday");
	for(i=0; i<7; ++i){
		var dayname = "document.frm_listings."+dayArray[i]+"[3].value";
		//alert(dayname);
		//alert(document.getElementById('txt_monday[3]').value);
		alert(dayname);
		//alert(dayArray[i]);
		//alert(document.frm_listings.dayname);
	}*/
	
	/*
	if(document.frm_listings.txt_monday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_monday[3],"Average age")==false) { return false;	}
	}
	if(document.frm_listings.txt_tuesday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_tuesday[3],"Average age")==false) { return false;	}
	}
	if(document.frm_listings.txt_wednesday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_wednesday[3],"Average age")==false) { return false;	}
	}
	if(document.frm_listings.txt_thursday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_thursday[3],"Average age")==false) { return false;	}
	}
	if(document.frm_listings.txt_friday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_friday[3],"Average age")==false) { return false;	}
	}
	if(document.frm_listings.txt_saturday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_saturday[3],"Average age")==false) { return false;	}
	}
	if(document.frm_listings.txt_sunday[3].value != ""){
		if(NumberValidate(document.frm_listings.txt_sunday[3],"Average age")==false) { return false;	}
	}
	*/
	
	
	document.frm_listings.action = "add_listings.php";
	document.frm_listings.submit();
}

// To validate the User Comments record fields
function usercommentValidate(){
 	
	/*Remove_Spaces(document.frm_comment.txt_email)
	if(EmailValidate(document.frm_comment.txt_email,"the email")==false) {
		document.frm_comment.txt_email.focus();		
		return false;	
	}*/
	Remove_Spaces(document.frm_comment.txt_comments)
	if(TextValidate(document.frm_comment.txt_comments,"the comments")==false) {
		document.frm_comment.txt_comments.focus();		
		return false;	
	}
	/*document.frm_comment.action = "comments_add.php";
	document.frm_comment.submit();*/
	return true
}

// To validate the Contact us record fields
function contactusValidate(){
 	Remove_Spaces(document.frm_comment.txt_name)
	if(TextValidate(document.frm_comment.txt_name,"the name")==false) {
		document.frm_comment.txt_name.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_comment.txt_email)
	if(TextValidate(document.frm_comment.txt_email,"the email")==false) {
		document.frm_comment.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_comment.txt_email)
	if(EmailValidateCheck1(document.frm_comment.txt_email,"the email")==false) {
		document.frm_comment.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_comment.txt_comments)
	if(TextValidate(document.frm_comment.txt_comments,"the Enquiry")==false) {
		document.frm_comment.txt_comments.focus();		
		return false;	
	}
	document.frm_comment.action = "contactus.php";
	document.frm_comment.submit();
}

// To validate the Advertise record fields
function advertiseValidate1(){
 	Remove_Spaces(document.frm_advertise.txt_name)
	if(TextValidate(document.frm_advertise.txt_name,"the name")==false) {
		document.frm_advertise.txt_name.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_advertise.txt_email)
	if(TextValidate(document.frm_advertise.txt_email,"the email")==false) {
		document.frm_advertise.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_advertise.txt_email)
	if(EmailValidateCheck1(document.frm_advertise.txt_email,"the email")==false) {
		document.frm_advertise.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_advertise.txt_phone)
	if(TextValidate(document.frm_advertise.txt_phone,"the phone number")==false) {
		document.frm_advertise.txt_phone.focus();		
		return false;	
	}
	if(TextAreaValidate(document.frm_advertise.txt_enquiry,"the enquiry")==false) {
		document.frm_advertise.txt_enquiry.focus();		
		return false;	
	}
	document.frm_advertise.action = "advertise.php";
	document.frm_advertise.submit();
}

// To validate the Report record fields
function reportValidate(){
 	Remove_Spaces(document.frm_comment.txt_name)
	if(TextValidate(document.frm_comment.txt_name,"the name")==false) {
		document.frm_comment.txt_name.focus();		
		return false;	
	}	
	Remove_Spaces(document.frm_comment.txt_email)
	if(TextValidate(document.frm_comment.txt_email,"the email")==false) {
		document.frm_comment.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_comment.txt_email)
	if(EmailValidateCheck1(document.frm_comment.txt_email,"the email")==false) {
		document.frm_comment.txt_email.focus();		
		return false;	
	}
	Remove_Spaces(document.frm_comment.txt_comments)
	if(TextValidate(document.frm_comment.txt_comments,"the comments")==false) {
		document.frm_comment.txt_comments.focus();		
		return false;	
	}
	if(document.frm_comment.txt_comments.value == 'If it is not very clear, please give details of the comment you would like to report so we are able to identify it. Feel free to leave any other comments as well. Thanks') {
		alert('Please enter the comments');
		document.frm_comment.txt_comments.focus();		
		return false;	
	}
	document.frm_comment.action = "report.php";
	document.frm_comment.submit();
}

// To validate the Admin Comment record fields
function commentValidate(){
 	/*Remove_Spaces(document.frm_comment.txt_name)
	if(TextValidate(document.frm_comment.txt_name,"the name")==false) {
		document.frm_comment.txt_name.focus();		
		return false;	
	}	*/
	/*Remove_Spaces(document.frm_comment.txt_email)
	if(EmailValidate(document.frm_comment.txt_email,"the email")==false) {
		document.frm_comment.txt_email.focus();		
		return false;	
	}*/
	Remove_Spaces(document.frm_comment.txt_comments)
	if(TextValidate(document.frm_comment.txt_comments,"the comments")==false) {
		document.frm_comment.txt_comments.focus();		
		return false;	
	}
	document.frm_comment.action = "add_comments.php";
	document.frm_comment.submit();
}

// To validate the Location record fields
function locationValidate(){
 	Remove_Spaces(document.frm_location.txt_name)
	if(TextValidate(document.frm_location.txt_name,"the location name")==false) {
		document.frm_location.txt_name.focus();
		return false;
	}
	
	document.frm_location.action = "add_locations.php";
	document.frm_location.submit();
}
// To validate the Sub Location record fields
function sublocationValidate(){
 	Remove_Spaces(document.frm_sublocation.txt_name)
	if(TextValidate(document.frm_sublocation.txt_name,"the sub location name")==false) {
		document.frm_sublocation.txt_name.focus();
		return false;
	}		
	if(SelectValidate(document.frm_sublocation.selLocation,"the location")==false) { return false;	}

	document.frm_sublocation.action = "add_sublocations.php";
	document.frm_sublocation.submit();
}
// To validate the Music record fields
function musicValidate(){
 	Remove_Spaces(document.frm_music.txt_name)
	if(TextValidate(document.frm_music.txt_name,"the music name")==false) {
		document.frm_music.txt_name.focus();
		return false;
	}
	
	document.frm_music.action = "add_music_choice.php";
	document.frm_music.submit();
}
// To validate the Dominant crowd record fields
function dominantcrowdValidate(){
 	Remove_Spaces(document.frm_dominantcrowd.txt_name)
	if(TextValidate(document.frm_dominantcrowd.txt_name,"the dominant crowd")==false) {
		document.frm_dominantcrowd.txt_name.focus();
		return false;
	}
	
	document.frm_dominantcrowd.action = "add_dominant_crowd.php";
	document.frm_dominantcrowd.submit();
}
// To validate the Dominant crowd record fields
function guygirlsValidate(){
 	Remove_Spaces(document.frm_guygirls.txt_name)
	if(TextValidate(document.frm_guygirls.txt_name,"the Guys/Girls")==false) {
		document.frm_guygirls.txt_name.focus();
		return false;
	}
	
	document.frm_guygirls.action = "add_guys_girls.php";
	document.frm_guygirls.submit();
}

// To validate the Staticpage
function staticpageValidate(){
	var editor_id = tinyMCE.getInstanceById('txt_content');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txt_content')),editor_id,"Please enter the content")==false) {
		return false; 
	}
	document.frm_static_page.action = "edit_static_page.php";
	document.frm_static_page.submit();
}

//# Deletion Region

//Alert message for deleting advertisement record
function deleteAdvertisements(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_advertisements.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}

//Alert message for deleting comment record
function deleteCommnets(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_comments.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}

//Alert message for deleting locations record
function deleteLocations(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_locations.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}

//Alert message for deleting Upload Adverise record
function deleteUploadAdvertisements(id,advertise_id_fk){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_upload_advertisements.php?action=delete&id="+id+"&advertise_id_fk="+advertise_id_fk;
		document.form1.submit();
 	}  	
}

//Alert message for deleting sublocations record
function deleteSublocations(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_sublocations.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}

//Alert message for deleting Dominant crowd record
function deleteDominantcrowd(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_dominant_crowd.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}
//Alert message for deleting Guys Girls  record
function deleteGuysGirls(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_guys_girls.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}


//Alert message for deleting Music choice record
function deleteMusics(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_music_choice.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}

//Alert message for deleting night club listing record
function deletelistings(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_listings.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}


//Alert message for deleting portfolio large image record
function deleteproductsimage(id,productsid){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="products_largeimage.php?action=delete&id="+id+"&products_id="+productsid;
		document.form1.submit();
 	}  		
}

//Alert message for deleting service page record

function deleteProducts(id){
	if(confirm("Are you sure you want to delete this Product?")) {
	    document.form1.action="products.php?action=delete&id="+id;
		document.form1.submit();
 	}  			
}

//Alert message for deleting testimonial record

function deleteTestimonial(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="testimonial.php?action=delete&id="+id;
		document.form1.submit();
 	}  				
}

function referralAccept(id)
{
	document.form1.action="view_listings.php?action=accept&pid="+id;
 	document.form1.submit();
}

function referralReject(id)
{
	document.form1.action="view_listings.php?action=reject&pid="+id;
 	document.form1.submit();
}

// supporting validation function of tinymice editor
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;
  }
 }

// to compare the multiple textboxes value as equal

function comparevaluesasequal(optionvalues){
	for(i = 0 ; i < optionvalues.length ; i++ ){
		for(j=0 ; j < optionvalues.length ; j++ ){
			if(i != j){
				if((trimAll(optionvalues[i][0].value) == trimAll(optionvalues [j][0].value)) && (trimAll(optionvalues[i][0].value) != "" && trimAll(optionvalues[j][0].value) != "")){
					alert("Please don't enter the equal values for "+optionvalues[i][1]+" and "+optionvalues[j][1]);
					if( i < j){
						optionvalues[j][0].focus();
					}else{
						optionvalues[i][0].focus();						
					}
					return false;
				}
			}
		}
	}
}

function faqValidate(){
	var editor_id_question = tinyMCE.getInstanceById('faq_question');
	if(Remove_Spaces_Editor((tinyMCE.getContent('faq_question')),editor_id_question,"Please enter the question")==false) {
		return false; 
	}
	var editor_id_answer = tinyMCE.getInstanceById('faq_answer');
	if(Remove_Spaces_Editor((tinyMCE.getContent('faq_answer')),editor_id_answer,"Please enter the answer")==false) {
		return false; 
	}

	document.frm_faq.action = "add_faq.php";
	document.frm_faq.submit();
}
function resetValues(name,type,id,day){
	if(confirm("Are you sure to reset the "+name+" ?")) {
	  window.location='add_listings.php?action=reset&type='+type+'&name='+name+'&id='+id+'&day='+day;
 	} 
	
	
}
function resetVotes(name,type, ratingId,memberId){
	if(confirm("Are you sure to delete the "+name+" ?")) {
	  window.location='member.php?action=reset&type='+type+'&name='+name+'&ratingId='+ratingId+'&memberId='+memberId;
 	} 
	
	
}
function deleteFAQ(id){
	if(confirm("Are you sure to delete this record?")) {
	    document.form1.action="add_faq.php?action=delete&id="+id;
		document.form1.submit();
 	}  	
}
function validateMember(){
	
	if(TextValidate(document.frmmember.member_fname,"the  First name")==false) {
		document.frmmember.member_fname.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_lname,"the  Last name")==false) {
		document.frmmember.member_lname.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_surname,"the  Nicknmae")==false) {
		document.frmmember.member_surname.focus();		
		return false;	
	}
	if(SelectValidate(document.frmmember.member_day,"the Day")==false) {
			document.frmmember.member_day.focus();		
			return false;
	}
	if(SelectValidate(document.frmmember.member_month,"the Month")==false) {
			document.frmmember.member_month.focus();		
			return false;
	}
	if(SelectValidate(document.frmmember.member_year,"the Year")==false) {
			document.frmmember.member_year.focus();		
			return false;
	}
	if(TextValidate(document.frmmember.member_postcode,"the Postcode")==false) {
		document.frmmember.member_postcode.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_email,"the Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(EmailValidate(document.frmmember.member_email,"Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_email,"the Confirm email")==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	if(EmailValidate(document.frmmember.confirm_member_email,"Confirm email")==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	if(Comparetextfields(document.frmmember.member_email,document.frmmember.confirm_member_email)==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	
	if(TextValidate(document.frmmember.member_password,"the Password")==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.confirm_member_password,"the Confirm password")==false) {
		document.frmmember.confirm_member_password.focus();		
		return false;	
	}
	if(Comparetextboxes(document.frmmember.member_password,document.frmmember.confirm_member_password)==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}
	
	document.frmmember.action = "member.php";
	document.frmmember.submit();
}
function validatePubMember(){
	
	if(TextValidate(document.frmmember.member_fname,"the  First name")==false) {
		document.frmmember.member_fname.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_lname,"the  Last name")==false) {
		document.frmmember.member_lname.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_surname,"the  Nicknmae")==false) {
		document.frmmember.member_surname.focus();		
		return false;	
	}
	if(SelectValidate(document.frmmember.member_day,"the Day")==false) {
			document.frmmember.member_day.focus();		
			return false;
	}
	if(SelectValidate(document.frmmember.member_month,"the Month")==false) {
			document.frmmember.member_month.focus();		
			return false;
	}
	if(SelectValidate(document.frmmember.member_year,"the Year")==false) {
			document.frmmember.member_year.focus();		
			return false;
	}
	if(TextValidate(document.frmmember.member_postcode,"the Postcode")==false) {
		document.frmmember.member_postcode.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_email,"the Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(EmailValidate(document.frmmember.member_email,"Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_email,"the Confirm email")==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	if(EmailValidate(document.frmmember.confirm_member_email,"Confirm email")==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	if(Comparetextfields(document.frmmember.member_email,document.frmmember.confirm_member_email)==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	
	if(TextValidate(document.frmmember.member_password,"the Password")==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.confirm_member_password,"the Confirm password")==false) {
		document.frmmember.confirm_member_password.focus();		
		return false;	
	}
	
	if(Comparetextboxes(document.frmmember.member_password,document.frmmember.confirm_member_password)==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.code,"your security code") == false){ return false; }
	
	if(document.frmmember.terms.checked == false) { alert("Please select terms and conditions"); return false; }
	if(document.frmmember.member_contact_four.checked == false) { alert("Please select confirm message"); return false; }
	
	
	document.frmmember.action = "user-registration.php";
	document.frmmember.submit();
}
function validateMemberInfoUpdate(){
	
	if(TextValidate(document.frmmember.member_fname,"the  First name")==false) {
		document.frmmember.member_fname.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_lname,"the  Last name")==false) {
		document.frmmember.member_lname.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_surname,"the  Nicknmae")==false) {
		document.frmmember.member_surname.focus();		
		return false;	
	}
	if(SelectValidate(document.frmmember.member_day,"the Day")==false) {
			document.frmmember.member_day.focus();		
			return false;
	}
	if(SelectValidate(document.frmmember.member_month,"the Month")==false) {
			document.frmmember.member_month.focus();		
			return false;
	}
	if(SelectValidate(document.frmmember.member_year,"the Year")==false) {
			document.frmmember.member_year.focus();		
			return false;
	}
	if(TextValidate(document.frmmember.member_postcode,"the Postcode")==false) {
		document.frmmember.member_postcode.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_email,"the Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(EmailValidate(document.frmmember.member_email,"Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_email,"the Confirm email")==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	if(EmailValidate(document.frmmember.confirm_member_email,"Confirm email")==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	if(Comparetextfields(document.frmmember.member_email,document.frmmember.confirm_member_email)==false) {
		document.frmmember.confirm_member_email.focus();		
		return false;	
	}
	
	if(TextValidate(document.frmmember.member_password,"the Password")==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.confirm_member_password,"the Confirm password")==false) {
		document.frmmember.confirm_member_password.focus();		
		return false;	
	}
	if(Comparetextboxes(document.frmmember.member_password,document.frmmember.confirm_member_password)==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}
	
	document.frmmember.action = "user-profile.php";
	document.frmmember.submit();
}
function deleteMember(id){
	if(confirm("Are you sure to delete this Member?")) {
	    document.form1.action="member.php?action=memberdelete&id="+id;
		document.form1.submit();
 	}  			
}

function validateLogin(baseurl,url) {
	if(document.formLogin.member_email.value=='Email Address'){
		alert("Please enter the Email");
		document.formLogin.member_email.value ='';
		document.formLogin.member_email.focus();
		return false;
	}
	

	if(TextValidate(document.formLogin.member_email,'the Email')==false) return false;
	if(EmailValidate(document.formLogin.member_email,"Confirm email")==false) {
		document.formLogin.member_email.focus();		
		return false;	
	}
	if(TextValidate(document.formLogin.member_password,'the Password')==false) return false;
	/*document.formLogin.action = baseurl+'loginProcess.php?url='+url;
	document.formLogin.submit(); */
	return true;
}
function validateLoginInner(baseurl,url) {
	if(document.frmmember.member_email.value=='Email Address'){
		alert("Please enter the Email");
		document.frmmember.member_email.value ='';
		document.frmmember.member_email.focus();
		return false;
	}
	
	if(TextValidate(document.frmmember.member_email,'the Email')==false) return false;
	if(EmailValidate(document.frmmember.member_email,"Confirm email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}
	if(TextValidate(document.frmmember.member_password,'the Password')==false) return false;
	document.frmmember.action = baseurl+'loginProcess.php?url='+url;
	document.frmmember.submit(); 
}
function validateForgot(){
	
	if(TextValidate(document.frmforgot.member_email,'the Email')==false) return false;
	if(EmailValidate(document.frmforgot.member_email,"Confirm email")==false) {
		document.frmforgot.member_email.focus();		
		return false;	
	}
	
	document.frmforgot.action="forget-password.php?action=mail";
 	document.frmforgot.submit();
	
}
function closeAccount(){
	if(confirm("Are you sure you want to close your account? Doing so will permanently erase all your votes, comments and favourites.")) {
	  window.location='close-account-process.php';
 	}  
	
}
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=no,resizable=yes,width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+'');
		newWindow.focus();
	}
	
var xmlHttp;

function checking(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var str=document.getElementById("member_surname").value;

	xmlHttp.abort();
	xmlHttp.open("GET", "checkName.php?name="+str);
	xmlHttp.onreadystatechange=function() 
	{ 
		if (xmlHttp.readyState==4)	{ 
			 document.getElementById('nicname').innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);
} 

function emailchecking(){
	
	var logincheck1 = document.frmmember.member_email.value;
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var str1 = document.frmmember.member_email.value;
	xmlHttp.abort();
	xmlHttp.open("GET", "checkName.php?mail="+str1);
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
		
			 document.getElementById('mail').innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);
} 
function checkingUpdate(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var str=document.getElementById("member_surname").value;
	var cur_str=document.getElementById("member_surname_hidden").value;
	if(cur_str==str){
		return;	
	}

	xmlHttp.abort();
	xmlHttp.open("GET", "checkName.php?name="+str);
	xmlHttp.onreadystatechange=function() 
	{ 
		if (xmlHttp.readyState==4)	{ 
			 document.getElementById('nicname').innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);
} 

function emailcheckingUpdate(){
	
	var logincheck1 = document.frmmember.member_email.value;
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var str1 = document.frmmember.member_email.value;
	var cur_str1=document.getElementById("member_email_hidden").value;
	if(cur_str1==str1){
		return;	
	}
	xmlHttp.abort();
	xmlHttp.open("GET", "checkName.php?mail="+str1);
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
		
			 document.getElementById('mail').innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);
} 

function ajax_search(field,value){		
		var from = 'core';
		var goto= "";
		var fieldarray = new Array(); 	
		var a=0;		
		var formData = '', elem = '';
		if(field!="" && field!=undefined) {
			formData = field+'='+value;
			if(field=="page") {
				formData += "&sortby="+document.getElementById("sortby").value;;	
			}
			//alert(formData);
		}else {
			var f = document.frmsearch;
			for(var s=0; s<f.elements.length; s++){ 
				elem = f.elements[s]; 
				if(formData != '' && flag == "1"){ 
					formData += '&'; 
				}			
				var flag = "0";			
				if(elem.type=="checkbox") {
					if(elem.checked==true) {
						formData += elem.name+"="+elem.value;
						flag = "1"; 
					}
				}else {
					formData += elem.name+"="+elem.value; 
					flag = "1"; 
				}	
			}
		}
		
		//alert(formData);
		//return false;
		if (window.XMLHttpRequest) {
			request = new XMLHttpRequest();
		}
		//If the user is using IE
		else if (window.ActiveXObject) {
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		var action = "ajax_search_result.php";
		var method = "post";		
		request.open(method,action, true);
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.onreadystatechange = ajax_search_process;
		request.send(formData);
		//request.send(null);		
		return false;
}
	
function ajax_search_process(){	
	if(request.readyState == 1){
		document.getElementById("searchresult").innerHTML = '<img src="nightclubFinderImage/working.gif">';	
	}
	if(request.readyState == 4){
		var answer = request.responseText;	
		var answerarray = answer.split("#^#$");
		document.getElementById("headerimagediv").innerHTML = answerarray[0];
		document.getElementById("leftadvertdiv").innerHTML = answerarray[1];
		document.getElementById("searchresult").innerHTML = answerarray[2];	
	}
}

function ajax_search_reload(URL_BASE){		
		var from = 'core';
		var field = '';
		var goto= "";
		var fieldarray = new Array(); 	
		var a=0;		
		var formData = '', elem = '';
		if(field!="" && field!=undefined) {
			formData = field+'='+value;
		}else {
			var f = document.frmsearch;
			for(var s=0; s<f.elements.length; s++){ 
				elem = f.elements[s]; 
				if(formData != '' && flag == "1"){ 
					formData += '&'; 
				}			
				var flag = "0";			
				if(elem.type=="checkbox") {
					if(elem.checked==true) {
						formData += elem.name+"="+elem.value;
						flag = "1"; 
					}
				}else {
					formData += elem.name+"="+elem.value; 
					flag = "1"; 
				}	
			}
		}
		
		//alert(formData);
		//return false;
		if (window.XMLHttpRequest) {
			request = new XMLHttpRequest();
		}
		//If the user is using IE
		else if (window.ActiveXObject) {
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		var action = "search_result.php?";
		window.location.href = URL_BASE+action+formData;
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
return xmlHttp;
}