/*ABLAK*/
//az ix elérése mindig attól a file-tól kell számitani amibe be lett töltve az ablak.js
var ixUrl = "js/ix.png";

//Az ablak és a háttér css tulajdonságai
var css = "<style>";

css += ".kulso{"
css += "display:none;background-color:red;position:fixed;left:0;top:0;height:100%;	width:100%;opacity:0.5;filter:alpha(opacity=50);z-index:10001}";

css += ".belso {";
css += "padding:5px;";
css += "color:black;";
css += "display:none;";
css += "left:50%;";
css += "top:0%;";
css += "position:fixed;";
css += "background:#ffffff ;";
css += "border: 6px solid #e4e4e4;-webkit-border-radius: 0.3em;";
css += "-moz-border-radius:0.3em;";
css += "z-index:99999;";
css += "font-size:12px;}";

css += ".belso2 {";
css += "padding:5px;";
css += "color:black;";
css += "display:none;";
css += "left:50%;";
css += "top:0%;";
css += "position:fixed;";
css += "background:#67A9DF ;";
css += "border: 6px solid #e4e4e4;-webkit-border-radius: 0.3em;";
css += "-moz-border-radius:0.3em;";
css += "z-index:99999;";
css += "font-size:12px;}";

if(navigator.appName == "Microsoft Internet Explorer")
{
    if(navigator.appVersion.indexOf("MSIE 7.") !=-1)
    {
        css += ".ix{";
        css += "width: 26px;height:32px;background:url(js/iex.png) no-repeat;position:absolute;right: 0;top:0;margin-top:0.1em;margin-right:-0.2em;z-index:100;cursor:pointer;";
        css += "-moz-user-select: none;";
        css += "-khtml-user-select: none;";
        css += "user-select: none;}";
        css += ".iemargin{margin-top:29px;padding-bottom:0px;margin-bottom:0px;}";
    }
    else
    {
       css += ".ix{";
       css += "width: 26px;height:32px;background:url(js/iex.png) no-repeat;position:absolute;right: 0;top:0;margin-top:0.1em;margin-right:-0.2em;z-index:100;cursor:pointer;";
       css += "-moz-user-select: none;";
       css += "-khtml-user-select: none;";
       css += "user-select: none;}";
       css += ".iemargin{margin-top:22px;}";
    }
}
else
{
        css += ".ix{";
        css += "width: 26px;height:32px;background:url("+ixUrl+") no-repeat left top;position:absolute;right: 0;top:0;margin-top:-1.5em;margin-right:-1.4em;z-index:100;cursor:pointer;";
        css += "-moz-user-select: none;";
        css += "-khtml-user-select: none;";
        css += "user-select: none;}";        
}

if(navigator.appName == "Microsoft Internet Explorer")
{
    if(navigator.appVersion.indexOf("MSIE 7.") !=-1)
    {
        css += ".ix2{";
        css += "display:none;width: 26px;height:32px;background:url('js/movex.png') no-repeat right top;position:absolute;right: 32px;top:0;margin-top:0.1em;margin-right:-0.5em;z-index:100;cursor:pointer;";
        css += "-moz-user-select: none;";
        css += "-khtml-user-select: none;";
        css += "user-select: none;}";
        
        css += "</style>";
    }
    else
    {
       css += ".ix2{";
        css += "display:none;width: 26px;height:32px;background:url('js/movex.png') no-repeat right top;position:absolute;right: 32px;top:0;margin-top:0.1em;margin-right:-0.5em;z-index:100;cursor:pointer;";
        css += "-moz-user-select: none;";
        css += "-khtml-user-select: none;";
        css += "user-select: none;}";
        css += "</style>";   
    }
}
else
{
        css += ".ix2{";
        css += "display:none;width: 26px;height:32px;background:url('js/move.png') no-repeat right top;position:absolute;right: 32px;top:0;margin-top:-1.5em;margin-right:-2.2em;z-index:100;cursor:pointer;";
        css += "-moz-user-select: none;";
        css += "-khtml-user-select: none;";
        css += "user-select: none;}";
        css += "</style>";
}



document.write(css);

//Ha az ablak már rejtés alatt van akkor nem engedi megjeleniteni az újat de fél másodperc mulva ujra megprobálja
var hiding = false;

function showInAblak(forras,tipus)
{
    if(tipus == "reszleges")
    {
        var htmlx = "<div style='overflow:hidden;height:306px;'><img src='"+forras+"' /></div>";
    }
    else
    {
        var htmlx = "<img src='"+forras+"' />";
    }
    
    addHTML(htmlx);   
    showAblak(); 
}

function addHTML(content)
{    
    document.getElementById("belso-main").style.display = "none";
    document.getElementById("belso").innerHTML = content;
}

