var invalidaddress = new Array("teensex","fuck","sex","xxx","sexcity")
var testresults
var ids=new Array('addtoform');

function switchid(id){	
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
		document.getElementById(id).style.display = 'none';
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function popUp(url){
  window.open(url,"MyPopup",'height=450,width=430');
} 

function formLinkExchange(formcheck_linkexchange){
    	if (document.formcheck_linkexchange.name.value == ""){
        alert( "Please type in your full name." );
        document.formcheck_linkexchange.name.focus();
        return false;
        }
    	if (document.formcheck_linkexchange.title.value == ""){
        alert( "Please type in website title.");
        document.formcheck_linkexchange.title.focus();
        return false;
        }
    	if (document.formcheck_linkexchange.url.value == ""){
        alert( "Please type in website url.");
        document.formcheck_linkexchange.url.focus();
        return false;
        }
    	if (document.formcheck_linkexchange.url.value == "" || document.formcheck_linkexchange.url.value == "http://"){
        alert( "Please type in website url.");
        document.formcheck_linkexchange.url.focus();
        return false;
        }
    	if (document.formcheck_linkexchange.recurl.value == "" || document.formcheck_linkexchange.recurl.value == "http://"){
        alert( "Please type in reciprocal url.");
        document.formcheck_linkexchange.recurl.focus();
        return false;
        }
    	if (document.formcheck_linkexchange.description.value == ""){
        alert( "Please type in description.");
        document.formcheck_linkexchange.description.focus();
        return false;
        }
	if (document.formcheck_linkexchange.email.value == "") {
        alert( "Please indicate your e-mail address." );
        document.formcheck_linkexchange.focus();
        return false ;
	}else{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.formcheck_linkexchange.email.value)){
	return (true)
        }
	alert("Invalid e-mail address! Please re-enter.");
        document.formcheck_linkexchange.email.focus();
	return false;
	}
	return true ;
}

