function trim(text){
	text = text.replace(/^\s+/, "");
	text = text.replace(/\s+$/, "");
	text = text.replace(/\s+/g, " ");
	return text;
}

function latestNewsToggle(objItem, strImg, strLink){
	// First remove hovers off all items
	for(i = 1; i <= 4; i++){$("news_hl_" + i).className="unselected";}
	// Now set the selected item and it's image
	objItem.className="selected";
	$("news_hl_img").src = strImg;
	$("news_hl_url").href = strLink;
}

function showMenu(strW, bolShow){
	for(i = 1; i <= 1000; i++){
		if($("menu_h_" + i) != undefined){$("menu_h_" + i).style.display="none";}
	}
	if(bolShow){
		if(BrowserDetect.browser == "Explorer" && BrowserDetect.version == 6){
			for (i=0; i<$('qui_s_form').elements.length; i++){
				$('qui_s_form').elements[i].style.visibility='hidden';
			}	
		}
		$(strW).style.display = "block";
	}else{
		if(BrowserDetect.browser == "Explorer" && BrowserDetect.version == 6){
			for (i=0; i<$('qui_s_form').elements.length; i++){
				$('qui_s_form').elements[i].style.visibility='visible';
			}	
		}
	}
}

function toggleFAQ(intID){
	if($("faqitem" + intID).style.display == "none"){
		$("faqitem" + intID).style.display = "block";
	}else{
		$("faqitem" + intID).style.display = "none";
	}
}

function faqAll(strAction){
	$$("div.answer").setStyle('display', strAction);
}

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function checkSubmitLinkForm(){		
	
	var objForm = $("submitLinkForm");
	
	if(trim(objForm.f1.value).length < 2){
		alert("Please enter your name.");
		objForm.f1.value = trim(objForm.f1.value);
		objForm.f1.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(objForm.f6.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.f6.value = trim(objForm.f6.value);
		objForm.f6.focus();
		return false;
	}
	
	if(trim(objForm.f7.value).length < 2){
		alert("Please ensure your Business Details and Description fields are completed.");
		objForm.f7.value = trim(objForm.f7.value);
		objForm.f7.focus();
		return false;
	}
	
	if(trim(objForm.f8.value).length < 2){
		alert("Please ensure your Business Details and Description fields are completed.");
		objForm.f8.value = trim(objForm.f8.value);
		objForm.f8.focus();
		return false;
	}
	
	if(trim(objForm.f9.value).length < 2){
		alert("Please ensure your Business Details and Description fields are completed.");
		objForm.f9.value = trim(objForm.f9.value);
		objForm.f9.focus();
		return false;
	}
	
	if(trim(objForm.f10.value).length < 2){
		alert("Please ensure your Business Details and Description fields are completed.");
		objForm.f10.value = trim(objForm.f10.value);
		objForm.f10.focus();
		return false;
	}
	
	return true;
	
}

function checkSubmitAdForm(){		
	
	var objForm = $("submitAdForm");
	
	if(trim(objForm.f1.value).length < 2){
		alert("Please enter your name.");
		objForm.f1.value = trim(objForm.f1.value);
		objForm.f1.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(objForm.f6.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.f6.value = trim(objForm.f6.value);
		objForm.f6.focus();
		return false;
	}
	
	if(trim(objForm.f7.value).length < 2){
		alert("Please ensure your Business Details and Description fields are completed.");
		objForm.f7.value = trim(objForm.f7.value);
		objForm.f7.focus();
		return false;
	}
	
	if(trim(objForm.f8.value).length < 2){
		alert("Please ensure your Business Details and Description fields are completed.");
		objForm.f8.value = trim(objForm.f8.value);
		objForm.f8.focus();
		return false;
	}
	
	return true;
	
}

function checkFeedForm(){		
	
	var objForm = $("feedForm");
	
	if(trim(objForm.f1.value).length < 2){
		alert("Please enter your name.");
		objForm.f1.value = trim(objForm.f1.value);
		objForm.f1.focus();
		return false;
	}
	
	if(trim(objForm.f2.value).length < 2){
		alert("Please enter your surname.");
		objForm.f2.value = trim(objForm.f2.value);
		objForm.f2.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(objForm.f5.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.f5.value = trim(objForm.f5.value);
		objForm.f5.focus();
		return false;
	}
	
	if(trim(objForm.f6.value).length < 2){
		alert("Please enter your message.");
		objForm.f6.value = trim(objForm.f6.value);
		objForm.f6.focus();
		return false;
	}
	
	return true;
	
}



function okok(responseText){
	var Tips1 = new Tips($$('.Tips1'));
				
	var Tips2 = new Tips($$('.today'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});

	var Tips3 = new Tips($$('.Tips3'), {
		showDelay: 500,
		hideDelay: 500,
		fixed: true
	});

	var Tips4 = new Tips($$('.Tips4'), {
		className: 'custom'
	});
}

function loadQSGeo2(intParent){
	var myAjax = new Ajax('code/includes/qs_geo2_listbox.asp?parent=' + intParent + '&_r='+Math.random(), {update: 'zone_qs_geo2', method: 'get'});
	myAjax.request();
}

function loadASGeo2(intParent){
	var myAjax = new Ajax('code/includes/as_geo2_listbox.asp?parent=' + intParent + '&_r='+Math.random(), {update: 'zone_as_geo2', method: 'get'});
	myAjax.request();
}

function checkSubmitProductForm(){		
	
	var objForm = $("submitProductForm");
	
	if(trim(objForm.c1.value).length < 2){
		alert("Please enter your name.");
		objForm.c1.value = trim(objForm.c1.value);
		objForm.c1.focus();
		return false;
	}
	
	if(trim(objForm.c2.value).length < 2){
		alert("Please enter your surname.");
		objForm.c2.value = trim(objForm.c2.value);
		objForm.c2.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(objForm.c6.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.c6.value = trim(objForm.c6.value);
		objForm.c6.focus();
		return false;
	}
	
	return true;
	
}

function checkEnquiryForm(){		
	
	var objForm = $("submitEnquiryForm");
	
	if(trim(objForm.c1.value).length < 2){
		alert("Please enter your name.");
		objForm.c1.value = trim(objForm.c1.value);
		objForm.c1.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(objForm.c6.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.c6.value = trim(objForm.c6.value);
		objForm.c6.focus();
		return false;
	}
	
	if(trim(objForm.frm_arrive.value).length < 2){
		alert("Please select your arrival date.");
		objForm.frm_arrive.value = trim(objForm.frm_arrive.value);
		objForm.frm_arrive.focus();
		return false;
	}
	
	if(trim(objForm.frm_depart.value).length < 2){
		alert("Please select your departure date.");
		objForm.frm_depart.value = trim(objForm.frm_depart.value);
		objForm.frm_depart.focus();
		return false;
	}
	
	return true;
	
}

function removeEnquiry(intID){
	if(confirm("Remove this listing from your enquiry list?")){
		window.location.href="code/includes/enquiry_del.asp?" + intID;
	}
}
