POPUPLAYER = function () {
    
    POPUPLAYER.prototype.getPageSize = function (){
    	var xScroll, yScroll;

    	if (window.innerHeight && window.scrollMaxY) {
    		xScroll = document.body.scrollWidth;
    		yScroll = window.innerHeight + window.scrollMaxY;
    	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    		xScroll = document.body.scrollWidth;
    		yScroll = document.body.scrollHeight;
    	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    		xScroll = document.body.offsetWidth;
    		yScroll = document.body.offsetHeight;
    	}

    	var windowWidth, windowHeight;
    	if (self.innerHeight) {	// all except Explorer
    		windowWidth = self.innerWidth;
    		windowHeight = self.innerHeight;
    	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    		windowWidth = document.documentElement.clientWidth;
    		windowHeight = document.documentElement.clientHeight;
    	} else if (document.body) { // other Explorers
    		windowWidth = document.body.clientWidth;
    		windowHeight = document.body.clientHeight;
    	}

    	// for small pages with total height less then height of the viewport
    	if(yScroll < windowHeight){
    		pageHeight = windowHeight;
    	} else {
    		pageHeight = yScroll;
    	}

    	// for small pages with total width less then width of the viewport
    	if(xScroll < windowWidth){
    		pageWidth = windowWidth;
    	} else {
    		pageWidth = xScroll;
    	}

        var scrOfX = 0, scrOfY = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
            //Netscape compliant
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
            //DOM compliant
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            //IE6 standards compliant mode
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
        }

    	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll,yScroll,scrOfX,scrOfY);
    	return arrayPageSize;
    }

    
    POPUPLAYER.prototype.setOpacity = function(a, b){
        if(b<0){b=0;} if(b>100){b=100;}
        var c=b/100;
        var d=document.getElementById(a);
        if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
        if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
        if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
        if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
    }

    
    
    POPUPLAYER.prototype.init = function(){
        var pageSize = this.getPageSize();

           
        try{
           document.getElementById('popuplayerback').style.display = 'block';
           document.getElementById('popuplayer').style.display = 'block';            
        }catch(e){
       
            var objBody = document.getElementsByTagName("body").item(0);

            //fekete hater
            var a = document.createElement('div');
            a.setAttribute('id','popuplayerback');
            a.style.display = 'block';
            a.style.position ='absolute';
            a.style.zIndex = 201;
            a.style.top = 0;
            a.style.left = 0;
            a.style.height = pageSize[1] + 'px';
            a.style.width = pageSize[4] + 'px';
            a.style.background = '#000';

            objBody.insertBefore(a, objBody.firstChild);
            this.setOpacity('popuplayerback',60);

            //popup    
            var b = document.getElementById('popuplayer');
            b.style.display = 'block';
            b.style.position='absolute';
            b.style.color='#000';
            b.style.padding = '0';
            b.style.top = (pageSize[7] + 150) + 'px';
           
            b.style.left = ((pageSize[0]/2)-123)+'px';
            b.style.zIndex = 202;
           

        }
    }

    
    //popup bezar
    POPUPLAYER.prototype.hide = function(){    			
        document.getElementById('popuplayerback').style.display = 'none';
        document.getElementById('popuplayer').style.display = 'none';
    }

    

    //bug: atmeretezi a fekete hateret, ablak atmeretezesnel, meg az ajax hivas utan hivjuk meg
    POPUPLAYER.prototype.resizeBack = function(){
        var pageSize = popuplayer.getPageSize();
        try{
            document.getElementById('popuplayer').style.top = (pageSize[7] + 50) + 'px';
            document.getElementById('popuplayer').style.left = ((pageSize[0]/2)-250)+'px';      
        }catch (e) {}
    }
    
    POPUPLAYER.prototype.search = function(str){
        this.hide();
        return googSearch.getResults(str);
    }

}

var popuplayer = new POPUPLAYER();
