/***********************************************
* Confirm Deletion of the record.
************************************************/
function confirmDeletion ()	{		
	var trigger=0;
    el=document.getElementsByTagName('INPUT');
    trigger=1;

	if(trigger==1){
		ht = document.getElementsByTagName("body");
		ht[0].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";		
		if (confirm("Do you really want to delete selected item(s)?"))	{
			return true;
		} else	{
			ht[0].style.filter = "";
			return false;
		}
	}
	else if(trigger==0){
		return false;
	}
}

/***********************************************
* Allow only numeric input.
************************************************/
function numericVal(obj)   {
    var tam = obj.value.length;
    var numeric = false;
    for(var i=0;i<tam;i++)  {
        caracter = obj.value.charCodeAt(i);
        if((caracter >= 48 && caracter <= 57))	{
       		numeric = true;
        }
        else  {
            obj.value=obj.value.substring(0,tam-1);
            numericVal(obj);
        }
    }
}

/***********************************************
* Layer hide / show.
************************************************/
function showhide (id)	{
	var style = document.getElementById(id).style
	if (style.display == "none")
		style.display = "";
	else
		style.display="none";
}

/***********************************************
* Hide Enail from spam bots.
************************************************/
function emailCloak() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
		  if (alltags[i].className == "emailCloak") {
		  	var oldText = alltags[i].firstChild;
		  	var emailAddress = alltags[i].firstChild.nodeValue;
		  	var user = emailAddress.substring(0, emailAddress.indexOf("("));
		  	var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
		  	var newText = user+"@"+website;
		  	var a = document.createElement("a");
		  	a.href = "mailto:"+newText;
			var address = document.createTextNode(newText);
			a.appendChild(address);
			alltags[i].replaceChild(a,oldText);
		  }
		}
	}
}
window.onload = emailCloak;

/***********************************************
* Wholesale customer validation.
************************************************/
function contact_validation(){
	var valid=true;
	
	if(document.frm_con.username.value=="") {
		alert("Please type you full name.");
		document.frm_con.username.focus();
		valid = false;
	}
	else if(document.frm_con.email.value=="") {
		alert("Please type youe email address.");
		document.frm_con.email.focus();
		valid = false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frm_con.email.value))) {
		alert("A valid e-mail address is required.\nPlease amend and retry.");
		document.frm_con.email.focus();
	    valid = false;
	}
	else if(document.frm_con.phone.value=="") {
		alert("Please type your contact telephone.");
		document.frm_con.phone.focus();
		valid = false;
	}
	else if(document.frm_con.company.value=="") {
		alert("Please type your company name.");
		document.frm_con.company.focus();
		valid = false;
	}
	else if(document.frm_con.country.value=="") {
		alert("Please type your country name.");
		document.frm_con.country.focus();
		valid = false;
	}
	else if(document.frm_con.subject.value=="") {
		alert("Please type your massage subject.");
		document.frm_con.subject.focus();
		valid = false;
	}
	else if(document.frm_con.message.value=="") {
		alert("Please type your message.");
		document.frm_con.message.focus();
		valid = false;
	}

	return valid;
}

/***********************************************
* Wholesale customer validation.
************************************************/
function quote_validation(){
	var valid=true;
	
	if(document.frm_quote.fullname.value=="") {
		alert("Please type full name.");
		document.frm_quote.fullname.focus();
		valid = false;
	}
	else if(document.frm_quote.email.value=="") {
		alert("Please type your email address.");
		document.frm_quote.email.focus();
		valid = false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frm_quote.email.value))) {
		alert("A valid e-mail address is required.\nPlease amend and retry.");
		document.frm_quote.email.focus();
	    valid = false;
	}
	else if(document.frm_quote.phone.value=="") {
		alert("Please type phone or mobile number.");
		document.frm_quote.phone.focus();
		valid = false;
	}
	else if(document.frm_quote.country.value=="") {
		alert("Please type your country name.");
		document.frm_quote.country.focus();
		valid = false;
	}
	else if(document.frm_quote.company.value=="") {
		alert("Please type your company / position .");
		document.frm_quote.company.focus();
		valid = false;
	}
	else if(document.frm_quote.activity.value=="") {
		alert("Please type your company activity.");
		document.frm_quote.activity.focus();
		valid = false;
	}
	else if(!document.frm_quote.web_dev.checked 	&&
			!document.frm_quote.web_redesign.checked &&
			!document.frm_quote.web_design.checked	&&
			!document.frm_quote.web_prog.checked	&&
			!document.frm_quote.web_logo.checked	&&
			!document.frm_quote.web_domain.checked	&&
			!document.frm_quote.web_host.checked
		   )	{
		alert("Please check the services are you interested in .");
		document.frm_quote.web_dev.focus();
		valid = false;
	}
	else if(document.frm_quote.comment.value=="") {
		alert("Please type your project timeframe and comments .");
		document.frm_quote.comment.focus();
		valid = false;
	}
	
	return valid;
}
