/******************* képernyő koordinátáinak meghatározása *****************/
function f_clientWidth() {
    return f_filterResults (
        window.innerWidth ? window.innerWidth : 0,
        document.documentElement ? document.documentElement.clientWidth : 0,
        document.body ? document.body.clientWidth : 0
    );
}
function f_clientHeight() {
    return f_filterResults (
        window.innerHeight ? window.innerHeight : 0,
        document.documentElement ? document.documentElement.clientHeight : 0,
        document.body ? document.body.clientHeight : 0
    );
}
function f_scrollLeft() {
    return f_filterResults (
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    );
}
function f_scrollTop() {
    return f_filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}
function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
/******************* light view ablak *****************/
function show_lw(param) {
    lw_bg = 'lw_bg'+param;
    lightview = 'lightview'+param;

    yScroll = f_scrollTop();

    ySize = f_clientHeight();
    yCenter = ySize/2+yScroll;
    xSize = f_clientWidth();
    xCenter = xSize/2;
    
    //hack
    if(!yScroll){
        h1 = window.innerHeight ? window.innerHeight : 0;
        h2 = document.documentElement ? document.documentElement.clientHeight : 0;
        h3 = document.body ? document.body.clientHeight : 0;
            
        if(h1>=h2 && h1>=h3){
            lwh = h1;     
        }else if(h2>=h1 && h2>=h3){
            lwh = h2;     
        }else if(h3>=h1 && h3>=h2){
            lwh = h3;     
        }
    }else{
        lwh = (ySize+yScroll<document.getElementById('main').offsetHeight) ? document.getElementById('main').offsetHeight : ySize+yScroll;
    }

    document.getElementById(lw_bg).style.display = 'block';
    document.getElementById(lightview).style.display = 'block';
    
    xSizeDiv = document.getElementById(lightview).offsetWidth;
    ySizeDiv = document.getElementById(lightview).offsetHeight;     
    
    x = parseInt(xCenter-(xSizeDiv/2));
    y = parseInt(yCenter-(ySizeDiv/2));
    
    
    document.getElementById(lw_bg).style.top = 0;
    document.getElementById(lw_bg).style.left = 0;
    document.getElementById(lw_bg).style.width = xSize+'px';
    document.getElementById(lw_bg).style.height = lwh+'px';   
    
    document.getElementById(lightview).style.left = x+'px';
    document.getElementById(lightview).style.top = y+'px';
    //document.getElementById(lightview).style.width = '600px';
    
    $('#lightview'+param).draggable({ handle: "h3", containment: "body"});
}

function close_lw(param){
    lw_bg = 'lw_bg'+param;
    lightview = 'lightview'+param;

    //displaynone(lw_bg);
    //displaynone(lightview);
	$('#'+lw_bg).attr('style', 'display:none;');
	$('#'+lightview).attr('style', 'display:none;');
}
function displayblock(div){
    document.getElementById(div).style.display = "block" ;
}
function displaynone(div){
    document.getElementById(div).style.display = "none" ;
}
function print_window(url, product) {
    window.open(url+"_print.php?product="+product, "Print", "top=0,left=0,width=700,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
}

