function imagePreview(url,width,height) {
    config='left=250,top=250,width='+width+',height='+height+',innerheight='+height+',innerwidth='+width+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
    stadion=window.open('','imagePreview',config);
    var otworzZW='';
    otworzZW+='<html><head>';
    otworzZW+='<title>Image preview</title>';
    otworzZW+='</head>';
    otworzZW+='<body bgcolor="white">';
    otworzZW+='<div align="center"><img src='+url+' border="0" alt="" /></div>';
    otworzZW+='</body></html>';
    stadion.document.write(otworzZW);
    stadion.focus();
//    setTimeout('stadion.stop()',4000);
}

function moviePreview(url,width,height) {
    config='left=250,top=250,width='+width+',height='+height+',innerheight='+height+',innerwidth='+width+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
    stadion=window.open('','imagePreview',config);
    var otworzZW='';
    otworzZW+='<html><head>';
    otworzZW+='<title>Movie preview</title>';
    otworzZW+='</head>';
    otworzZW+='<body bgcolor="white">';
    otworzZW+='<object   classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
                'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%">'+
                '<param name="movie" value="'+url+'"><param name="quality" value="high">'+
                '<param name="scale" value="noscale" />'+
                '<param name="BGCOLOR" value="#FFFFFF">'+
                '<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '+
                'bgcolor="#FFFFFF" scale="noscale" width="100%" height="100%"></embed></object>';
    otworzZW+='</body></html>';
    stadion.document.write(otworzZW);
    stadion.focus();
}


function previewNow(field, imageFile, maxx, maxy) {
    var img2src = new Image();
    img2src.src = imageFile;
    
    imgSwap     = document.getElementById(field);
    imgSwap.src = imageFile;

    if(img2src.width > maxx || img2src.height > maxy){
        //count both dimensions
        var xRatio = maxx / img2src.width;
        var yRatio = maxy / img2src.height;
        var width = 0;
        var height= 0;
        //check which one has smaller ratio and use it for both x and y
        if( xRatio < yRatio ){
           width  = img2src.width  * xRatio;
           height = img2src.height * xRatio;
        } else {
           width  = img2src.width  * yRatio;
           height = img2src.height * yRatio;
        }

        //change size
        imgSwap.width  = width;
        imgSwap.height = height;
    }else{
        imgSwap.width  = img2src.width;
        imgSwap.height = img2src.height;
    }
}

function showImageDiv(divId, image,x,y){
    element = document.getElementById(divId);
    element.innerHTML = '<img src="' + image + '" border=0>';
}

function showMovieDiv(divId, url){
    element = document.getElementById(divId);
    element.innerHTML = '<object   classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
                'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1024" height="768" align="left">'+
                '<param name="movie" value="'+url+'"><param name="quality" value="high">'+
                '<param name="scale" value="noscale" />'+
                '<param name="align" value="left" />'+
                '<param name="BGCOLOR" value="#FFFFFF">'+
                '<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '+
                'bgcolor="#FFFFFF" scale="noscale" width="1024" height="768"></embed></object>';
}


function setSelectValueOrEmpty(selectObject, value){
    var i = selectObject.length;
    var resp = false;
    var j = 0;
    for(var j = 0; j< i; j++){
    
        if( selectObject.options[j].value == value ){
            resp = true;
        }
    }

    if(resp == true){
        selectObject.value = value;
    }else{
        selectObject.value = '';
    }
}


function MM_preloadImages() { //v3.0
    var d=document; 
    if(d.images){ 
        if(!d.MM_p) 
            d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
        for(i=0; i<a.length; i++)
            if (a[i].indexOf("#")!=0){ 
                d.MM_p[j]=new Image; 
                d.MM_p[j++].src=a[i];
            }
    }
}



