function ref(object)
{
    if (document.getElementById)
    {
        return document.getElementById(object);
    }
    else if (document.all)
    {
        return eval('document.all.' + object);
    }
    else
    {
        return false;
    }
}

function select_all (obj) {
    var ids = document.getElementsByName(obj);
    for (i=0;i<ids.length ;i++ ) {
        ids[i].checked = 'checked';
    }
}
function select_none (obj) {
    var ids = document.getElementsByName(obj);
    for (i=0;i<ids.length ;i++ ) {
        ids[i].checked = '';
    }
}

function jumpMenu(url){
        window.location.href = url;
}


//ORDER AJAX
function order_set(url) {

var opt = {
    // Use POST
    // Handle successful response
     method:'post' ,
    onSuccess: function(t) {

        eval(t.responseText);
        if (jsarray['error'] != '') {
            alert(jsarray['error']);
        } else {
            $('order_items').value = jsarray['order_items'];
            if (confirm(jsarray['success_msg'])) {
                window.location.href = jsarray['success_url'];
            }
        }
/*
        if (t.responseText.indexOf('error') != -1) {
            alert  ("��������� �� ���� �� ���� ������!");
        }
*/
    },
    // Handle 404
    on404: function(t) {
        alert('Error 404: location "' + t.statusText + '" was not found.');
    },
    // Handle other errors
    onFailure: function(t) {
        alert('Error ' + t.status + ' -- ' + t.statusText);
    }
}

    new Ajax.Request(url, opt);
}
function AjaxRequest(url) {
    if (url == ''){
        alert("NO URL specified in AjaxRequest");
        return false;
    }
var opt = {
    // Use POST
    // Handle successful response
     method:'post' ,
    onSuccess: function(t) {
//        eval(t.responseText);
//        if (jsarray['error'] != '') {
//            alert(jsarray['error']);
//        } else {
//            $('order_items').value = jsarray['order_items'];
//            if (confirm(jsarray['success_msg'])) {
//                window.location.href = jsarray['success_url'];
//            }
//        }
    },
    // Handle 404
    on404: function(t) {
        alert('Error 404: location "' + t.statusText + '" was not found.');
    },
    // Handle other errors
    onFailure: function(t) {
        alert('Error ' + t.status + ' -- ' + t.statusText);
    }
}

    new Ajax.Request(url, opt);
}

function setCookie(c_name,value,expiredays)
{
    if (value == 'none'){
        value = '';
    } else {
        value = 'none';
    }
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +value+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

// Delete image from gallery
function delete_image(url, obj) {
//var opt = {
//    // Use POST
//    // Handle successful response
//    onSuccess: function(t) {
//    },
//    // Handle 404
//    on404: function(t) {
//        alert('Error 404: location "' + t.statusText + '" was not found.');
//    },
//    // Handle other errors
//    onFailure: function(t) {
//        alert('Error ' + t.status + ' -- ' + t.statusText);
//    }
//}
//
//    new Ajax.Updater(obj, url, opt);
    $('#' + obj).load(url);
 
}


// RATING functions
function setStars(starNum, itemId, voted) {
    url = env.INDEX_URL + "?" + env.mainparam + "=items&items=ranking&item=" + itemId + "&rank=" + starNum + "&voted=" + voted;
    if ($('item_rating')){
		$('#item_rating').load(url,function () {
					//alert();
				});
        //new Ajax.Updater('item_rating', url, {onComplete:function(){ new Effect.Shake('item_rating');},asynchronous:true});
    } else {
        $('#item_rating').load(url);
		//new Ajax.Request(url, {asynchronous:true});
    }
//    AjaxRequest(url);
}
function showStars(starNum, itemId) {
    if (!itemId){
        itemId = '';
    }
    for(var i=1;i<=env.PH_MAX_RATING_NUM;i++){
        if (i <= starNum) {
            $("star_" + itemId + "_"+(i)).src = "images/icons/small/ranking_star_yellow.png";
        } else {
            $("star_" + itemId + "_"+(i)).src = "images/icons/small/ranking_star_grey.png";
        }
    }
}
function resetStars(rank,itemId) {
    if (!itemId){
        itemId = '';
    }
    for(var i=1;i<=env.PH_MAX_RATING_NUM;i++){
        if (i <= rank) {
            $("star_" + itemId + "_"+(i)).src = "images/icons/small/ranking_star_yellow.png";
        } else if (i == Math.round(rank)){
            $("star_" + itemId + "_"+(i)).src = "images/icons/small/ranking_star_middle.png";
        } else {
            $("star_" + itemId + "_"+(i)).src = "images/icons/small/ranking_star_grey.png";
        }
    }
}

/*
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")


//form tags to omit in NS6+:
var omitformtags=["input", "textarea", "select"]

omitformtags=omitformtags.join("|")

function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable(){
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
*/


//  End -->

