function checkDelivery() {
    if ($('deliverySame')) {
        same = DWRUtil.getValue('deliverySame');
        if (same) {
            address = DWRUtil.getValue('billingAddress');
            DWRUtil.setValue('deliveryAddress', address);
            zip = DWRUtil.getValue('billingZip');
            DWRUtil.setValue('deliveryZip', zip);
            $('deliveryAddress').disabled = true;
            $('deliveryZip').disabled = true;
        } else {
            $('deliveryAddress').disabled = false;
            $('deliveryZip').disabled = false;
        }
    }
}

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 checkPresent(id, normalColor) {
    if (DWRUtil.getValue(id) == '') {
        $(id).style.backgroundColor = c;
        return false;
    } else {
        $(id).style.backgroundColor = normalColor;
        return true;
    }
}

function checkEmail(id) {
    str = DWRUtil.getValue(id);
    if (str == '') {
        $(id).style.backgroundColor = c;
        return false;
    } else if (echeck(str)) {
        $(id).style.backgroundColor = 'white';
        return true;
    } else {
        $(id).style.backgroundColor = c;
        return false;
    }
}

function hoverSection(s) {
    var td = document.getElementById(s);
    // td.style.background="#ffffff";
    td.style.border="3px solid #00ff33";
}
function unhoverSection(s) {
    var td = document.getElementById(s);
    // td.style.background="transparent";
    td.style.border="3px solid #eeeeff";
}
function popSearchBox() {
    if (DWRUtil.getValue('searchField') == "") {
        DWRUtil.setValue('searchField', "Search this website...");
    }
}

function focusSearchBox() {
    if (DWRUtil.getValue('searchField') == "Search this website...") {
        DWRUtil.setValue('searchField', "");
    }
}
function popEmailBox() {
    if (document.getElementById("email")) {
        if (DWRUtil.getValue('email') == "") {
            DWRUtil.setValue('email', "Your email address..");
        }
    }
}

function focusEmailBox() {
    if (DWRUtil.getValue('email') == "Your email address..") {
        DWRUtil.setValue('email', "");
    }
}

function popBoxes() {
    popSearchBox();
}

