var image_bg1 = new Image();
image_bg1.src = "/includes/ultimatecure_images/_uc_bg_f1.png";

var image_bg2 = new Image();
image_bg2.src = "/includes/ultimatecure_images/_uc_bg_f2.png";

var image_navigation = new Image();
image_navigation.src = "/includes/ultimatecure_images/_navigation_f1.png";

var image_bgImage = new Image();
image_bgImage.src = "/includes/ultimatecure_images/bg_img.png";

var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
  myHeight = document.documentElement.clientHeight;
}


function showCaptcha() {
	var siteDiv = document.getElementById("site");
	
	var captchaBoxWrapper = document.getElementById("captchaBoxWrapper");
	var backgroundDiv = document.getElementById("screen_background");
	backgroundDiv.style.height = myHeight + "px";

	backgroundDiv.style.display = "block";
	captchaBoxWrapper.style.display = "block";

	window.onresize=resizeCaptchaPopup;
	backgroundDiv.onclick=hideCaptchaPopup;
	
	return false;
}


function resizeCaptchaPopup (e) {
	var siteDiv = document.getElementById("site");
	var backgroundDiv = document.getElementById("screen_background");
	if (siteDiv.clientHeight < document.body.clientHeight) {
		backgroundDiv.style.height = document.body.clientHeight + "px";
	} else {
		backgroundDiv.style.height = siteDiv.clientHeight + "px";
	}
}

function hideCaptchaPopup() {
	var referencePopupDiv = document.getElementById("captchaBoxWrapper");
	referencePopupDiv.style.display = "none";	
}

function submitContactForm() {
	var captchaValue = document.getElementById("captchaValue");
	var captchaField = document.getElementById("captchaField");
	captchaValue.value = captchaField.value;
	
	var contactForm = document.getElementById("contactForm");
	contactForm.submit();
}

function validateForm(lang){
	var contact_email = document.getElementById("email").value;

	if(validateEmail(contact_email) ){
		if(lang =="en"){
			alert("Please provide a valid E-Mail")
		}else if (lang =="bg"){
			alert("Please provide a valid E-Mail")
		}	
		return false;
	}else return true;
}

function validateEmail(email){
	
	var indexAt;
	var indexDot;
	indexAt = email.indexOf("@");
	indexDot = email.lastIndexOf(".");	
	
	if (indexAt>0 && indexDot > indexAt+1 && indexDot < (email.length-1)) {
			return false;
	} else {
		return true;
	}
	
}