/*
 * file to obchod module
 * =====================
 *
 **/

function zoom(id,zoomw, zoomh, zoompath, zoomtitle ){
    zoom_console = window.open("",id,"left=120, top=120, width="+zoomw+",height="+zoomh+",scrollbars=auto");
    zoom_console.document.write("<HTML><TITLE>IHAHA</TITLE><BODY style=\"margin:0;padding:0;margin-top:50px;background-image: url(images/obchod/napis.gif);background-repeat: no-repeat\" bgcolor=#ffffff>");
    zoom_console.document.write('<div align="center"><img onclick="window.close()" style="border: 10px solid #D95B1D;cursor:hand" src="'+zoompath+'"  alt="   IHAHA   '+"\n    " + zoomtitle  + "\n \n" + '    click = close" border="0"></div>');
    zoom_console.document.write("</BODY></HTML>");
    zoom_console.document.close();
    return true;
}


function populate(x,object)
{
    cacheobj = document.getElementById('stage'+object);
    for (m=cacheobj.options.length-1;m>0;m--)
    cacheobj.options[m]=null;
    selectedarray=eval(x);
    for (i=0;i < selectedarray.length;i++)
        cacheobj.options[i]=new Option(selectedarray[i].text,selectedarray[i].value);
    cacheobj.options[0].selected=true;
    satna_change_img(object);
}



function satna_change_img (stage)
{
    image_view = document.getElementById('satna_img_'+stage);
    cacheobj = document.getElementById('stage'+stage);

    s = cacheobj.options[cacheobj.selectedIndex].value;
    image_src =s.substr(0,s.indexOf('&&&'));
    if (image_src){
        image_view.src = image_src;
    }


   // image_view.title = s.substr(s.indexOf('&&&')+3,s.indexOf('%%%')-(s.indexOf('&&&')+3));
    image_view.name = s.substr(s.indexOf('%%%')+3);

}

function satna_zoom(objekt)
{
    /*window.open(objekt.title,'zoom','height=600px,width=600px,scrollbars=1');*/

    
    if (objekt.name != ''  && objekt.name != 'pepa'){
        zoom_console = window.open("show_shop_item.php?id="+objekt.name,objekt.id,"left=120, top=120, width=640,height=640,scrollbars=yes");
    }
    else {

        if ( objekt.title == 'zvětšit foto a zobrazit informace o zboží') {
            //pepu zvetsit nelze ;)
        }
        else {
            if(objekt.title!='') {
                alert(objekt.title);
                zoom_console = window.open("",objekt.id,"left=120, top=120, width=640,height=640,scrollbars=no");
                zoom_console.document.write("<HTML><TITLE>IHAHA</TITLE><BODY style=\"margin:0;padding:0;margin-top:50px;background-image: url(images/obchod/napis.gif);background-repeat: no-repeat\" bgcolor=#ffffff>");
                zoom_console.document.write('<div align="center"><img onclick="window.close()" style="border: 10px solid #D95B1D;cursor:hand" src="'+objekt.title+'"  alt="" border="0"></div>');
                zoom_console.document.write("</BODY></HTML>");
                zoom_console.document.close();
            }
        }
    }
    /*  return true;*/
}


function satna_default( stage )
{
    image_view = document.getElementById('satna_img_'+stage);
    var image_pepa;
    image_pepa = new Array();
    image_pepa[1] = 'images/obchod/satna_hlava.jpg'
    image_pepa[2] = 'images/obchod/satna_trup.jpg'
    image_pepa[3] = 'images/obchod/satna_nohy.jpg'
    image_pepa[4] = 'images/obchod/satna_chodidla.jpg'
    image_src = image_pepa[stage] ;

    image_view.src = image_src;

    elSel = document.getElementById('stage'+stage);
    var i;
    for (i = elSel.length - 1; i>=0; i--) {
        elSel.remove(i);
    }

    image_view.name = 'pepa';

}
