/*  
Script made by Martial Boissonneault © 2001-03 http://getElementById.com/
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/

var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var MenuTop = 205;    // menu top position
var MenuLeft = 195;  // how much your menu slide in and out

var timerID1 = null;
var timerID2 = null;

closecode= null;

var menuStatus = 0;

function menuStatic()
{
	if ( ! window.location.href.match(/milka.com.pl/) && ! window.location.href.match(/plpl1/) )
		slideMenuInitStatic();
	else
		slideMenuInit();
}

function activateMenuClose()
{
	if ( ! window.location.href.match(/milka.com.pl/) && ! window.location.href.match(/plpl1/) )
		closecode=setTimeout('activeMenu()', 5000);
}

function activateMenu()
{
	if ( ! window.location.href.match(/milka.com.pl/) && ! window.location.href.match(/plpl1/) )
		setTimeout('activeMenu()', 500);
}

function initMenu() { slideMenuInit(); }



function activeMenu(opvar) {
	document.getElementById("menu").style.top = MenuTop ;
    if (opvar != 'close') {			
			if(menuStatus == 0) {
				slideIn();
				menuStatus = 1;
			} else if (menuStatus == 1) {
				slideOut();
				menuStatus = 0;
			} 

	} else if (opvar == 'close'){
		slideOut();
		menuStatus = 0;
		clearTimeout(closecode);
	}

}

function statik(){
	if(ie5){
    		document.getElementById('menu').style.top = document.body.scrollTop + MenuTop;
    	} 
    	if(ns6){
    		document.getElementById('menu').style.top = window.pageYOffset + MenuTop;
    	}
}

function changeBG(obj, bgColor) {
   	if(ie5 || ns6){
	    	obj.style.backgroundColor = bgColor;
	}
}

function slideIn(){
	if(ie5 || ns6){
		if(parseInt(document.getElementById('menu').style.left) < 45){
			clearTimeout(timerID2);
			document.getElementById('menu').style.left = parseInt(document.getElementById('menu').style.left) + 15 + "px";
			timerID1=setTimeout("slideIn()", 30);
		}
		
	}
}

function slideOut(){
	if(ie5 || ns6){
		if(parseInt(document.getElementById('menu').style.left) > -MenuLeft){
			clearTimeout(timerID1);
			document.getElementById('menu').style.left = parseInt(document.getElementById('menu').style.left) - 15 + "px";
			timerID2=setTimeout("slideOut()", 30);
		}
	}
}

function slideMenuInit() {
    	if(ie5 || ns6){
		document.getElementById('menu').style.visibility = "visible";
		document.getElementById('menu').style.left = -MenuLeft;
		document.getElementById('menu').style.top = MenuTop;
	}
}

function slideMenuInitStatic() {
    	if(ie5 || ns6){
		document.getElementById('menu').style.visibility = "visible";
		document.getElementById('menu').style.left = 45;
		document.getElementById('menu').style.top = 205;
	}
}

//fades layer in and out
opac3 = 0;

function opacIn1() {
	if(opac3 != 60){
		opac3+=5;
		if(ie5) document.getElementById('fadeprimarynav').filters.alpha.opacity = opac3;
		if(ns6) document.getElementById('fadeprimarynav').style.MozOpacity = opac3/100;
		setTimeout('opacIn1()', 100);
		}else{
		//calls opacOut() function, therefore creating the loop
		
	}
}

function opacIn2() {
	if(opac3 != 70){
		opac3+=5;
		if(ie5) document.getElementById('primarynav').filters.alpha.opacity = opac3;
		if(ns6) document.getElementById('primarynav').style.MozOpacity = opac3/100;
		setTimeout('opacIn2()', 100);
		}else{
		//calls opacOut() function, therefore creating the loop
		
	}
}

function opacOut() {
	if(opac3 != 0){
		opac3-=3;
		if(ie5) document.getElementById('fadeprimarynav').filters.alpha.opacity = opac3;
		if(ns6) document.getElementById('fadeprimarynav').style.MozOpacity = opac3/100;
		setTimeout('opacOut()', 10);
		}else{
		//calls opacOut() function, therefore creating the loop
		
	}
}
