/**
 * @author Admin
 */

//window.onload = enable_menues_for_ie;


var ns4 = (document.layers)? true:false;
var nn6 = (!document.all && document.getElementById)? true:false;
var ie4 = (document.all)? true:false;

function posTop()
{
    return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

function getPageSize(){
	
	var arrayPageSize = new Array();
	var xScroll, yScroll;
	var pageWidth = 0;
      var pageHeight = 0;
	
	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;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}





function doResize()
{
    var arrayPageSize = new Array();
    arrayPageSize = getPageSize();
    if (ns4)
    {
        document.layers['disablePage'].width = '100%';
        document.layers['disablePage'].height = '100%';
        document.layers['disablePage'].height = (arrayPageSize[1] + arrayPageSize[3]);
    }
    if (nn6)
    {
        document.getElementById('disablePage').style.width = '100%';
        document.getElementById('disablePage').style.height = '100%';
        document.getElementById('disablePage').style.height = (arrayPageSize[1]) + 'px';
    }
    if (ie4)
    {
        document.getElementById('disablePage').style.width = '100%';
        document.getElementById('disablePage').style.height = '100%';
        document.getElementById('disablePage').style.height = (arrayPageSize[1]);
    }
}

window.onresize = function()
{
    doResize();
};

function enable_menues_for_ie()
{
    if (document.all)
    {
        uls = document.getElementsByTagName('UL');

        for(i = 0; i < uls.length; i++)
        {
            if (uls[i].className == 'dropdown')
            {
                var lis = uls[i].getElementsByTagName('li');

                for (j = 0; j < lis.length; j++)
                {
                    if(lis[j].lastChild.tagName == 'UL')
                    {
                        lis[j].onmouseover = function() { this.lastChild.style.display = 'block'; }
                        lis[j].onmouseout = function() { this.lastChild.style.display = 'none'; }
                        lis[j].onclick = function() { this.lastChild.style.display = 'none'; }
                    }
                }
            }
        }
    }
}


window.onload = function(){
	//enable_menues_for_ie();
	//starter();	
}














function dialogImgLoad()
{
    var im = document.images['dialogImg'];
    var dl = document.getElementById('dialogLoading');
    var dc = document.getElementById('dialogContent');
    var dbg = document.getElementById('dialogBackground');
    var body = document.body;
    var top = 0;

    dl.style.display='none';
    dc.style.display='block';

    dbg.style.height=im.height + 6;

    if (ns4)
    {
        if((window.innerHeight / 2 - (im.height / 2)) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - (im.height / 2));
        document.layers['dialogBox'].top = top;

        document.layers['dialogBox'].left = (body.offsetWidth / 2 - (im.width / 2));
        document.layers['dialogPanel'].width = (im.width + 6);
        document.layers['dialogBackground'].width = (im.width + 6);
        document.layers['dialogBackground'].height = (im.height + 6);
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - (im.height / 2)) <=0) top = 0;
        else top = (window.innerHeight / 2 - (im.height / 2));
        document.getElementById('dialogBox').style.top = (top + posTop()) + 'px';

        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (im.width / 2)) + 'px';
        document.getElementById('dialogPanel').style.width = (im.width + 6) + 'px';
        document.getElementById('dialogBackground').style.width = (im.width + 6) + 'px';
        document.getElementById('dialogBackground').style.height = (im.height + 6) + 'px';
    }
    if (ie4)
    {
        if((document.body.offsetHeight/2 - (im.height / 2)) <= 0) top = 0;
        else top = (document.body.offsetHeight/2 - (im.height / 2));
        document.getElementById('dialogBox').style.top = top + posTop();

        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (im.width / 2));
        document.getElementById('dialogPanel').style.width = (im.width + 6);
        document.getElementById('dialogBackground').style.width = (im.width + 6);
        document.getElementById('dialogBackground').style.height = (im.height + 6);
    }
    doResize();
}


