function OpenImage(img_title, photo_id, img_width, img_height) {
  var name = Math.round(Math.random()*1000000);
  
  preview_window=window.open("/show_photo.php?photo_id="+photo_id, "photo_"+name, "width="+(img_width+100)+",height="+(img_height+120)+",toolbar=0,scrollbars=0,statusbar=0,resizable=1");
/*  preview_window.document.open();
  preview_window.document.clear;
  preview_window.document.write("<html>");
  preview_window.document.write("<head><title>"+img_title+"</title></head>");
  preview_window.document.write("<body leftmargin=0 topmargin=0>");
  preview_window.document.write("<table width=100% height=100% border=0 cellspacing=5 cellpadding=0><tr><td align=center valign=middle><img style='cursor: pointer;' src='"+img_link+"' border=0 onClick=\"self.close();\"></td></tr></table>");
  preview_window.document.write("</body>");
  preview_window.document.write("</html>");
  preview_window.document.close(); */
  preview_window.focus(true);
}


function OpenImageLarge(img_title, photo_id, img_width, img_height) {
  var name = Math.round(Math.random()*1000000);
  
  preview_window=window.open("/show_photo_large.php?photo_id="+photo_id, "photo_"+img_title, "width="+(img_width+20)+",height="+(img_height+20)+",toolbar=0,scrollbars=0,statusbar=0,resizable=1");
  preview_window.focus(true);
}

function OpenImagesLarge(img_title, image_id, img_width, img_height) {
  var name = Math.round(Math.random()*1000000);
  
  preview_window=window.open("/show_image_large.php?image_id="+image_id, "photo_"+img_title, "width="+(img_width+20)+",height="+(img_height+20)+",toolbar=0,scrollbars=0,statusbar=0,resizable=1");
  preview_window.focus(true);
}

function OpenCertificate(img_title, photo_id, img_width, img_height) {
  var name = Math.round(Math.random()*1000000);
  
  preview_window=window.open(photo_id, "photo_"+img_title, "width="+(img_width+20)+",height="+(img_height+20)+",toolbar=0,scrollbars=0,statusbar=0,resizable=1");
  preview_window.focus(true);
}


function OpenPrint(link)
 {
   print_window=window.open(link, 'wydruk', "width="+690+",height="+500+",toolbar=0,scrollbars=1,statusbar=0,resizable=1"); 
   print_window.focus(true);
 }
 
function OpenPopup(wlink,width,height,scroll)
 {
   popup_window=window.open(wlink, 'informacja', "width="+width+",height="+height+",toolbar=0,scrollbars=1"+",statusbar=0,resizable=1"); 
   popup_window.document.location = wlink;
   popup_window.focus(true);
 }
 
  
function OpenW(link,width,height)
 {
   p_window=window.open(link, 'informacja', "width="+width+",height="+height+",toolbar=0,scrollbars=1,statusbar=0,resizable=1"); 
   p_window.focus(true);
 }
 
 
function OpenProduct(wnd_title, wnd_link, wnd_width, wnd_height) {
  var name = Math.round(Math.random()*1000000);
  preview_window=window.open("", "item_"+name, "width="+(wnd_width+30)+",height="+(wnd_height+30)+",toolbar=0,resizable=1,scrollbars=1");
  preview_window.document.location=wnd_link;
  preview_window.document.title=wnd_title;
  preview_window.focus(true);
}

function OpenCompare(cmp_title, cmp_link, cmp_show) {
  compare_window=window.open("", "compare", "toolbar=0,scrollbars=1, resizable=1");
  compare_window.document.location = cmp_link;
//  if(compare_window.opener == null)
    compare_window.opener = self;
}

function ReloadFrame(frame_name) {
  parent.frames[frame_name].location.reload();
}

function LoadFrame(frame_name, frame_link) {
  parent.frames[frame_name].location = frame_link;
}

