
function Len(me)
{
    var lValue = Trim(me.value);
    
    return lValue.length;
}

function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function iif(Expression, TruePart, FalsePart)
{
    return (Expression ? TruePart : FalsePart);
}

function Replace(StrValue, OldValue, Newvalue)
{
    StrValue = StrValue.replace(new RegExp(OldValue, "gi"), Newvalue);
    
    return StrValue;
}

function SetCookie(name, value)
{
    var exp = new Date();
    
    exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30));    
	document.cookie = name + "=" + value + "; path=/" + ((exp == null) ? "" : "; expires=");
}

function GetCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i = 0; i < ca.length; i++) {
		var c = ca[i];
		
		while (c.charAt(0) == " ") c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	
	return null;
}

function DelCookie(name)
{
    document.cookie = name + "=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT"; 
}

function CheckEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
		return true
	}
	
	return (false)
}

function PhoneFormat(me)
{
	if (me.value.length > 0) {
		var tValue = me.value.replace(new RegExp("-", "gi"), "");
		
		tValue = tValue.substring(0, 3) + '-' + tValue.substring(3, 6) + '-' + tValue.substring(6);
		me.value = tValue;
	}
}

/*function subscribe(){
	if(document.frmSubscribe.txtEmail.value == "" || CheckEmail(document.frmSubscribe.txtEmail.value) == false ){
		alert("Please check your email address");
	}else{
		//document.frmSubscribe.action = document.frmSubscribe.url.value + "?act=subscribe";
		document.frmSubscribe.submit();
	}	
}*/
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false
	 }

	 return true					
}
	
	
function subscribe(){
	if(document.frmSubscribe.txtEmail.value == "" || CheckEmail(document.frmSubscribe.txtEmail.value) == false){
		alert("You have to enter correct email address for you to sign-up!");
	}
	else{
		document.frmSubscribe.submit();
	}
}