function dialogShow(imge)
{
    var d = document.getElementById('dialogBox');
    var dl = document.getElementById('dialogLoading');
    var dc = document.getElementById('dialogContent');
    var im = document.images['dialogImg'];
    var body = document.body;

    var top = 0;

    if (ns4)
    {
        if((window.innerHeight / 2 - 300) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.layers['dialogBox'].top = top;
        document.layers['dialogBox'].left = (body.offsetWidth / 2 - (400));
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - 300) <=0) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.getElementById('dialogBox').style.top = (top + posTop()) + 'px';
        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (400)) + 'px';
    }
    if (ie4)
    {
        if((document.body.offsetHeight/2 - 300) <= 0) top = 0;
        else top = (document.body.offsetHeight/2 - 300);
        document.getElementById('dialogBox').style.top = top + posTop();
        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (400));
    }

    d.style.display='block';
    dl.style.display='block';
    dc.style.display='none';
    document.getElementById('disablePage').style.display='block';

    im.src=''+uri+'images/'+imge;

    doResize();
}

function dialogAbort()
{
    var d = document.getElementById('dialogBox');
    var im = document.images['dialogImg'];
    d.style.display='none';
    document.getElementById('disablePage').style.display='none';
    im.src=''+uri+'images/loading2.gif';
/*
    if (ns4)
    {
        document.layers['dialogPanel'].width = 806;
        document.layers['dialogBackground'].width = 806;
        document.layers['dialogBackground'].height = 606;
    }
    if (nn6)
    {
        document.getElementById('dialogPanel').style.width = (800 + 6) + 'px';
        document.getElementById('dialogBackground').style.width = (800 + 6) + 'px';
        document.getElementById('dialogBackground').style.height = (600 + 6) + 'px';
    }
    if (ie4)
    {
        document.getElementById('dialogPanel').style.width = (800 + 6);
        document.getElementById('dialogBackground').style.width = (800 + 6);
        document.getElementById('dialogBackground').style.height = (600 + 6);
    }
*/
}

































function dialogImgLoadPortfolio()
{
    var im = document.images['dialogImgPortfolio'];
    var dl = document.getElementById('dialogLoadingPortfolio');
    var dc = document.getElementById('dialogContentPortfolio');
    var dbg = document.getElementById('dialogBackgroundPortfolio');
    var body = document.body;
    var top = 0;

    var arrayPageSize = new Array();
    arrayPageSize = getPageSize();

    dl.style.display='none';
    dc.style.display='block';

    dbg.style.height=im.height + 6;

    if (ns4)
    {
        if((window.innerHeight / 2 - (im.height / 2)) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - (im.height / 2));
        document.layers['dialogBoxPortfolio'].top = top;

        document.layers['dialogBoxPortfolio'].left = (body.offsetWidth / 2 - (im.width / 2));
        document.layers['dialogPanelPortfolio'].width = (im.width + 6);
        document.layers['dialogBackgroundPortfolio'].width = (im.width + 6);
        document.layers['dialogBackgroundPortfolio'].height = (im.height + 6);
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - (im.height / 2)) <=0) top = 0;
        else top = (window.innerHeight / 2 - (im.height / 2));
        document.getElementById('dialogBoxPortfolio').style.top = (top + posTop()) + 'px';

        document.getElementById('dialogBoxPortfolio').style.left = (body.offsetWidth / 2 - (im.width / 2)) + 'px';
        document.getElementById('dialogPanelPortfolio').style.width = (im.width + 6) + 'px';
        document.getElementById('dialogBackgroundPortfolio').style.width = (im.width + 6) + 'px';
        document.getElementById('dialogBackgroundPortfolio').style.height = (im.height + 6) + 'px';
    }
    if (ie4)
    {
//        if((document.body.offsetHeight/2 - (im.height / 2)) <= 0) top = 0;
//        else top = (document.body.offsetHeight/2 - (im.height / 2));

        if((arrayPageSize[3] / 2 - (im.height / 2)) <= 0) top = 0;
        else top = (arrayPageSize[3] / 2 - (im.height / 2));

        document.getElementById('dialogBoxPortfolio').style.top = top + posTop();

        document.getElementById('dialogBoxPortfolio').style.left = (body.offsetWidth / 2 - (im.width / 2));
        document.getElementById('dialogPanelPortfolio').style.width = (im.width + 6);
        document.getElementById('dialogBackgroundPortfolio').style.width = (im.width + 6);
        document.getElementById('dialogBackgroundPortfolio').style.height = (im.height + 6);
    }
    doResize();
}


