/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function mainmenu(){
    // $(" .nav ul li ul ").css({display: "none"}); // Opera Fix
    $("#nav ul li").hover(function(){
        $(this).find('ul:first').css({
            visibility: "visible",
            display: "none"
        }).slideDown(200);

    },function(){
        $(this).find('ul:first').css({
            visibility: "hidden"
        });
    });
}



$(document).ready(function(){
    mainmenu();
    equalHeight("#cleft","#cright");

/*
    new horizScroller(
    {
        delay:5,
        contentEl:document.getElementById('horizContainer'),
        leftEl:document.getElementById('arrowLeft'),
        rightEl:document.getElementById('arrowRight')
    });
*/
//  equalHeightGroup(".colum");
});

/*

function horizScroller(opt)
{
    var d = 0;
    opt.delay = opt.delay || 50;
    opt.dist = opt.dist || 2;
    opt.leftEl.onmouseover = function() {
        d = -opt.dist;
        scroll();
    }
    opt.leftEl.onmouseout = function() {
        d = 0
    }
    opt.rightEl.onmouseover = function() {
        d = opt.dist;
        scroll();
    }
    opt.rightEl.onmouseout = function() {
        d = 0
    }

    function scroll()
    {
        if (!d) return;
        var x = opt.contentEl.scrollLeft+d, stop = false, rightBoundary = opt.contentEl.scrollWidth-opt.contentEl.offsetWidth;
        if (x<0) {
            addClassName(opt.leftEl, 'disabled');
            x = 0;
            stop = true;
        } else {
            removeClassName(opt.leftEl, 'disabled');
        }
        if (x>=rightBoundary) {
            addClassName(opt.rightEl, 'disabled');
            x = rightBoundary;
            stop = true;
        } else {
            removeClassName(opt.rightEl, 'disabled');
        }
        opt.contentEl.scrollLeft = x;
        if (stop) return;
        window.setTimeout(scroll, opt.delay);
    }

    function addClassName(el, className)
    {
        el.className = el.className.replace(new RegExp(' ?'+className+'|$'), ' '+className);
    }

    function removeClassName(el, className)
    {
        el.className = el.className.replace(new RegExp(' ?'+className+'( |$)'), '$1');
    }
}
*/
function showGrid() {
    $("#productlist").removeClass('productlist');
    $("#productlist").addClass('productgird');
    equalHeight("#cleft","#cright");
}
function showList() {
    $("#productlist").removeClass('productgird');
    $("#productlist").addClass('productlist');
    equalHeight("#cleft","#cright");
}




function equalHeightGroup(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
        alert(thisHeight);
    });
    group.height(tallest);
}


function equalHeight(itema, itemb)
{
    tallest = 0;
    thisHeightA = $(itema).height();
    thisHeightB = $(itemb).height();
    if( thisHeightA > thisHeightB) {
        tallest = thisHeightA;
    } else {
        tallest = thisHeightB;
    }
    $(itema).height(tallest);
    $(itemb).height(tallest);
}


function showDialog(vLink, vWidth, vHeight)
{
    return showWindow(vLink, false, true, true, false, false, false, true, true, vWidth, vHeight, 0, 0);
}
function showModalDialog(vLink, vWidth, vHeight)
{
    return showWindow(vLink, false, false, false, false, false, false, true, true, vWidth, vHeight, 0, 0);
}

function showWindow(vLink, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vWidth, vHeight, vTop, vLeft)
{
    var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

    winDef = '';
    winDef = winDef.concat('status=').concat((vStatus) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('resizable=').concat((vResizeable) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('scrollbars=').concat((vScrollbars) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('toolbar=').concat((vToolbar) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('location=').concat((vLocation) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('fullscreen=').concat((vFullscreen) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('titlebar=').concat((vTitlebar) ? 'yes' : 'no').concat(',');
    winDef = winDef.concat('height=').concat(vHeight).concat(',');
    winDef = winDef.concat('width=').concat(vWidth).concat(',');

    if (vCentered)
    {
        winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
        winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
    }
    else
    {
        winDef = winDef.concat('top=').concat(vTop).concat(',');
        winDef = winDef.concat('left=').concat(vLeft);
    }

    open(sLink, '_blank', winDef);

    if (typeof(vLink.href) != 'undefined')
    {
        return false;
    }
    return false;
}

