// form related functions
function subscribe(){
	var el = document.getElementById('email');
	if (el){
		email = el.value;
		if (checkEmail(email)){
			var f = document.getElementById('eNewsletter');
			if (f){
				if ( f.formlang.value == "en") {
					popupsmall("", 558, 280, "subscribe");
				} else {
					popupsmall("", 558, 247, "subscribe");
				}
				f.submit();
			}
			return false;
		}else{
			alert("Email address is invalid");
			return false;
		}
	}
}

function subscribe_lite() {
    var el = document.getElementById('newsletter_email');
    if (el) {
        if ( el.form.formlang.value == "en") {
            popupsmall("", 558, 280, "subscribe");
        } else {
            popupsmall("", 558, 247, "subscribe");
        }
    }
}

function popupsmall(__loc, __w, __h, __anchor){
	__anchor = (__anchor==null) ? 'small_win' : __anchor;
	opwin(__loc,__w,__h,'yes','yes','no',__anchor);
}

function opwin(__url, __w, __h,__r,__sb,__s, __name){
	__r = (__r==null) ? 'yes' : __r;
	__sb = (__sb==null) ? 'yes' : __sb;
	__s = (__s==null) ? '1' : __s;
	__name = (__name==null) ? 'mywin' : __name;
	if (window.screen) {
	    cw = Math.floor((screen.availWidth-__w)/2);
	    ch = Math.floor((screen.availHeight-__h)/2);
	}
	mywin = window.open(__url,__name,'width='+__w+',height='+__h+'resizable='+__r+',scrollbars='+__sb+',status='+__s+',left='+cw+',top='+ch);
	mywin.opener = this;
	mywin.focus();
}

function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
		return true;
	}else {
		return false;
	}
}