function dialogShowPortfolio(imge,offset,limit,lp)
{
    var d = document.getElementById('dialogBoxPortfolio');
    var dl = document.getElementById('dialogLoadingPortfolio');
    var dc = document.getElementById('dialogContentPortfolio');
    var im = document.images['dialogImgPortfolio'];
    var body = document.body;


    var arrayPageSize = new Array();
    arrayPageSize = getPageSize();

    var top = 0;

    if (ns4)
    {
        if((window.innerHeight / 2 - 300) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.layers['dialogBoxPortfolio'].top = top;
        document.layers['dialogBoxPortfolio'].left = (body.offsetWidth / 2 - (400));
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - 300) <=0) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.getElementById('dialogBoxPortfolio').style.top = (top + posTop()) + 'px';
        document.getElementById('dialogBoxPortfolio').style.left = (body.offsetWidth / 2 - (400)) + 'px';
    }
    if (ie4)
    {
//        if((document.body.offsetHeight / 2 - 300) <= 0) top = 0;
//        else top = (document.body.offsetHeight / 2 - 300);
        if((arrayPageSize[3] / 2 - 300) <= 0) top = 0;
        else top = (arrayPageSize[3] / 2 - 300);
//        top = (arrayPageSize[3] /2) - 300;
        document.getElementById('dialogBoxPortfolio').style.top = top + posTop();   // top +
        document.getElementById('dialogBoxPortfolio').style.left = (body.offsetWidth / 2 - (400));
    }

    d.style.display='block';
    dl.style.display='block';
    dc.style.display='none';
    document.getElementById('disablePage').style.display='block';

//    im.src=''+uri+'images/'+imge;
//      alert(offset + ' -- ' + limit + '--' + lp);

    doResize();
    xajax_portfolio(offset,limit,lp);
}

function dialogAbortPortfolio()
{
    var d = document.getElementById('dialogBoxPortfolio');
    var im = document.images['dialogImgPortfolio'];
    d.style.display='none';
    document.getElementById('disablePage').style.display='none';
    im.src=''+uri+'images/loading2.gif';

    if (ns4)
    {
        document.layers['dialogPanelPortfolio'].width = 806;
        document.layers['dialogBackgroundPortfolio'].width = 806;
        document.layers['dialogBackgroundPortfolio'].height = 606;
    }
    if (nn6)
    {
        document.getElementById('dialogPanelPortfolio').style.width = (800 + 6) + 'px';
        document.getElementById('dialogBackgroundPortfolio').style.width = (800 + 6) + 'px';
        document.getElementById('dialogBackgroundPortfolio').style.height = (600 + 6) + 'px';
    }
    if (ie4)
    {
        document.getElementById('dialogPanelPortfolio').style.width = (800 + 6);
        document.getElementById('dialogBackgroundPortfolio').style.width = (800 + 6);
        document.getElementById('dialogBackgroundPortfolio').style.height = (600 + 6);
    }
}

/********************************************************************************************************************/


function dialogLoadingPortfolio()
{
    var d = document.getElementById('dialogBoxPortfolio');
    var dl = document.getElementById('dialogLoadingPortfolio');
    var dc = document.getElementById('dialogContentPortfolio');
    var im = document.images['dialogImgPortfolio'];
    var body = document.body;

    var top = 0;

    if (ns4)
    {
        if((window.innerHeight / 2 - 300) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.layers['dialogBoxPortfolio'].top = top;
        document.layers['dialogBoxPortfolio'].left = (body.offsetWidth / 2 - (400));
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - 300) <=0) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.getElementById('dialogBoxPortfolio').style.top = (top + posTop()) + 'px';
        document.getElementById('dialogBoxPortfolio').style.left = (body.offsetWidth / 2 - (400)) + 'px';
    }
    if (ie4)
    {
        if((document.body.offsetHeight/2 - 300) <= 0) top = 0;
        else top = (document.body.offsetHeight/2 - 300);
        document.getElementById('dialogBoxPortfolio').style.top = top + posTop();
        document.getElementById('dialogBoxPortfolio').style.left = (body.offsetWidth / 2 - (400));
    }

    d.style.display='block';
    dl.style.display='block';
    dc.style.display='none';
    document.getElementById('disablePage').style.display='block';

    doResize();
}

