function get_win(pictures, win_name, width, height){
	window.open("./pics.php?pic="+pictures, win_name, "left=100, top=100, width="+width+", height="+height);
}

function stat(message){
		window.status = message;
}

imgsrc = new Array();
		imgsrc[0] = './img/left_menu/cz/active/left_menu_active_1x1.gif';

img = new Array();
for (i=0; i<imgsrc.length; i++){
	img[i] = new Image();
	img[i].src = imgsrc[i];
}
		
function chng(i,imgname){
	if(document.images){
			document[imgname].src=img[i].src;
	}
}

function sub(frm_id){
     var s_frm = document.getElementById(frm_id);
     s_frm.submit();
}

function chng2(i, img_id){
	image=document.getElementById(img_id);
	image.setAttribute("src", imgsrc[i]);
}

function check_email(e) {
		ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
		for(i=0; i < e.length ;i++){
				if(ok.indexOf(e.charAt(i))<0){ 
					return (false);
				}	
		} 

		if (document.images) {
				re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
				re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
				if (!e.match(re) && e.match(re_two)) {
					return (-1);		
				} 
		}

}


function compare_addresses(){
     var frm = document.getElementById("eshop_order");

     frm.alt_contact.value = "";
     frm.alt_street.value = "";
     frm.alt_city.value = "";
     frm.alt_zipcode.value = "";

     frm.alt_contact.disabled = false;
     frm.alt_street.disabled = false;
     frm.alt_city.disabled = false;
     frm.alt_zipcode.disabled = false;

     if(frm.adress_check.checked){

          frm.alt_contact.value = frm.fname.value + " " + frm.lname.value;
          frm.alt_street.value = frm.street.value;
          frm.alt_city.value = frm.city.value;
          frm.alt_zipcode.value = frm.psc.value;
          
          frm.alt_contact.disabled = true;
          frm.alt_zipcode.disabled = true;
          frm.alt_street.disabled = true;
          frm.alt_city.disabled = true;
     }

     return true;
}


function validate_shop_order(){
var chyba = "Nesprávné nebo chybějící údaje:\n\n";
var fall = 0;
var emptypass = 0;
var frm = document.getElementById("eshop_order");

	if(frm.fname.value==""){
			chyba = chyba + "Jméno\n";
			fall=1;
	}if(frm.lname.value==""){
			chyba = chyba + "Příjmení\n";
			fall=1;
	}if(frm.phone.value==""){
			chyba = chyba + "Telefon\n";
			fall=1;
	}if(frm.email.value==""){
			chyba = chyba + "E-mail\n";
			fall=1;
	}else{
			if (!check_email(frm.email.value)){
					chyba = chyba + "Vaše E-mailová adresa není ve správném formátu.\n";
					fall=1;
			}
	}

	if (fall==1){
			window.alert(chyba);
			return false;
	}else{
			return true;
	}
}


function validate(){
var chyba = "Nesprávné nebo chybějící údaje:\n\n";
var fall = 0;
var emptypass = 0;
var frm = document.getElementById("regform");

	if(frm.fname.value==""){
			chyba = chyba + "Jméno\n";
			fall=1;
	}if(frm.lname.value==""){
			chyba = chyba + "Příjmení\n";
			fall=1;
	}if(frm.phone.value==""){
			chyba = chyba + "Telefon\n";
			fall=1;
	}if(frm.email.value==""){
			chyba = chyba + "E-mail\n";
			fall=1;
	}else{
			if (!check_email(frm.email.value)){
					chyba = chyba + "Vaše E-mailová adresa není ve správném formátu.\n";
					fall=1;
			}
	}if(frm.req.value==0){
			chyba = chyba + "Produkt, mám zájem o\n";
			fall=1;
	}

	if (fall==1){
			window.alert(chyba);
			return false;
	}else{
			return true;
	}

}

function blg_check(){
var chyba = "Chybějící údaje:\n\n";
var fall = 0;
var form = document.getElementById("blg_frm");
	if(form.nazev.value==""){
			chyba = chyba + "Název\n";
			fall=1;
	}if(form.obsah.value==""){
			chyba = chyba + "Obsah\n";
			fall=1;
	}
	
	if (fall==1){
			window.alert(chyba);
			return false;
	}else{
			return true;
	}
}

function shop_check(){
var chyba = "Chybějící údaje:\n\n";
var fall = 0;
var form = document.getElementById("blg_frm");
	if(form.nazev.value==""){
			chyba = chyba + "Název\n";
			fall=1;
	}if(form.obsah.value==""){
			chyba = chyba + "Popis\n";
			fall=1;
	}if(form.cena.value==""){
			chyba = chyba + "Cena\n";
			fall=1;
	}
	
	if (fall==1){
			window.alert(chyba);
			return false;
	}else{
			return true;
	}
}

function leave(locality){
	location.href=locality;
}

function get_dimens(objId, dim){
     obj = document.getElementById(objId);
     if(dim == 1){ // pocita se vyska, jinak sirka
          objDim = obj.style.height;
     }else{
          objDim = obj.style.width;
     }
     objDim = objDim.substring(0, objDim.length-2);
     return objDim;
}

function set_dimens(objId, dim, value){
     obj = document.getElementById(objId);
     if(dim == 1){
          obj.style.height = value;
     }else{
          obj.style.width = value;
     }
}

function fixHeight(left, right){
          var lh=document.getElementById(left).offsetHeight;
          var rh=document.getElementById(right).offsetHeight;
          document.getElementById(right).style.height=(lh>rh)? lh+"px" : rh+"px";
          document.getElementById(left).style.height=(rh>lh)? rh+"px" : lh+"px";
}

function getPositionByID(ob){
		obj = document.getElementById(ob);
		objLeft = obj.offsetLeft;
		objTop = obj.offsetTop;
}

function moveobj(id, x, y, ob){
	getPositionByID(ob);
	document.getElementById(id).style.top = objTop + y + "px";
	document.getElementById(id).style.left = objLeft + x + "px";
}

function confirm_link(message){
	var diag = window.confirm(message);
     if(diag){
		return true;
	}else{
          return false;
	}
}

function getLocation(){
	var loc = window.location;
	return loc;
}

function draw_credits(){
	document.write("<a class='credits' href='http://validator.w3.org/check?uri="+getLocation()+"'>W3C XHTML Validate</a>&nbsp;&nbsp;|&nbsp;&nbsp;");
	document.write("<a class='credits' href='http://jigsaw.w3.org/css-validator/validator?uri="+getLocation()+"'>W3C CSS Validate</a>");
}