function CheckReviewFrm() {
	var result = true;
	var msg="";

	if (document.frmReview.name.value=="") {
			msg+="Name should not be blank.\n";
			document.frmReview.name.focus();
			result = false;
	}	
	if (document.frmReview.review.value=="") {
			msg+="Review should not be blank.\n";
			document.frmReview.review.focus();
			result = false;
	}	
	if (document.frmReview.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmReview.captcha.focus();
			result = false;
	}		
  if (checkEmailReview(document.frmReview.email.value) == 0 || document.frmReview.email.value==""){
			msg+="Email not valid.\n";
			document.frmReview.email.select();
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}

function CheckNewsFrm() {
	var result = true;
	var msg="";

	if (document.frmNews.author.value=="") {
			msg+="Name should not be blank.\n";
			document.frmNews.author.focus();
			result = false;
	}	
	if (document.frmNews.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmNews.captcha.focus();
			result = false;
	}		
	if (document.frmNews.email.value=="") {
			msg+="Email should not be blank.\n";
			document.frmNews.email.focus();
			result = false;
	}	
  if (checkEmailNews(document.frmNews.email.value) == 0 || document.frmNews.email.value==""){
			msg+="Email not valid.\n";
			document.frmNews.email.select();
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}

function checkNewsFrm(str){
	var invalidcheck = 0
	var str = document.frmNews.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}      

function CheckgNewsFrm() {
	var result = true;
	var msg="";

	if (document.frmgNews.author.value=="") {
			msg+="Name should not be blank.\n";
			document.frmgNews.author.focus();
			result = false;
	}	
	if (document.frmgNews.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmgNews.captcha.focus();
			result = false;
	}		
	if (document.frmgNews.email.value=="") {
			msg+="Email should not be blank.\n";
			document.frmgNews.email.focus();
			result = false;
	}	
  if (checkEmailgNews(document.frmgNews.email.value) == 0 || document.frmgNews.email.value==""){
			msg+="Email not valid.\n";
			document.frmgNews.email.select();
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}

function checkgNewsFrm(str){
	var invalidcheck = 0
	var str = document.frmgNews.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}      

function CheckNewsletterFrm() {
	var result = true;
	var msg="";

	if (document.frmNewsletter.fname.value=="") {
			msg+="First name should not be blank.\n";
			document.frmNewsletter.fname.focus();
			result = false;
	}	
	if (document.frmNewsletter.lname.value=="") {
			msg+="Last name should not be blank.\n";
			document.frmNewsletter.lname.focus();
			result = false;
	}	
	if (document.frmNewsletter.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmNewsletter.captcha.focus();
			result = false;
	}		
	
  if (checkEmailNewsletter(document.frmNewsletter.email.value) == 0 || document.frmNewsletter.email.value==""){
			msg+="Email not valid.\n";
			document.frmNewsletter.email.focus();
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}   

function CheckSharePhotoFrm() {
	var result = true;
	var msg="";

	if (document.frmSharePhoto.fname.value=="") {
			msg+="First name should not be blank.\n";
			document.frmSharePhoto.fname.focus();
			result = false;
	}	

	if (document.frmSharePhoto.file.value=="") {
			msg+="Please enter an image to upload.\n";
			document.frmSharePhoto.file.focus();
			result = false;
	}	

	if (document.frmSharePhoto.caption.value=="") {
			msg+="Please enter a caption.\n";
			document.frmSharePhoto.caption.focus();
			result = false;
	}

	if (document.frmSharePhoto.category.value=="") {
			msg+="Please categorize your image.\n";
			document.frmSharePhoto.category.focus();
			result = false;
	}

	if (document.frmSharePhoto.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmSharePhoto.captcha.focus();
			result = false;
	}		
	
  if (checkEmailSharePhoto(document.frmSharePhoto.email.value) == 0 || document.frmSharePhoto.email.value==""){
			msg+="Email not valid.\n";
			document.frmSharePhoto.email.focus();
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}   

function CheckSPCommentFrm() {
	var result = true;
	var msg="";

	if (document.frmSPComment.fname.value=="") {
			msg+="Name should not be blank.\n";
			document.frmSPComment.fname.focus();
			result = false;
	}	

	if (document.frmSPComment.comment.value=="") {
			msg+="Please enter your comment.\n";
			document.frmSPComment.comment.focus();
			result = false;
	}

	if (document.frmSPComment.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmSPComment.captcha.focus();
			result = false;
	}		
	
  if (checkEmailSPComment(document.frmSPComment.email.value) == 0 || document.frmSPComment.email.value==""){
			msg+="Email not valid.\n";
			document.frmSPComment.email.focus();
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}   

function checkEmailSPComment(str){
	var invalidcheck = 0
	var str = document.frmSPComment.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}      

function checkEmailSharePhoto(str){
	var invalidcheck = 0
	var str = document.frmSharePhoto.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}      

function checkEmailNewsletter(str){
	var invalidcheck = 0
	var str = document.frmNewsletter.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}                



function checkEmailNews(str){
	var invalidcheck = 0
	var str = document.frmNews.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}    

function checkEmailReview(str){
	var invalidcheck = 0
	var str = document.frmReview.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				//alert("Please specify a more official Email Address!")
				//document.formcheck.email.select()
				testresults = 0
			}
	}else{
		//alert("Please specify a valid Email Address!")
		//document.formcheck.email.select()
		testresults = 0
	}
	
	return (testresults)
}                            

function CheckBookingFrm() {
	var result = true;
	var msg="";

	if (document.frmBooking.fname.value=="") {
			msg+="Please specify your full name.\n";
			document.frmBooking.fname.focus();
			document.getElementById('fname').style.color="red";
			result = false;
	}	

	if (document.frmBooking.nationality.value=="") {
			msg+="Please specify your nationality.\n";
			document.frmBooking.nationality.focus();
			document.getElementById('nationality').style.color="red";
			result = false;
	}	

	if (document.frmBooking.phone.value=="") {
			msg+="Please specify your contact phone.\n";
			document.frmBooking.phone.focus();
			document.getElementById('phone').style.color="red";
			result = false;
	}	

	if (document.frmBooking.location.value=="") {
			msg+="Please specify your current location.\n";
			document.frmBooking.location.focus();
			document.getElementById('location').style.color="red";
			result = false;
	}	

	if (document.frmBooking.occupancy.value=="") {
			msg+="Occupancy should not be blank.\n";
			document.frmBooking.occupancy.focus();
			document.getElementById('occupancy').style.color="red";
			result = false;
	}	

	if (document.frmBooking.address.value=="") {
			msg+="Please specify your address.\n";
			document.frmBooking.address.focus();
			document.getElementById('address').style.color="red";
			result = false;
	}	

	if (document.frmBooking.nofrooms.value=="") {
			msg+="Please specify number of rooms to reserve.\n";
			document.frmBooking.nofrooms.focus();
			document.getElementById('nofrooms').style.color="red";
			result = false;
	}	

	if (document.frmBooking.terms.checked==false) {
			msg+="You did not agree with our terms and condition.\n";
			document.frmBooking.terms.focus();
			document.getElementById('terms').style.color="red";
			result = false;
	}		

	if (document.frmBooking.captcha.value=="") {
			msg+="For verification. Please enter month today.\n";
			document.frmBooking.captcha.focus();
			document.getElementById('captcha').style.color="red";
			result = false;
	}		
	

  if (checkEmailBooking(document.frmBooking.email.value) == 0 || document.frmBooking.email.value==""){
			msg+="Email is not valid.\n";
			document.frmBooking.email.focus();
			document.getElementById('email').style.color="red";
			result = false;
	}
	if(msg==""){
	return result;
	}{
	alert(msg)
	return result;
	}
}   

function checkEmailBooking(str){
	var invalidcheck = 0
	var str = document.frmBooking.email.value
	var filter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		
		for (i=0; i < invalidaddress.length; i++){
			if (tempstring[0] == invalidaddress[i])
				invalidcheck = 1
			}
			
			if (invalidcheck != 1)
				testresults = 1
			else{
				testresults = 0
			}
	}else{
		testresults = 0
	}
	return (testresults)
}   