function portfolioJs(offset,limit,lp)
{
    var dl = document.getElementById('dialogLoadingPortfolio');
    var dc = document.getElementById('dialogContentPortfolio');
    dl.style.display='block';
    dc.style.display='none';

    xajax_portfolio(offset,limit,lp);
}


/***************************************************************************************************************/

function getFlash(flash,w,h)
{
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'" id="menu_nawigacja_glowna_krakow" align="middle">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="movie" value="'+flash+'" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="bgcolor" value="#ffffff" />');
    document.write('<param name="wmode" value="transparent">');
    document.write('<param name="scale" value="scale" />');
    document.write('<param name="menu" value="false" />');
    document.write('<embed src="'+flash+'" menu="false" scale="scale" wmode="transparent" quality="high" width="'+w+'" height="'+h+'" name="menu_nawigacja_glowna_krakow" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

var t = 0;

function przewin(coid,kierunek)
{
//    alert(coid + ' -- ' + kierunek);
//    alert(document.getElementById(coid));
    if(kierunek=='s')
    {
        document.getElementById(coid).scrollTop+=1;
        t=setTimeout("przewin('"+coid+"','s')",2)
    }
    else if(kierunek=='w')
    {
        document.getElementById(coid).scrollTop-=1;
        t=setTimeout("przewin('"+coid+"','w')",2)
    }

}


function stop()
{
    clearTimeout(t);
}


function menuOver(im,file)
{
//    im.src="{$url}templates/{$city}/images/" + file;
    im.src=uri+"templates/images/" + file;
}

function menuOut(im,file)
{
//    im.src="{$url}templates/{$city}/images/" + file;
    im.src=uri+"templates/images/" + file;
}

function menu(im,file)
{
//    im.src="{$url}templates/{$city}/images/" + file;
    im.src=url+"templates/images/" + file;
}

function mShow(val)
{
	if(val<=100)
	{
		val++;
		$('monitor').setOpacity(val / 100);
		setTimeout("mShow("+val+")",5);
	}
}

function mHide(val)
{
	if(val>=0)
	{
		val--;
		$('monitor').setOpacity(val / 100);
		setTimeout("mHide("+val+")",5);
	} else $('monitor').style.display='none';
}


function monitorShow()
{
	var t = document.viewport.getScrollOffsets();
	
	$("monitor").style.top=(document.viewport.getHeight()+t[1])/2 - 25 + "px";
	$("monitor").style.left=(document.viewport.getWidth()+t[0])/2 - 100 + "px";
	
	$('monitor').setOpacity(0.0);
	$('monitor').style.display='block';
	
	mShow(0.0);

	setTimeout("monitorHide()",5000);
}

function monitorHide()
{
	mHide(100);
}



function starter()
{
	var val = 60;
	$('img1').setOpacity(val / 100);
	$('img2').setOpacity(val / 100);
	$('img3').setOpacity(val / 100);
	$('img4').setOpacity(val / 100);
	$('img5').setOpacity(val / 100);
}


function imShow(val,id)
{
	if(val<=100)
	{
		val++;
		$(id).setOpacity(val / 100);
		setTimeout("imShow("+val+",'"+id+"')",5);
	}
}

function imHide(val,id)
{
	if(val>=60)
	{
		val--;
		$(id).setOpacity(val / 100);
		setTimeout("imHide("+val+",'"+id+"')",5);
	}
}


function imgintr(id,p)
{
	if(p=='u')
	{
		imShow(80,id);
	}
	
	if(p=='d')
	{
		imHide(100,id);
	}
};


var slidev = 1;

function slides(id,val)
{
	if(val <= 100)
	{
		val +=2;
		$('sim'+id).setOpacity(val/100);
		setTimeout("slides("+id+","+val+")",10);
	}
}

function slideh(id,val)
{
	if(val >= 0)
	{
		val -=2;
		$('sim'+id).setOpacity(val/100);
		setTimeout("slideh("+id+","+val+")",10);
	}
}

function slide()
{
	slideh(slidev,100);
	slidev++;
	if(slidev > 3) slidev=1;
	slides(slidev,0);
	
	setTimeout("slide()",5000);
	
}