var ns4 = document.layers? true : false;
var ie = document.all? true : false;
var dom = document.getElementById && !document.all ? true : false;
// uchovame si aktualne vybrany riadok (row id)
var highlightedRow = '';

// ziskame dom object
function getObject(nameStr) {
    if (dom)
        return document.getElementById(nameStr);
    else if (ie)
        return document.all[nameStr];
    else if (ns4)
        return document.layers[nameStr];
}

function highlight(rowID) {
    unHighlight();
    // ak mame vybrane pole zistime si ake z cookie
    row = getCookie('rowSel');
    selRow = document.getElementById(row);
    // vyznacime si riadok
    rowObj = getObject(rowID);
    rowObj.style.background = '#FFFFE0';
    highlightedRow = rowID;
    // zapiseme cookie
    setCookie('rowSel',rowID,1);
    // zmazeme pozadie predchadzajuce vyberu
    if (row != rowID){
        removeBg(selRow);
    }
}

function unHighlight() {
    if (highlightedRow != '') {
        rowObj = getObject(highlightedRow);
        rowObj.style.background = '#ffffff';
    }
}

// odstranenie pozadia
function removeBg (button) {
    if (button.style.removeAttribute) {
        button.style.removeAttribute ("backgroundColor");
    }
    else {
        button.style.removeProperty ("background-color");
    }
}


// registracia cookies
function setCookie(c_name,value,expiredays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

// vypis cookies
function getCookie(c_name){
    if (document.cookie.length>0) {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1){
            c_start=c_start + c_name.length+1 ;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return ""
}

// mazanie cookies
function delCookie(name) {
    document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
} 

// potvrdenie zmazania
function jsconfirm(thetext){
    return confirm(thetext);
}

/* begin - Primary Navigation */
var primaryNavigation = {
    init: function() {
        if ($.browser.msie) // iframe to fix dropdowns over select items
            $('#p7menubar > li').append('<iframe style="display: none;" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>');

        $('#p7menubar > li').hover(
            function() {
                $(this).addClass('over');
                $(this).children('a').addClass('over');
                if ($.browser.msie) {
                    var h = $(this).children('ul').height();
                    var w = $(this).children('ul').width() + 1;
                    var i = $(this).children('iframe');
                    if (i.length > 0 && h != null && w != null)
                        i.height(h).width(w).show();
                }
            },
            function() {
                $(this).removeClass('over');
                $(this).children('a').removeClass('over');
                if ($.browser.msie)
                    $(this).children('iframe').hide();
            }
            );
    }
};
$(function() { 
    primaryNavigation.init();
});

function squirrelmail_loginpage_onload() {
    document.forms[0].js_autodetect_results.value = '1';
    var textElements = 0;
    for (i = 0; i < document.forms[0].elements.length; i++) {
        if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "password") {
            textElements++;
            if (textElements == 1) {
                document.forms[0].elements[i].focus();
                break;
            }
        }
    }
}

function P7_ExpMenu(){ //v1.1.0.2 by PVII-www.projectseven.com
    if(navigator.appVersion.indexOf("MSIE")==-1){
        return;
    }
    var i,k,g,lg,r=/\s*p7hvr/,nn='',c,cs='p7hvr',bv='p7menubar';
    for(i=0;i<10;i++){
        g=document.getElementById(bv+nn);
        if(g){
            lg=g.getElementsByTagName("LI");
            if(lg){
                for(k=0;k<lg.length;k++){
                    lg[k].onmouseover=function(){
                        c=this.className;cl=(c)?c+' '+cs:cs;
                        this.className=cl;
                    };
                    lg[k].onmouseout=function(){
                        c=this.className;
                        this.className=(c)?c.replace(r,''):'';
                    };
                }
            }
        }
        nn=i+1;
    }
}

/* end - Primary Navigation */

//
// zobrazenie skrytie blokov
//

function toggle5(showHideDiv, switchImgTag, showText, hideText) {
	var ele = document.getElementById(showHideDiv);
	var imageEle = document.getElementById(switchImgTag);
	if(ele.style.display == "block") {
		ele.style.display = "none";
		imageEle.innerHTML = showText;
	}
	else {
		ele.style.display = "block";
		imageEle.innerHTML = hideText;
	}
}

// preskocenie na input ked ho zapneme
function inputFocus(id) {
    var input	= document.getElementById(id);
    if (input) {
        input.focus();
        input.select();
    }
}

// cena balikov
function getHostingPrice(hostingID) {
    var intervalID;
    intervalID = document.getElementById('interval_' + hostingID).value;

    $.post("/custom/getHostingPrice.php", {
        h_id : hostingID,
        i_id : intervalID
    },
    function(data){
        var prices = data.split('#');
        $("#price" + hostingID).html(prices[0]);
        $("#pricey" + hostingID).html(prices[1]);
        $("#pricem" + hostingID).html(prices[2]);
    });
}

// zobrazenie info a errorov k formularom

if (typeof(jQuery) != 'undefined') {
    var $j = jQuery.noConflict();
}  

$j(document).ready(function () {
	$j('a.infoLink').click(function () {
		$j(this).parent().parent().children('.info').show();
	return false;
	});
	$j('a.infoLink').blur(function () {
		$j(this).parent().parent().children('.info').fadeOut(300);
	return false;
	});
	$j('a.closeLink').click(function () {
		$j(this).parent().fadeOut(300);
	return false;
	});

	$j("#upc_bundlelist div.itemcontainer").hide();
	$j("#upc_bundlelist .item .info").hide();
}); 



