function photopage(classname, id, imgfrom, imgto, imgcur) {    

    var url = '../ajax/images.php';
    var pars = 'classname='+classname+'&id='+id+'&imgfrom='+imgfrom+'&imgto='+imgto+'&imgcur='+imgcur;
    
	var myAjax = new Ajax.Request(
        url, 
        {method: 'get', parameters: pars, onFailure: reportError, onComplete: function(r){restoreimages(r)}});
       
    return false;
}

function restoreimages (r) {
    var ret=r.responseText;
    var imagesnav=$("imagesnav");
    imagesnav.innerHTML=ret;
}

function photoset (classname, id, imgcur) {    
    
    var url = 'ajax/imageplace.php';
    var pars = 'classname='+classname+'&id='+id+'&imgcur='+imgcur;
    
	var myAjax = new Ajax.Request(
        url, 
        {method: 'get', parameters: pars, onFailure: reportError, onComplete: function(r){restoreimageplace(r)}});
       
    return false;    
}

function restoreimageplace(r) {    
    var ret=r.responseText;
	
    var img=ret.substr(0,(ret.indexOf("</a>")+4));
    var comm=ret.substr((ret.indexOf("</a>")+4));
	
    var imagesnav=$("big_pic");
    imagesnav.innerHTML=img;
	
    var img_comment=$("img_comment");
    img_comment.innerHTML=comm;
}

function reportError(request) {
    alert('Sorry. There was an error.');
}

function myshow(field, id) {
    
    var reshow=1;
    if (show_desc) {
        if (show_desc==id) var reshow=0;
    }
    
    if (reshow) {
    	var posy=getPosition(field)[1];
    	var posx=getPosition(field)[0];    	
    	var div=$(id);
    	div.style.position="absolute";
    	div.style.top=eval(posy-20)+"px";
    	div.style.left=eval(posx-20)+"px";    
    	div.style.display="block";
    	show_desc=id;
    }
}

function myhide(id) {
    var div=$(id);
    div.style.display="none";
    show_desc=0;
}

function getPosition(obj) {
    var o=obj; 
    var x=0, y=0; 
    while(o) { 
        x+=o.offsetLeft; 
        y+=o.offsetTop; 
        o=o.offsetParent; 
    } 
    return [x,y]; 
}

var win;
function big_photo(f,w,h) {
    if (win) {
        win.close();        
    }
    
    win=window.open('photo.php?f='+f, null, "width="+(w+50)+",height="+(h+40)+",toolbar=0,scrollbars=no,resizable=no");    
    return false;
}  

function copy_info (form, chck) {    
    if (chck.checked==true) {        
        for (var i=0; i<form.elements.length; i++) {
            var el=form.elements[i];
            var shname='s_'+el.name;
            var shelem=document.getElementsByName(shname);
            if (shelem[0]) {
                shelem[0].value=el.value;
            }
        }
    }
}