 function lib_open_img_window(src,width,height){
   if(width==0)
     width=500;
   width+=20;
   if(height==0)
     height=400;
   height+=20;
   if(height>600)
     height=600;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/img_preview.php?src='+src,'info','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
 
function open_window(src, id, width, height){
   if(width==0)   width=500;
   width+=20;
   if(height==0)  height=400;
   height+=20;
   if(height>600)  height=600;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/'+src+'?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }

 function popupWindow(module, field, id, width, height){
    width += 20;
    height += 50;
    info=window.open('/popup.php?module=' + module +'&field=' + field + '&id='+id, 'popup','scrollbars=no, toolbar=0, status=0, width='+width+', height='+height);
    info.focus();
 }

 function windowPopup(wUrl, wWidth, wHeight, wScrolls) 
{
    var xPos = (screen.availWidth  / 2) - (wWidth / 2);
    var yPos = (screen.availHeight / 2) - (wHeight / 2);
    if (!wScrolls) {
        wScrolls = 'yes';        
    } else {
        wScrolls = 'no';
    }
    window.open(wUrl, '', 'directories=no,location=no,menubar=no,resizable=yes,scrollbars='+wScrolls+',status=no,toolbar=no,width='+wWidth+',height='+wHeight+',left='+xPos+',top='+yPos);
}


 function opw(id,width,height){
   if(width==0)
	width=660;
  if(height==0)		
   height=700;
   
   height+=200;
   width+=100;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/fotogalery.php?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
 
  function opw2(id,width,height){
   if(width==0)
	width=660;
  if(height==0)		
   height=700;
   
   height+=200;
   width+=100;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/photos.php?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
  
  function opw3(id,width,height){
   if(width==0)
	width=660;
  if(height==0)		
   height=700;
   
   height+=200;
   width+=100;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/photos_rel.php?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }

 function opw4(id,width,height){
   if(width==0)
	width=660;
  if(height==0)		
   height=700;
   
   height+=200;
   width+=100;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/img/'+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }


function sendFormCup(){
    var form_data = $(".formBlock").find("input:text, textarea");

    if (form_data.length == 0) {
        return false;
    }

    $('#jx_loader').show();

    $.post(
        '/cup_jx.php',
        form_data,
        function (data){
            data_list = data.split("%%%split%%%");
            var err = data_list[0];
            var msg = data_list[1];
            if ( err == 'good' ){
                $('.formBlock .formmsg').html(msg);
                $('.formBlock .data').css('display','none');
            }
            else {
                $('.formBlock .formmsg').html('<div class="badmsg">'+msg+'</div>');
            }
            $('#jx_loader').hide();
        }
    );
        return false;
}