function doCompareListSubmit(aForm, aAction) {
  var name = Math.round(Math.random()*1000000);
  var oldAction = aForm.action;
  compare_window=window.open("", "compare_"+name,"width="+screen.width+"-50,height="+screen.height+"-50,toolbar=0,scrollbars=1,resizable=1");
  aForm.target = "compare_"+name;
  aForm.action = aAction;
  aForm.submit();
  aForm.action = oldAction
  aForm.target='';
  compare_window.focus(true);
}

function doPrintListSubmit(aForm, aAction) {
  var name = Math.round(Math.random()*1000000);
  var oldAction = aForm.action;
  print_window=window.open("", "print_"+name,"width=730,height=500,toolbar=0,scrollbars=1,resizable=1");
  aForm.target = "print_"+name;
  aForm.action = aAction;
  aForm.submit();
  aForm.action = oldAction
  aForm.target='';
  print_window.focus(true);
}


function doConfiguratorPrintSubmit(aForm, aAction) {
  var name = Math.round(Math.random()*1000000);
  var oldAction = aForm.action;
  conf_window=window.open("", "configurator_print_"+name,"width=650,height=500,toolbar=0,scrollbars=1,resizable=1");
  aForm.target = "configurator_print_"+name;
  aForm.action = aAction;
  aForm.submit();
  aForm.action = oldAction
  aForm.target='';
  conf_window.focus(true);
}

function doComputerPreviewSubmit(aForm, aAction) {
  var name = Math.round(Math.random()*1000000);
  var oldAction = aForm.action;
  compare_window=window.open("", "configurator_preview_"+name,"width=960,height=720,toolbar=0,scrollbars=1,resizable=1");
  aForm.target = "configurator_preview_"+name;
  aForm.action = aAction;
  aForm.submit();
  aForm.action = oldAction
  aForm.target='';
  compare_window.focus(true);
}

function doBasketPrintSubmit(aForm, aAction) {
  var name = Math.round(Math.random()*1000000);
  var oldAction = aForm.action;
  basket_window=window.open("", "basket_print_"+name,"width="+screen.width+"-50,height="+screen.height+"-50,toolbar=0,scrollbars=1,resizable=1");
  aForm.target = "basket_print_"+name;
  aForm.action = aAction;
  aForm.submit();
  aForm.action = oldAction
  aForm.target='';
  basket_window.focus(true);
}

function DetectImageSize(picName,picTitle){
      picURL=picName;
      newWindow=window.open(picURL,'newWin','toolbar=no,width='+picName.width+',height='+picName.height);
      newWindow.document.write('<html><head><title>'+picTitle+'<\/title><\/head><body style=\"background: url("'+picURL+'" no-repeat;\"><\/body><\/html>');
      newWindow.resizeBy(picName.width-newWindow.document.body.clientWidth,picName.height-newWindow.document.body.clientHeight);
      newWindow.focus();
   } 



            function fitPic() {
                if (window.innerWidth){
                    iWidth = window.innerWidth;
                    iHeight = window.innerHeight;
                }else{
                    iWidth = document.body.clientWidth;
                    iHeight =document.body.clientHeight;
                }
                iWidth = document.images[0].width - iWidth + 20;
                iHeight = document.images[0].height - iHeight + 20;
                window.resizeBy(iWidth, iHeight);
            };
			
			
function OpenImageBig(image)
 {
 
       picURL=bigimages[image];
	   picName=picURL;
	   
      newWindow=window.open('/photo.php?id='+picURL,'Powiększenie','toolbar=no,width='+400+',height='+300);
      newWindow.focus();
  
   
   
 //   window.open(,'Powiększenie','width=775,height=550,top=5,left=5,resizable,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no');
  }


        			
			
function OpenImageBigID(image)
 {
 
       picURL=image;
	   picName=picURL;
	   
      newWindow=window.open('/photoid.php?id='+picURL,'Powiększenie','toolbar=no,width='+400+',height='+300);
      newWindow.focus();
  
   
   
 //   window.open(,'Powiększenie','width=775,height=550,top=5,left=5,resizable,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no');
  }