function showAblak(rounds)
{    
    if(hiding == true)
    {           
        setTimeout("showAblak()" , 100);
        return;
    }
    
    //document.getElementById("belso-main").style.top = "8%";  
    
	var browserName=navigator.appName;

	//Igy nem kell paraméter
    if (typeof rounds == "undefined")
	{
    	rounds = 1;
  	}

	//kulso belso ablak változóba mentése késöbbi elérésre
	//var kulso = document.getElementById("kulso");
	var belso = document.getElementById("belso-main");

	//Ha explorer akkor csak eltünnek
	if(browserName == "Microsoft Internet Explorer")
 	{
		//Alap értékek beálitása hogy minden elotünés látszódjon
		if(belso.style.display != "block")
		{   
		    document.getElementById("belso-main").className  = "belso"; 
            //kulso.style.filter = 'alpha(opacity=' + 1 + ')';
            belso.style.filter = 'alpha(opacity=' + 1 + ')';       
            belso.style.left = "50%";
        	belso.style.marginTop = "3%";
			//kulso.style.display = "block";
			belso.style.display = "block";
		}
            var szelesseg = parseInt(belso.clientWidth);
       
	        belso.style.marginLeft = (szelesseg/2) * -1 + "px";

		//Maga az átlászóság beálitása 0.1* mert 0.1 * 1 az 0.1
		if((rounds*0.1) < 0.6)
        {
            belso.style.filter = 'alpha(opacity=' + ((rounds * 17) * 2) + ')';
            //kulso.style.filter = 'alpha(opacity=' + ((rounds * 10)) + ')';    

			setTimeout("showAblak("+(rounds+ 1)+")" , 20);
        }
        else
        {
            var szelesseg = parseInt(belso.clientWidth);
       
	        belso.style.marginLeft = (szelesseg/2) * -1 + "px";
			return;
        }

    	}
	else
	{
		//Alap értékek beálitása hogy minden elotünés látszódjon
		if(belso.style.display != "block")
		{		  
		    document.getElementById("belso-main").className  = "belso"; 
            //kulso.style.opacitiy = 0.0;
            belso.style.opacitiy = 0.0;
            //var opacity = kulso.style.opacity;
			//kulso.style.display = "block";
			belso.style.display = "block";
            belso.style.left = "50%";
        	belso.style.marginTop = "3%";
		}        
        
        var szelesseg = parseInt(belso.clientWidth);
       
	    belso.style.marginLeft = (szelesseg/2) * -1 + "px";

		//Maga az átlászóság beálitása 0.1* mert 0.1 * 1 az 0.1
		if((rounds*0.1) < 0.6)
        {           
			//kulso.style.opacity = (rounds * 0.1);
			belso.style.opacity = (rounds * 0.1) * 2;                        
			setTimeout("showAblak("+(rounds+ 1)+")" , 50);
        }
        else
        {            
            startOffsetX = belso.offsetLeft;
            startOffsetY = belso.offsetTop;
			return;
        }
	}

}


//Villogás ellen
function hideAblak()
{       
    if(hiding == true)
    {        
        return;
    }
    else
    {
        hideAblakIn();
    }
}


//Adott ablak eltüntetése
function hideAblakIn(rounds)
{    
    hiding = true;

	//Igy nem kell paraméter
    if (typeof rounds == "undefined")
	{
    	rounds = 10;
  	} 	

	//kulso belso ablak változóba mentése késöbbi elérésre
	//var kulso = document.getElementById("kulso");
	var belso = document.getElementById("belso-main");

    if( (belso.style.display == "none" || belso.style.display == "" ) && rounds == 10 )
    {            
        hiding = false;
        return;    
    }

	//Ha explorer nincs efekt
 	var browserName=navigator.appName;

	//Ha explorer akkor csak eltünnek
	if(browserName == "Microsoft Internet Explorer")
 	{
		//Maga az átlászóság beálitása 0.1* mert 0.1 * 1 az 0.1
		if((rounds*0.1) > 0.0)
        {
            belso.style.filter = 'alpha(opacity=' + ((rounds * 10) * 2) + ')';
            //kulso.style.filter = 'alpha(opacity=' + ((rounds * 5)) + ')'; 

			setTimeout("hideAblakIn("+ (rounds - 1) +")" , 20);
        }
        else
        {
			//kulso.style.display = "none";
			belso.style.display = "none";
            hiding= false;
        }

	}
	else
	{
		//Maga az átlászóság beálitása 0.1* mert 0.1 * 1 az 0.1
		if((rounds*0.1) > 0.0)
        {           
			//kulso.style.opacity = (rounds * 0.1) - 0.5;
			belso.style.opacity = (rounds * 0.1);
			setTimeout("hideAblakIn("+ (rounds - 1) +")" , 50);
        }
        else
        {
            
			//kulso.style.display = "none";
			belso.style.display = "none";
            hiding= false;
         

        }
	}
}


//Az ablak és háttér div létrehozása
//Kivettem: <div id='kulso' class='kulso' onclick='hideAblak();' ></div>
document.write("<div id='belso-main' class='belso' ><div id='moveablak' class='ix2'></div><div onclick='hideAblak();' class='ix'></div><div class='iemargin' id='belso'></div></div>");


