// Navigation Drop Down List
function navMenu(targ,selObj) {
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
}

// Clear text box on click
function clearText(field){
	if (field.defaultValue == field.value) field.value = '';
	else if (field.value == '') field.value = field.defaultValue;
}

// Generates Contact Email
function generateMailToLink() {
	//variables
	var mlink;
	var start_here = '&#105;n&#102;o'; 
	var finish_here = '&#97;f&#114;i&#99;a&#115;a&#102;a&#114;i&#99;l&#97;s&#115;i&#99;s' + '&#46;' + 'c&#111;m'; 
	 
	//output
	mlink = '<a class=\"enquiryLink\" href=\"mailto:' + start_here + '&#64;' + finish_here + '?subject=Enquiry from the website\">'; 
	mlink += 'CLICK HERE TO ENQUIRE';
	mlink += '</a>';
	
	return (mlink);
}

// Generates Contact Email
function generateContactEmail(style) {
	//variables
	var email;
	var start_here = '&#105;n&#102;o'; 
	var finish_here = '&#97;f&#114;i&#99;a&#115;a&#102;a&#114;i&#99;l&#97;s&#115;i&#99;s' + '&#46;' + 'c&#111;m'; 
	 
	//output
	email = '<a class=\"' + style + '\" href=\"mailto:' + start_here + '&#64;' + finish_here + '\">'; 
	email += start_here + '&#64;' + finish_here;
	email += '</a>';
	
	return (email);
}

// Facebook Sharer
function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

// Opens Window PopUp
function winPopUp(winURL,winName,winWidth,winHeight)
{
	var w = window.open(winURL, winName, "width="+winWidth+", height="+winHeight+", toolbars=no, scrollbars=yes");
	w.focus();
}

// Trims White Spaces in the passed values
function trimText(obj) {
	var str = "";
	for (var i=0; i < obj.length; i++) {
		var letter = obj.charAt(i).toLowerCase();
		if (letter == " ")
			continue;
		str = str + letter;
	}
	return str;
}

// Regenerates Captcha Image
function newCaptcha() {
	var url = 'generate_veriword.php?sid='+Math.random();
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
		var code = transport.responseText;
		document.getElementById("secure_image").src = "anti_spam.php?key=" + code;
		document.getElementById("signup_csecure").value = code;
	  },
	  onFailure:function(){ alert('Something went wrong...') }
	});
}

// Validates Passed Email Address
function isValidEmail(email){ 
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false) {
		return false;
	} else {
		return true; 
	}
} 

