target="";
msg_del="Naozaj si prajete zmazať túto položku?";

function isClassName(e,myclass)
{

 if (e.className){
    var classNames=e.className.split(" ");
    for(var i=0;i<classNames.length;i++) if ( classNames[i]==myclass) return true;
 }
    return false;    
}

function button_onmouseover()
{
this.my_className=this.className;
this.className+="_hover";

}

function button_onmouseout()
{
this.className=this.my_className;
}


function new_window()
{
	target=this.parentNode.getElementsByTagName("input")[0];

	child=window.open("/galery/","Galery","width=800,height=600,top=100,left=100,resizable=1,scrollbars=yes");
	//child.document.write("mytarget","rene");
}

function img_open(patag)
{

	
	window.open(patag.href,"Galery","width=640,height=480,top=100,left=100,scrollbars=yes");
	//child.document.write("mytarget","rene");
	return false;
}


function select()
{
	window.opener.target.value=this.firstChild.value;
	window.close();
}

function reload_by_select(path)
{
 window.location=this.pathws+this.value+"/";
}

function togle()
{
	if (this.firstChild.checked) {
		this.firstChild.checked=false;
		this.className="tnimg";
	}
	else {
		this.firstChild.checked=true;
		this.className="tnimg_on";
	}

}


function togle_img_property()
{
//this=td tag
    this.firstChild.checked=true;
    var tr=this.parentNode;
    var img=tr.getElementsByTagName("img");
    for (var i=0;i<img.length;i++) img[i].className="";

     img=this.getElementsByTagName("img")[0];
    if (this.firstChild.checked) {
	img.className="border";
    } else img.className="";

    img=document.getElementById("product_img");
    if (img) img.src=pimages[this.firstChild.value].src;

}

function question(msg)
{
 return confirm(msg);
}

function check_form(mform)
{

 if ((mform.previous_form) && (mform.previous_form.dont_check)) return true;
 var items=mform.elements;
 for (var i=0;i<items.length;i++) {
    if (isClassName(items[i],"required")){
	if (items[i].value==""){
	 alert('"'+items[i].title+'"'+" musí byť vyplnené!!!");
	 return false;
	}
    }
 }
 return true;
}

function show_optional_form()
{
    var ele=this.parentNode.childNodes;
    for(var i=0;i<ele.length;i++ ){
	if ((ele[i].className=="optional_form") && (ele[i].tagName=="DIV")){ 
	    if (this.checked) ele[i].style.display="block";
	    else ele[i].style.display="none";
	}
    }
}

function init_elements_by_name(){
var items=document.getElementsByTagName("input");

for(var i=0,len=items.length;i<len;i++) {
	     if (isClassName(items[i],"browse")) {
		if (!items[i].browse){
			items[i].browse=true;
			var ele=document.createElement("input");
			ele.type="button";
			ele.value="...";
			items[i].parentNode.appendChild(ele);
			ele.onclick=new_window;
		   }	
		}
	    if (isClassName(items[i],"optional_form")) {
		items[i].onclick=show_optional_form;
		items[i].onclick();
		}
	    if (isClassName(items[i],"nextform")) {
		items[i].onmouseover=button_onmouseover;
		items[i].onmouseout=button_onmouseout;
		}
	    if (isClassName(items[i],"prevform")) {
		items[i].onmouseover=button_onmouseover;
		items[i].onmouseout=button_onmouseout;
		items[i].onclick=function(){this.dont_check=true;return true;};
		}
	}
var items=document.getElementsByTagName("div");
for(i=0,len=items.length;i<len;i++) {
	if (items[i].className=="tnimg") {
 
	items[i].onclick=togle;
	items[i].ondblclick=select;

	}

	if (items[i].className=="slideshow") {
 
	if (!items[i].slideshow) items[i].slideshow=new slideshow(items[i]);

	}
	
}
var item;
if (name)
if  (item=document.getElementsByName(name)[0])
	{
		item.onchange=function() {
			var priceitem;
			for(i=1;i<4;i++){
				if (priceitem=document.getElementById("price"+i)) priceitem.innerHTML=price[item.value][i-1]+",- Kč";
			}
		}
		//item.onchange();
	}

}




function init_elements_by_tagname(){
var items=document.getElementsByTagName("td");

for(i=0,len=items.length;i<len;i++) {
	if (items[i].className=="property_img") {
		
		items[i].onclick=togle_img_property;
		}
	

	}

}


//---------------ajax
function processRequest(){
	if (httpRequest.readyState==4){
		if(httpRequest.status==200){
			var target = document.getElementById("step");
			target.innerHTML = httpRequest.responseText;
			init_elements_by_name();
		}else{
			alert("Error "+httpRequest.status+": "+ httpRequest.statusText);
		}
	}
}

function send(paurl,parequest,patarget){

	var request = parequest;
	var url = paurl;
	if (window.ActiveXObject){
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		httpRequest = new XMLHttpRequest();
	}
	httpRequest.open("POST", url, true);
	httpRequest.onreadystatechange = function() { processRequest(); };
	httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf8');
	httpRequest.send(request);
}



obj=document.getElementById("form_properties");
if (obj) {
	obj.idp.onchange=function(){
		send("/ajax.php?action=add_properties_values","id="+obj.id.value+"&idp="+obj.idp.value);
	};
	send("/ajax.php?action=add_properties_values","id="+obj.id.value+"&idp="+obj.idp.value);
}


function checkbasket2()
{
if (!document.forms[1].shipping[0].checked){
	document.forms[1].payment[1].disabled=false;
	document.forms[1].payment[1].parentNode.parentNode.lastChild.style.color="";
}
if (!(document.forms[1].shipping[1].checked )) {
	document.forms[1].payment[0].disabled=false;
	document.forms[1].payment[0].parentNode.parentNode.lastChild.style.color="";
	document.forms[1].payment[2].disabled=false;
	document.forms[1].payment[2].parentNode.parentNode.lastChild.style.color="";
}
if (!(document.forms[1].shipping[2].checked )) {
	document.forms[1].payment[2].disabled=false;
	document.forms[1].payment[2].parentNode.parentNode.lastChild.style.color="";
	document.forms[1].payment[1].disabled=false;
	document.forms[1].payment[1].parentNode.parentNode.lastChild.style.color="";
}

if (document.forms[1].shipping[0].checked) {
		document.forms[1].payment[1].disabled=true;
		document.forms[1].payment[1].checked=false;
		document.forms[1].payment[1].parentNode.parentNode.lastChild.style.color="gray";
	}
if (document.forms[1].shipping[1].checked ) {
		document.forms[1].payment[0].disabled=true;
		document.forms[1].payment[0].checked=false;
		document.forms[1].payment[0].parentNode.parentNode.lastChild.style.color="gray";
		document.forms[1].payment[2].disabled=true;
		document.forms[1].payment[2].checked=false;
		document.forms[1].payment[2].parentNode.parentNode.lastChild.style.color="gray";
	}
if (document.forms[1].shipping[2].checked ) {
		document.forms[1].payment[2].disabled=true;
		document.forms[1].payment[2].checked=false;
		document.forms[1].payment[2].parentNode.parentNode.lastChild.style.color="gray";

		document.forms[1].payment[1].disabled=true;
		document.forms[1].payment[1].checked=false;
		document.forms[1].payment[1].parentNode.parentNode.lastChild.style.color="gray";
}
window.setTimeout('checkbasket2()',100);
}

