var isMSIE = (navigator.appName == "Microsoft Internet Explorer");

function updatePreview(edit,preview) {
        if(document.getElementById(edit).value=='') {
                document.getElementById(preview).src = '/images/1x1.gif';
        } else {
                document.getElementById(preview).src = document.getElementById(edit).value;
        }
}

function files(){
        var width = 750;
        var height = 450;
        var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
        var x = parseInt(screen.width / 2.0) - (width / 2.0);
        var y = parseInt(screen.height / 2.0) - (height / 2.0);

        if (typeof(scroll) == "undefined")
                scroll = "no";

        if (isMSIE) {
                // Pesky MSIE + XP SP2
                width += 15;
                height += 35;

                //var features = "resizable:no;scroll:no;status:no;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;";
                //window.showModalDialog(url, window, features);
        }

        var win = window.open("/common/js/filemanager/frameset.php", "files", "top=" + y + ",left=" + x + ",scrollbars="+ scroll +",modal=yes,width=" + width + ",height=" + height + ",resizable=yes");
        win.focus();
}

function images(){
        var width = 750;
        var height = 450;
        var x = parseInt(screen.width / 2.0) - (width / 2.0);
        var y = parseInt(screen.height / 2.0) - (height / 2.0);

        if (isMSIE) {
                // Pesky MSIE + XP SP2
                width += 15;
                height += 35;
        }

        var win =       window.open("/common/js/imagemanager/images.php","images","top=" + y + ",left=" + x + ",scrollbars=no,width=" + width + ",height=" + height + ",resizable=yes");

        try {
                win.focus();
        } catch (e) {
        }


}


function displayBlock(block, display) {
    var now = new Date();
    oBlock = document.getElementById(block);
    oBlock.style.display = (display) ? "inline" : "none";
}

function checkrequired(which,reqfields){
        for (i=0;i<which.length;i++){
          var tempobj=which.elements[i];
                for(j=0;j<reqfields.length;j++) {
                        if(reqfields[j]==tempobj.name && tempobj.value=='') {
                                alert('Необходимо заполнить все обязательные поля');
                                return false;
                        }
                }
        }
        return true
}


function checkrequired_orig(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}
else
document.getElementById('blah').disabled=true;

return true
}

function showPicture(src,title)
{
  var w=Math.floor(screen.availWidth)-50;
  var h=Math.floor(screen.availHeight)-50;
  window.open("/show_picture.php?src="+src+"&title="+title,"","scrollbars=1,resizable=1,menubar=0,width="+w+",height="+h+",left=20,top=1");
}
