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 CheckEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
		return true
	}
	
	return (false)
}

function subscribe(){
	if(document.frmSubscribe.txtemail.value == "" || CheckEmail(document.frmSubscribe.txtemail.value) == false )
		alert("Please Check Your Email Address");
	else{
		//alert("Thank you for signing up!");		
		document.frmSubscribe.action = ""; 
		document.frmSubscribe.submit();  
					
		}
	
}

//--------- Bookmark Us ------------//

function bookmarksite(){
var myloc = location.href;
var title = "Moral Fabrix";
if (document.all)
window.external.AddFavorite(myloc,title);
else if (window.sidebar)
window.sidebar.addPanel(title, myloc,"")
}
//End

//--------------Send to Friend---------------//

function sendtofriend() {
	var URL
	URL = location.href;
	window.open('http://www.moralfabrix.com/wp-content/themes/Moral Fabrix/sendtofriend.html?page='+URL, 'EmailWindow', 'scrollbars=yes,width=772,height=318');
}


function ordertransact() {
	eForm = document.transaction;
	
	if (eForm.txtfname.value=="") {
		alert("Please type in your name.");
		eForm.txtfname.focus();
		return;
	}
	
	else if (eForm.txtlname.value=="") {
		alert("Please type in your last name.");
		eForm.txtlname.focus();
		return;
	}
	
	else if (eForm.txtaddress.value=="") {
		alert("Please type in your address.");
		eForm.txtaddress.focus();
		return;
	}

	else if (eForm.txtcity.value=="") {
	alert("Please enter your city.");
	eForm.txtcity.focus();
	return;
	}
	
	else if (eForm.txtstate.value=="") {
		alert("Please enter your state.");
		eForm.txtstate.focus();
		return;
	}
	
	else if (eForm.txtcountry.value=="") {
		alert("Please enter your country.");
		eForm.txtcountry.focus();
		return;
	}
	
	else if (eForm.txtzip.value=="") {
		alert("Please enter your zipcode.");
		eForm.txtzip.focus();
		return;
	}
	
	else if (eForm.txtemail.value=="") {
		alert("Please enter your email address.");
		eForm.txtemail.focus();
		return;
	}
					
	else if (CheckEmail(eForm.txtemail.value)==false) {
		alert("Please check your Email Address.");
		eForm.txtemail.focus();
		return;
	}
	
	document.transaction.action="http://www.moralfabrix.com/checkout-paypal/";
	document.transaction.submit();
	eForm.formAction.value = "Submit";
	eForm.submit();
	}
