function setClass(obj, cl){
    if (obj.className!=cl) obj.className = cl;
}

function hideInfoCrearForm(m_message,m_email) {

    if ( document.getElementById('info') ) {

        document.forms['quick_form'].elements.q_message.value     = m_message;

        document.forms['quick_form'].elements.q_email.value     = m_email;

        document.getElementById('info').style.display             = "none";

    }

}

function HideDebugInfo(id) 
{
    setCookie("debug_status_"+id, "hided", new Date(2299,1,1), "/");
    if ( document.getElementById('debug_'+id) ) 
    {
        document.getElementById('debug_'+id).style.display             = "none";
        document.getElementById('debug_hide_butt_'+id).style.display     = "none";
        document.getElementById('debug_show_butt_'+id).style.display     = "";
    }
}

function ShowDebugInfo(id) 
{
    setCookie("debug_status_"+id, "showed", new Date(2299,1,1), "/");
    if ( document.getElementById('debug_'+id) ) 
    {
        document.getElementById('debug_'+id).style.display             = "";
        document.getElementById('debug_hide_butt_'+id).style.display     = "";
        document.getElementById('debug_show_butt_'+id).style.display     = "none";
    }
}

function DebugInfoCheck(id)
{
    if(getCookie("debug_status_"+id) == "hided") HideDebugInfo(id);
}

function setClassById(objid, cl){

    if (!cl) cl = '';

    document.getElementById(objid).className = cl;

}


function makeGray (obj, state, text){

    if (state && (obj.value == '')){

        obj.value = text;

    } else if (!state && (obj.value == text)){

        obj.value = '';

    }

}





function changeDisplayById(objId){

    for (c = 0; c < changeDisplayById.arguments.length; c++){

        obj = document.getElementById(changeDisplayById.arguments[c]);

        if (obj.style.display == 'none') obj.style.display = 'block';

        else obj.style.display = 'none';

    }

}



function gotoURL(url, target, callback){



    if (!url) url = "/";



    if(typeof callback == "function")

        callback(url);



    if(target && target!='_self'){

        popupURL(url, target);

    }

    else{

        if (window.event){

            var src = window.event.srcElement;

            if((src.tagName != 'A') && ((src.tagName != 'IMG') || (src.parentElement.tagName != 'A'))){

                if (window.event.shiftKey) window.open(url);

                else document.location = url;

            }

        } else document.location = url;

    }

}





function popupURL(url, target){

    window.open(url, target);

}



function getLeftPos(obj){

    var res = 0;

    while (obj){

        res += obj.offsetLeft;

        obj = obj.offsetParent;

    }

    return res;

}



function getTopPos(obj){

    var res = 0;

    while (obj){

        res += obj.offsetTop;

        obj = obj.offsetParent;

    }

    return res;

}



function chbCheckAll(formObj, checkName, checkVal){

    var el = formObj.elements;

    for (count = 0; count < el.length; count++)

        if (el[count].name == checkName + '[]')

            if (!el[count].disabled) el[count].checked = checkVal;

}



function chbExamAll(formObj, checkName, resName){

    var checkCount = 0;

    var boxCount = 0;

    var el = formObj.elements;

    for (count = 0; count < el.length; count++)

        if (el[count].name == checkName + '[]'){

            boxCount++;

            if (el[count].checked || el[count].disabled) checkCount++;

        }

    formObj.elements[resName].checked = (checkCount == boxCount);

}



function chbIsAllEmpty(formObj, checkName){

    var checkCount = 0;

    var boxCount = 0;

    var el = formObj.elements;

    for (count = 0; count < el.length; count++)

        if (el[count].name == checkName + '[]'){

            boxCount++;

            if (el[count].checked) checkCount++;

        }

    return(checkCount == 0);

}



function chbIsOnlyOne(formObj, checkName){

    var checkCount = 0;

    var boxCount = 0;

    var el = formObj.elements;

    for (count = 0; count < el.length; count++){

        if (el[count].name == checkName + '[]'){

            boxCount++;

            if (el[count].checked) checkCount++;

        }

    }

    return(checkCount == 1);

}



function disableAll(){

    for (c1 = 0; c1 < document.forms.length;  c1++){

        var formElements = document.forms[c1].elements;

        for (c2 = 0; c2 < formElements.length;  c2++) formElements[c2].disabled = true;

    }

}



// name - cookie name

// value - cookie value

// [expires] - Date object (by default cookie expires at the end of browser session)

// [path]

// [domain]

// [secure]

function setCookie(name, value, expires, path, domain, secure)

{

    var curCookie = name + "=" + escape(value) +

                ((expires) ? "; expires=" + expires.toGMTString() : "") +

                ((path) ? "; path=" + path : "") +

                ((domain) ? "; domain=" + domain : "") +

                ((secure) ? "; secure" : "")



    if ( (name + "=" + escape(value)).length <= 4000)

        document.cookie = curCookie

}



// name - cookie name

function getCookie(name)

{

        var prefix = name + "="

        var cookieStartIndex = document.cookie.indexOf(prefix)

        if (cookieStartIndex == -1)

                return null

        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)

        if (cookieEndIndex == -1)

                cookieEndIndex = document.cookie.length

        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))

}



// name - cookie name

// [path]

// [domain]

function deleteCookie(name, path, domain)

{

    if (getCookie(name))

    {

        document.cookie = name+"="+

                ((path) ? "; path=" + path : "") +

                ((domain) ? "; domain=" + domain : "") +

                "; expires=Thu, 01-Jan-70 00:00:01 GMT"

    }

}





function preLoad() {

    if(document.images)  {

        var argLen = arguments.length;

        for(var i = 0; i < argLen; i++) {

            var arg = arguments[i];

            self[arg] = new Image();

            self[arg].src = arg;

        }

    }

}



function ch_img(obj, img ) {

    if (self[img]) {

        obj.src = self[img].src;

    }

}



function mm_act(obj,img,cl,num,selected){

    

    if ( cl == 'item act' )

        showMenu(obj, num);

    else

        hideMenu(obj, num);

    

    if ( selected ) return;

    

    while (obj) {

        obj = obj.childNodes[0];

        if ( obj && obj.tagName == 'IMG') {

            ch_img(obj,img);

            break;

        }

    }

    

    while (obj && cl!='') {

        obj = obj.parentNode;

        if ( obj && obj.tagName == 'DIV') {

            obj.className = cl;

            break;

        }

    }

}



function popup_view (url, w, h, wname) {

    scr_left = 0;

    scr_top = 0;

    wname = wname;

    new_window = window.open (url, wname , "title=image,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width="+w+",height="+h+",top="+scr_top+",left="+scr_left);

    new_window.focus();

    return new_window;

}

function trim(str)
{
    str = '' + str;
    var re = /^ */;
    var res = str.replace(re, '');
    re = / *$/;
    return(res.replace(re, ''));
}

function fixPNG(element)
{
    if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
    {
        var src;
        
        if (element.tagName=='IMG')
        {
            if (/\.png$/.test(element.src))
            {
                src = element.src;
                element.src = "http://www.gift-wishes.com/images/blank.gif";
            }
        }
        else
        {
            src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
            if (src)
            {
                src = src[1];
                element.runtimeStyle.backgroundImage="none";
            }
        }
        
        if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
    }
}

