function ajaxRatePhoto(id,gal,rate,gdc){
    $.get(document.location.pathname,{p:'3',action:'ratePhoto', id:id, gal:gal, rate:rate, gdc:gdc}, function(result){
    UpdateRateButtons(result,gdc);
    });
}

function ajaxRateVideo(id,gal,rate,gdc){
    $.get(document.location.pathname,{p:'3',action:'rateVideo', id:id, gal:gal, rate:rate, gdc:gdc}, function(result){
    UpdateRateButtons(result,gdc);
    });
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
    do {
    curleft += obj.offsetLeft;
    curtop += obj.offsetTop;
    } while (obj = obj.offsetParent);
    }
    return [curleft,curtop];
}

function setLeft(obj,lyr)
    {
    if (document.getElementById(lyr))
    {
    var coors = findPos(document.getElementById(obj));
    var x = document.getElementById(lyr);
    x.style.top = coors[1] + 'px';
    x.style.left = coors[0] + 'px';
    }
}

function setRight(obj,lyr){
    if (document.getElementById(lyr))
    {
    var coors = findPos(document.getElementById(obj));
    var x = document.getElementById(lyr);
    var y = document.getElementById(obj);
    x.style.top = coors[1] + 'px';
    var wid = y.style.width;

    x.style.left = coors[0] + parseInt(wid.replace(/px/,"")) - 76 + 'px';
    }
}

function popup(url,windowname,width,height,features)
    {
    width=(width)?width:screen.width/2;
    height=(height)?height:screen.height/2;
    var screenX = (screen.width/2 - width/2);
    var screenY = (screen.height/2 - height/2);
    var features= "width=" + width + ",height=" + height +",scrollbars=no,status=no";
    features += ",screenX=" + screenX + ",left=" + screenX;
    features += ",screenY=" + screenY + ",top=" + screenY;

    var mywin=window.open(url, windowname, features);
    if (mywin)
    mywin.focus();
    return mywin;
}

function getKey(evt,btnId) {
	if (document.getElementById('hide'))
		document.getElementById('hide').value = btnId;
	var ns6=document.getElementById&&!document.all;
     if (evt && ns6)
     typedKey=evt.which;
     else
     typedKey=event.keyCode;
     if (typedKey == 13) {
     if(document.all) {
     window.event.cancelBubble='true';
     window.event.returnValue = false;
     } else {
     evt.stopPropagation();
     evt.preventDefault();
     }

     document.getElementById(btnId).click();
     }
}

function UpdateBorder(){
    $(document).ready(function(){
    if(currentid) {
    $("img").css("border","");
    $("#small"+currentid).css("border","2px solid black");
    $("#small2"+currentid).css("border","2px solid black"); 
    $("#small3"+currentid).css("border","2px solid black"); }})
}

function UpdateRateButton(result){
    $("#rateButtons").html(result);
}
