/**
* @author  Stayko Dimitrov
* @version 1.0
*
* menu.js
* Modification History  :
*
* 1.0 	rs 	Initial
*/

var hght = screen.availHeight;

function regnews () {
		if (check_data()) {
			var imageViewWindow = window.open("newsletter/do_register.php?email="+document.forms['newsletter'].email.value, "_blank", "width=350, height=250, location=no,toolbar=no,status=no,resizeable=yes,scrollbars=no");
			imageViewWindow.focus();
		}
}

function openImage (site, settings) {
		var imageViewWindow = window.open(site,"imageViewWindow",settings + "location=no,toolbar=no,status=no,resizeable=yes,scrollbars=no");
		imageViewWindow.focus();
}

function go_config_top () {
	window.open(document.config.configurator.value, "_blank", "location=no,toolbar=no,status=yes,resizeable=no,scrollbars=yes,width=620,height="+hght+",screenX=1,screenY=1,left=1,top=1");
	document.config.configurator.value = "Select"
}

function go_config (tip, id) {
	window.open("config/?type=" + tip + "&id=" + id, "_blank", "location=no,toolbar=no,status=yes,resizeable=no,scrollbars=yes,width=620,height="+hght+",screenX=1,screenY=1,left=1,top=1");
	document.config.configurator.value = "Select"
}

function print (t) {
	window.open("print.php?id=" +t,"_blank","location=no,toolbar=no,status=yes,scrollbars=yes, width=606,height="+hght+",screenX=1, screenY=1,left=1,top=1,")
}

function is_valid_email(form, element) {
	if ((document.forms[form].elements[element].value.indexOf("@")<1) || (((document.forms[form].elements[element].value.lastIndexOf("."))-(document.forms[form].elements[element].value.indexOf("@")))<2) || (((document.forms[form].elements[element].value.length-1)-(document.forms[form].elements[element].value.lastIndexOf("."))))>3 || (((document.forms[form].elements[element].value.length-1)-(document.forms[form].elements[element].value.lastIndexOf(".")))<2) || document.forms[form].elements[element].value.indexOf("@") != document.forms[form].elements[element].value.lastIndexOf("@") || document.forms[form].elements[element].value.indexOf(" ") != -1 || document.forms[form].elements[element].value.indexOf(";") != -1 || document.forms[form].elements[element].value.indexOf(",") != -1) {
		return false;
	} else {
		return true
	}
}

// Checks email for Newsletter Registration
function check_data() {
	if (document.forms['newsletter'].email.value == '') {
		alert("E-mail is empty")
		return false;
	} else  {
		if (!is_valid_email('newsletter', 'email')) {
			alert("E-mail is invalid")
			return false;
		} else {
			return true;
		}
	}
}