function doCheckRegister(frm){
	var thefields = new Array("firstname","surname","emailaddress","emailaddress_conf","password1","password2","howdidyouhear");
	var thetext = new Array("your firstname","your surname","your email address","your confirmed email address","your password","your confirmation password","how did you hear about Holiday Swopping");	
	for (var i=0; i<thefields.length; i++){
		if (i==2){
			if (frm[thefields[i]].value.indexOf('@') == -1){ 
				alert("Please enter "+ thetext[i] + "."); 
				frm.emailaddress.focus(); 
				return false; 
			} 
		} 
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	if ((frm.emailaddress.value)!=(frm.emailaddress_conf.value)){
		alert("Your email addresses do not match!");
		return false;
	}
	if ((frm.password1.value)!=(frm.password2.value)){
		alert("Your Password and Confirmation Password do not match!");
		return false;
	}
	if (frm.iagree.checked == false){
		alert("You must agree to the sites Terms & Conditions");
		return false;
	}
	frm.theAction.value = "doRegister";
	frm.submit();
}

function doCheckRegister_old(frm){
	var thefields = new Array("firstname","surname","address","emailaddress","emailaddress_conf","password1","password2","country","province","town","nearestcity","typeoflocation","duration","howdidyouhear");
	var thetext = new Array("your firstname","your surname","your address","your email address","your confirmed email address","your password","your confirmation password","the country","the province","the town","your nearest city","the type of location","the duration","how did you hear about Holiday Swopping");	
	for (var i=0; i<thefields.length; i++){
		if (i==3){
			if (frm[thefields[i]].value.indexOf('@') == -1){ 
				alert("Please enter "+ thetext[i] + "."); 
				frm.emailaddress.focus(); 
				return false; 
			} 
		} 
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	if ((frm.emailaddress.value)!=(frm.emailaddress_conf.value)){
		alert("Your email addresses do not match!");
		return false;
	}
	if ((frm.password1.value)!=(frm.password2.value)){
		alert("Your Password and Confirmation Password do not match!");
		return false;
	}
	if (frm.iagree.checked == false){
		alert("You must agree to the sites Terms & Conditions");
		return false;
	}
	frm.theAction.value = "doRegister";
	frm.submit();
}

function doRegister2(frm){
	frm.theAction.value = "doRegister";
	frm.submit();
}
function doCheckAddListing(frm){
	var thefields = new Array("country","province","town","nearestcity","typeoflocation","duration");
	var thetext = new Array("the country","the province","the town","the nearest city","the type of location","the duration");	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value = "doAddLisiting";
	frm.submit();
}
function check_searchform(frm){
	if ((frm.country.value=="")||(frm.typeofexchange.value=="")){
		alert("Please make the required selection!");
	}else{
		frm.theAction.value="doSearch";
		frm.submit();
	}
}
function check_searchformbyid(frm){
	if (frm.propertyid.value==""){
		alert("Please enter the ID number of the property you\nare searching for!");
	}else{
		frm.theActionbyid.value="doSearch";
		frm.submit();
	}
}

function check_loginform(frm){
	if ((frm.username.value == "USERNAME") || (frm.password.value == "PASSWORD")){
		alert("Please enter your Username and Password");
	}else{
		frm.submit();
	}
}

function doEditit(frm,theID){
	frm.theAction.value="EditIt";
	frm.theID.value=theID;
	frm.submit();
}

function doUploadit(frm,theID){
	frm.theAction.value="UploadIt";
	frm.theID.value=theID;
	frm.submit();
}

function doUploadImage(frm,theID){
	frm.theAction.value="UploadImage";
	frm.theID.value=theID;
	frm.submit();
}

function doUpdateit(frm,theID){
	var thefields = new Array("country","province","town","nearestcity","typeoflocation","duration");
	var thetext = new Array("the country","the province","the town","the nearest city","the type of location","the duration");	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value="UpdateIt";
	frm.theID.value=theID;
	frm.submit();
}
function doCancelit(frm){
	frm.theAction.value="doCancelEdit";
	frm.theID.value="";
	frm.submit();
}
function doDeleteit(frm,theID){	
	if (confirm("Are you sure you want to delete this?")){
		frm.theAction.value="DeleteIt";
		frm.theID.value=theID;
		frm.submit();
	}
}

function doDeleteSupportingDoc(frm,theID){	
	if (confirm("Are you sure you want to delete this support document?")){
		frm.theAction.value="DeleteSuppDoc";
		frm.deletedoc.value=theID;
		frm.submit();
	}
}

function doCancelmyprofile(frm){
	frm.theAction.value="cancelmyprofile";
	frm.submit();
}
function doCheckUpdateProfile(frm){
	var thefields = new Array("firstname","surname","emailaddress","password1","password2");
	var thetext = new Array("your firstname","your surname","your email address","your password","your confirmation password");	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	if ((frm.password1.value)!=(frm.password2.value)){
		alert("Your Password and Confirmation Password do not match!");
		return false;
	}
	frm.theAction.value="doUpdateProfile";
	frm.submit();
}
function resfreshImg1(){
	if (document.register.ImgFeature_upld1.value!="")
		document.register.ImgFeature1.src=document.register.ImgFeature_upld1.value;
}
function resfreshImg2(){
	if (document.register.ImgFeature_upld2.value!="")
		document.register.ImgFeature2.src=document.register.ImgFeature_upld2.value;
}
function resfreshImg3(){
	if (document.register.ImgFeature_upld3.value!="")
		document.register.ImgFeature3.src=document.register.ImgFeature_upld3.value;
}
function resfreshImg4(){
	if (document.register.ImgFeature_upld4.value!="")
		document.register.ImgFeature4.src=document.register.ImgFeature_upld4.value;
}
function resfreshImg5(){
	if (document.register.ImgFeature_upld5.value!="")
		document.register.ImgFeature5.src=document.register.ImgFeature_upld5.value;
}
function resfreshImg6(){
	if (document.register.ImgFeature_upld6.value!="")
		document.register.ImgFeature6.src=document.register.ImgFeature_upld6.value;
}

function resfreshImg1Edit(){
	if (document.updateit.ImgFeature_upld1.value!="")
		document.updateit.ImgFeature1.src=document.updateit.ImgFeature_upld1.value;
}
function resfreshImg2Edit(){
	if (document.updateit.ImgFeature_upld2.value!="")
		document.updateit.ImgFeature2.src=document.updateit.ImgFeature_upld2.value;
}
function resfreshImg3Edit(){
	if (document.updateit.ImgFeature_upld3.value!="")
		document.updateit.ImgFeature3.src=document.updateit.ImgFeature_upld3.value;
}
function resfreshImg4Edit(){
	if (document.updateit.ImgFeature_upld4.value!="")
		document.updateit.ImgFeature4.src=document.updateit.ImgFeature_upld4.value;
}
function resfreshImg5Edit(){
	if (document.updateit.ImgFeature_upld5.value!="")
		document.updateit.ImgFeature5.src=document.updateit.ImgFeature_upld5.value;
}
function resfreshImg6Edit(){
	if (document.updateit.ImgFeature_upld6.value!="")
		document.updateit.ImgFeature6.src=document.updateit.ImgFeature_upld6.value;
}

function resfreshImg1Add(){
	if (document.addlisting.ImgFeature_upld1.value!="")
		document.addlisting.ImgFeature1.src=document.addlisting.ImgFeature_upld1.value;
}
function resfreshImg2Add(){
	if (document.addlisting.ImgFeature_upld2.value!="")
		document.addlisting.ImgFeature2.src=document.addlisting.ImgFeature_upld2.value;
}
function resfreshImg3Add(){
	if (document.addlisting.ImgFeature_upld3.value!="")
		document.addlisting.ImgFeature3.src=document.addlisting.ImgFeature_upld3.value;
}
function resfreshImg4Add(){
	if (document.addlisting.ImgFeature_upld4.value!="")
		document.addlisting.ImgFeature4.src=document.addlisting.ImgFeature_upld4.value;
}
function resfreshImg5Add(){
	if (document.addlisting.ImgFeature_upld5.value!="")
		document.addlisting.ImgFeature5.src=document.addlisting.ImgFeature_upld5.value;
}
function resfreshImg6Add(){
	if (document.addlisting.ImgFeature_upld6.value!="")
		document.addlisting.ImgFeature6.src=document.addlisting.ImgFeature_upld6.value;
}

function checkitforgottenpassword(frm){
	if (frm.emailaddress.value.indexOf('@') == -1){ 
		alert("Please enter a valid email address"); 
		frm.emailaddress.focus(); 
		return false; 
	} 
	frm.theAction.value="gogetit";
	frm.submit();
}
function doSearch(frm){
	//var thefields = new Array("country","typeofexchange");
	//var thetext = new Array("the country","the type of exchange");	
	var thefields = new Array("country");
	var thetext = new Array("the country");	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value="doSearch";
	frm.submit();
}
function doRecommendaFriendcheck(frm){
	if (frm.name.value == ""){
		alert("Please enter your friends name");
		frm.name.focus(); 
		return false; 
	}
	if (frm.email.value.indexOf('@') == -1){ 
		alert("Please enter a valid email address"); 
		frm.email.focus(); 
		return false; 
	} 
	frm.theAction.value="gosendrec";
	frm.submit();
}
function popUp(url) {
SMWin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=500,height=400,left='+(screen.width-530)/2+',top='+(screen.height-550)/2+'');
}
function search_doReset(frm){
	frm.country.value = "Any";
	frm.typeofexchange.value = "Any";
}

function doDeleteImage(frm,object_id){
	if (confirm("Are you sure you want to delete this image?")){
		frm.theAction.value = "DeleteImage";
		frm.object_id.value = object_id;
		frm.submit();
	}						
}

function the_RemoveImage1(frm,theID){
	if (confirm("Are you sure you want to remove this from the database?")){
		frm.txt_RemoveImage1.value="DeleteIt";
		frm.theID_remove1.value=theID;
		frm.submit();
	}
}
function the_RemoveImage2(frm,theID){
	if (confirm("Are you sure you want to remove this from the database?")){
		frm.txt_RemoveImage2.value="DeleteIt";
		frm.theID_remove2.value=theID;
		frm.submit();
	}
}
function the_RemoveImage3(frm,theID){
	if (confirm("Are you sure you want to remove this from the database?")){
		frm.txt_RemoveImage3.value="DeleteIt";
		frm.theID_remove3.value=theID;
		frm.submit();
	}
}
function the_RemoveImage4(frm,theID){
	if (confirm("Are you sure you want to remove this from the database?")){
		frm.txt_RemoveImage4.value="DeleteIt";
		frm.theID_remove4.value=theID;
		frm.submit();
	}
}
function the_RemoveImage5(frm,theID){
	if (confirm("Are you sure you want to remove this from the database?")){
		frm.txt_RemoveImage5.value="DeleteIt";
		frm.theID_remove5.value=theID;
		frm.submit();
	}
}
function the_RemoveImage6(frm,theID){
	if (confirm("Are you sure you want to remove this from the database?")){
		frm.txt_RemoveImage6.value="DeleteIt";
		frm.theID_remove6.value=theID;
		frm.submit();
	}
}

function check_contact(frm){
	if (frm.name.value == ""){
		alert("Please enter your name");
		frm.name.focus(); 
		return false; 
	}
	if (frm.message.value == ""){
		alert("Please enter your message"); 
		frm.message.focus(); 
		return false; 
	} 
	frm.submit();
}
function goodchars(e, goods){
var key, keychar;
key = getkey(e);
if (key == null) return true;

// get character
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
	return true;

// control keys
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
   return true;

// else return false
return false;
}

function checkit_suggestion(frm){
	var thefields = new Array("name","email","comments");
	var thetext = new Array("your name","your full email address","your comments");	
	for (var i=0; i<thefields.length; i++){
		if (i==1){
			if (frm[thefields[i]].value.indexOf('@') == -1){
				alert("Please enter "+ thetext[i] + ".");
				frm.email.focus();
				return false;
			}
		}
		if (!frm[thefields[i]].value){
		alert("Please enter "+ thetext[i] + ".");
		frm[thefields[i]].focus();
		return false;
		}
	}
	frm.submit();
}

