////////// Precache images 

var imageLibrary = new Array();

imageLibrary["image1"] = new Image(144,69);
imageLibrary["image1"].src = "http://static.subsub.si/wp-content/themes/subsub/images/button_oglasise_white.jpg";
imageLibrary["image2"] = new Image(144,69);
imageLibrary["image2"].src = "http://static.subsub.si/wp-content/themes/subsub/images/button_oglasise_white.jpg";
imageLibrary["image3"] = new Image(139,69);
imageLibrary["image3"].src = "http://static.subsub.si/wp-content/themes/subsub/images/menuBannerBuilding.png";
imageLibrary["image4"] = new Image(139,69);
imageLibrary["image4"].src = "http://static.subsub.si/wp-content/themes/subsub/images/menuBannerBuildingOver.png";
imageLibrary["image5"] = new Image(139,69);
imageLibrary["image5"].src = "http://static.subsub.si/wp-content/themes/subsub/images/menuBannerMala.png";
imageLibrary["image6"] = new Image(139,69);
imageLibrary["image6"].src = "http://static.subsub.si/wp-content/themes/subsub/images/menuBannerMalaOver.png";

////////// Helpers

function toggleDisplay(divId) {
	var div = document.getElementById(divId);
	div.style.display = (div.style.display=="block" ? "none" : "block");
}

////////// Oglasi se

function controlField(form,checkbox,input) {
	with(form) {
	  if(eval(checkbox).checked) eval(input).disabled=false;
    else eval(input).disabled=true;
  }
}

function emptyvalidation(entered, alertbox) {
	with (entered) {
		if(value==null || value=="") {if(alertbox!="") alert(alertbox); return false;}
		else return true;
	}
}

function emailvalidation(entered, alertbox) {
	with (entered) {
		if (value==null || value=="") return true;
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {if (alertbox) alert(alertbox); return false;}
		else return true;
	}
}

function submitContact(form) {
	with(form) {
		if(emptyvalidation(contact_name, "Prosim vpiši svoje ime")==false) {contact_name.focus(); return false;}
		else if(emptyvalidation(contact_email, "Prosim vpiši svoj Email")==false) {contact_email.focus(); return false;}
		else if(emailvalidation(contact_email, "Prosim preveri svoj Email naslov")==false) {contact_email.focus(); return false;}
		form.submit();
	}
}
