function toggleCalendar() {
    h = document.getElementById('calendar_hidden').style;
    s = document.getElementById('calendar_show').style;
    if (h.display=='none') {
        h.display = 'block';
        s.display = 'none';
    } else {
        h.display = 'none';
        s.display = 'block';
    }
};

function ShowElement(element,type) {
 if (type==0) {
 if (document.getElementById(element).style.display=="none")
    {
    document.getElementById(element).style.display="";
    } else {
    document.getElementById(element).style.display="none";
    };
 };
 if (type==1) {document.getElementById(element).style.display="";}    
 if (type==2) {document.getElementById(element).style.display="none";} 
};

function ShowPreview(file,img) {
 document.getElementById(img).src=document.getElementById(file).value;
 document.getElementById(img).style.display="";
};

function CanAdd(file) {
 str=document.getElementById(file).value.length;
 file_add.style.display="none";
 if((document.getElementById(file).value.substring(str,str-4) != '.gif')&&(document.getElementById(file).value.substring(str,str-4) != '.jpg')&&(document.getElementById(file).value.substring(str,str-5) != '.jpeg')&&(document.getElementById(file).value.substring(str,str-4) != '.png')){
    file_add.style.display="";
    document.getElementById('file').focus();
    return false;
 }
document.getElementById(form_add).onsubmit = "return true;";

return true; 
};

function ge(id) {
 return document.getElementById(id);
};

function check_extension(filename,extension)
{
	var reg = new RegExp("\."+extension+"$","i");
	return reg.test(filename);
};

function redirect (href) {
 window.location=href;
};

var helpWin;
function showHelp(title,str) {
 if (helpWin) {
  if (!helpWin.closed){helpWin.close();}
 }
 helpWin = window.open("","_blank","width=400,height=400,left=200,top=100,scrollbars=1,toolbar=0,location=0,menubar=0,resizable=0,status=0");
 helpWin.focus();
 helpWin.document.write('<html><head><meta http-equiv="content-type" content="text/html; charset=windows-1251" /><link rel="stylesheet" type="text/css" href="/styles/admin.css" media="all" /><title>'+title+'</title></head><body><table width="100%" height="100%"><tr><td style="height: 100%; font-size: 11px; text-align: center; padding: 20px;">'+str+'</td></tr><tr><td style="text-align: center; padding: 20px;"><a href="javascript: window.close();"><img width="112" height="20" src="/img_admin/close.gif"></a></td></tr></table></body></html>');
 };

 function showPicture(url)
 {
		w=100;
		h=100;
    left_ = Math.floor((screen.availWidth - w)/2);
    top_ = Math.floor((screen.availHeight - h)/2);
    win = window.open ('', '_blank', 'width='+w+',height='+h+',left='+left_+',top='+top_+',scrollbars=no,resizeable=yes');
    s='<html><head><title>Каталог</title></head><body style="padding:0px; margin:0px;"><center style="vertical-align:top"><a href="#" onclick="javascript: window.close();"><img onload="window.opener.ResizeWindowToImage(window,document.getElementById(\'bimage\'));"  src="'+url+'" alt="Закрыть" border="0" id="bimage" /></a></center><br></body></html>';
    win.document.write(s);

};

function ShowPictureSize(url,w,h)
{
    if (w>screen.availWidth)
    {
        w = screen.availWidth;
    };
    if (h>screen.availHeight)
    {
        h = screen.availHeight;
    };
    left_ = Math.floor((screen.availWidth - w)/2);
    top_ = Math.floor((screen.availHeight - h)/2);
    win = window.open ('', '_blank', 'width='+w+',height='+h+',left='+left_+',top='+top_+'scrollbars=yes,resizeable=yes');
    s='<html><head><title>Каталог</title></head><body style="padding:0px; margin:0px;"><center style="vertical-align:top"><a href="#" onclick="javascript: window.close();"><img src="'+url+'" alt="Закрыть" border="0" id="bimage" /></a></center><br></body></html>';
    win.document.write(s);
};

function ResizeWindowToImage (win,image)
{
    w=image.width;
    h=image.height;
    left_ = Math.floor((screen.availWidth - w)/2);
    top_ = Math.floor((screen.availHeight - h)/2);
    //win.resizeTo(w,h);
    win.resizeTo(w+10,h+50);
    win.moveTo(left_,top_);
    //win = window.open ('', '_blank', 'width='+w+',height='+h+',left='+left_+',top='+top_+',scrollbars=no,resizeable=yes');
    //s='<html><head><title>Каталог</title></head><body style="padding:0px; margin:0px;"><center style="vertical-align:top"><a href="#" onclick="javascript: window.close();"><img src="'+image.src+'" alt="Закрыть" border="0" id="bimage" /></a></center><br></body></html>';
    //win.document.write(s);
    //win.close();
};

 function showWindow(url,w,h) 
 {
    left_ = Math.floor((screen.availWidth - w)/2);
    top_ = Math.floor((screen.availHeight - h)/2);
    win = window.open (url, '_blank', 'width='+w+',height='+h+',left='+left_+',top='+top_+',scrollbars=yes');
};

