
/*

iOkno

Created by Pavel Pekun
www.FXOPEN.com

ie6-8,opera,safari,ff,chrome
*/

var h,w,wI,hI,scrollH;
var de = document.documentElement;
var iokno;

$(document).ready(function(){ 

    if($("#bg_iOkno").width()){
        if(is_ie6){
            $("#bg_iOkno").css({opacity:0.4});
        }
        
        $(window).resize(function() {
             iOknoPosition();
        });
        
        $("#bg_iOkno").click(function(){
            close_iOkno();
        });
        
        if(is_ie6){
            $(window).scroll(function(){ 
                h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
                scrollH = document.documentElement.scrollTop;
                hI = (h - $("#"+iokno).height())/2+scrollH;
                $("#"+iokno).css({left:wI,top:hI});
            });
        }
    }
    
});

function iOknoPosition(){

    h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
    w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
    
    wI = (w - $("#"+iokno).width())/2;
    if(is_ie6){
        scrollH = document.documentElement.scrollTop;
        hI = (h - $("#"+iokno).height())/2+scrollH;
        if(document.body.clientHeight>h){h=document.body.clientHeight;}
        $("#bg_iOkno").css({height:h});
    }else{
        hI = (h - $("#"+iokno).height())/2;  
    }  
    
    if(wI<0){wI=0;}
    if(hI<0){hI=0;}
    
    $("#"+iokno).css({left:wI,top:hI});  
    
}

function iOkno(wid){
    iokno = wid;
    $("#"+iokno).find(".iokno_line").css({width: $("#"+iokno).width() - 55});
    $("#"+iokno).width($("#"+iokno).width());
    $("#bg_iOkno").css({display:"block"});
    $("#"+iokno).css({display:"block"});
    $("#bg_iOkno").blur();
    
    iOknoPosition();
}

function close_iOkno(){
    $("#bg_iOkno").css({display:"none"});
    $("#"+iokno).css({display:"none"});
    iokno = null;
    
    return false;
}
