function popup_show(obj){
	//obj.style.display="none";
	//var navroot = document.getElementById(obj.parent);
	
	var bodyroot = document.getElementById('body-container');
	
	var productpopup = document.getElementById('productpopupmain');
	if(productpopup) bodyroot.removeChild(productpopup);

	
	
	
	//if(bodyroot.lastChild.className){
	//var pos = bodyroot.lastChild.className.indexOf('productpopup');
	//if (pos>=0) {
	//	alert('exist');
	//}
	//}
	
	var lis=obj.parentNode.getElementsByTagName("DIV");
	var posX=getElementLeft(obj.parentNode);
	var posX2=getElementLeft(bodyroot);
	var posY=getElementTop(obj.parentNode);
	//alert(posX2);
	//alert(lis.length);
	for (i=0; i<lis.length; i++) {
		var pos = lis[i].className.indexOf('productpopup');
			if (pos>=0) {
				
				newdiv1 = document.createElement('div'); 
				newdiv1.setAttribute('id','productpopupmain'); 

				//lis[i].style.display="block";
				var clone = lis[i].cloneNode(true);
				clone.style.display="block";
				clone.id="productpopup";
				clone.style.top=posY;
				clone.style.left=posX-posX2-338;
				newdiv1.appendChild(clone);
				bodyroot.appendChild(newdiv1);
			}
	}
}

function popupShow2(id){
	o=document.getElementById('mainover_'+id);
	o.style.display="none";
	
        // oscar
	//var szNormal2 = 167, szSmall  = 157, szFull   = 187;
	var szNormal2 = 167, szSmall  = 167, szFull   = 167;

	
	var kwicks = $$("#cs2_prodoductboxes_main .productmainover");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});

	
	o=document.getElementById('popup_'+id);
	o.style.display="block";
}

function getHeightt(element){
	var els = element.style;
	var originalVisibility = els.visibility;
	var originalPosition = els.position;
	var originalDisplay = els.display;
	els.visibility = 'hidden';
	els.position = 'absolute';
	els.display = 'block';
	var originalWidth = element.clientWidth;
	var originalHeight = element.clientHeight;
	els.display = originalDisplay;
	els.position = originalPosition;
	els.visibility = originalVisibility;
	return originalHeight; 
}

function popupShow(id) {
	if(CloseTmr)clearTimeout(CloseTmr);
	//alert(id);
		var bodyroot = document.getElementById('body-container');

		var productpopup = document.getElementById('productpopupmain');
		if(productpopup) bodyroot.removeChild(productpopup);

		var pp = document.getElementById('popup_'+id);
		//alert(pp.id);
		//vyska=$('popup_'+id).getHeight();
		
		dim=$('popup_'+id).getCoordinates();
		vyska=dim['height'];
		
		alert(vyska);
		var posX=getElementLeft(pp.parentNode);
		var posX2=getElementLeft(bodyroot);
		var posY=getElementTop(pp.parentNode);
		
		newdiv1 = document.createElement('div'); 
		newdiv1.setAttribute('id','productpopupmain');
		//newdiv1.style.display="block";
		//lis[i].style.display="block";
		var clone = pp.cloneNode(true);
		clone.style.display="block";
		clone.id="productpopup";
		clone.style.top=posY-vyska+168;
		clone.style.left=posX-posX2-338;
		newdiv1.appendChild(clone);
		bodyroot.appendChild(newdiv1);
//alert('xxx');
		
		
		var pp2 = document.getElementById('productpopupmain');
		//vyska=parseInt(pp.getHeight());

		//alert(posY-vyska);
		//pp2.style.top=posY-vyska;
		CurOvr=pp2;
		CurPopup=id;
		pp2.onmouseout=function() {                       
				deActivatePopup2(this);
			}
			
		pp2.onmouseover=function() {
			if(CloseTmr)clearTimeout(CloseTmr);
		}
		
}

function deActivatePopup(cur) {
	if(CloseTmr)clearTimeout(CloseTmr);
	cur.style.display="none";
	CurPopup=null;
}

function deActivatePopup2(cur) {
	if(CloseTmr)clearTimeout(CloseTmr);
	CloseTmr=setTimeout("deActivatePopup(CurOvr)",300);
	
}

activatePopup = function(){
	var navroot = document.getElementById('top3-contentright');
	if(navroot){
	var lis=navroot.getElementsByTagName("DIV");  
		id=0;
	for (i=0; i<lis.length; i++) {
		var pos = lis[i].className.indexOf('productmaintitle');
				if (pos>=0) {
					lis[i].id='maintitle_'+id;
					lis[i].onmouseover=function() {
						if(CloseTmr)clearTimeout(CloseTmr);
						ksk=this.id.split('_'); 
						//pp = document.getElementById('popup_'+ksk[1]);
						//pp.style.display="block";
						if(ksk[1]!=CurPopup) popupShow(ksk[1]);
					}
					lis[i].onmouseout=function() {  
						deActivatePopup2(this);
					}

				}

		var pos = lis[i].className.indexOf('productheadermainimage');
				if (pos>=0) {
					lis[i].id='mainimage_'+id;
					lis[i].onmouseover=function() {
						if(CloseTmr)clearTimeout(CloseTmr);
						ksk=this.id.split('_'); 
						//pp = document.getElementById('popup_'+ksk[1]);
						//pp.style.display="block";
						if(ksk[1]!=CurPopup) popupShow(ksk[1]);
					}
					lis[i].onmouseout=function() {                       
						deActivatePopup2(this);
					}
				}
				
		var pos = lis[i].className.indexOf('productpopup');
				if (pos>=0) {
					lis[i].id='popup_'+id;
					id++;
				}
				
				
	}
	}
}

function getElementLeft(elem) {
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;
	
}

function getElementTop(elem) {
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
}



	
function activateA(cur) {
	if(cur){
		if(CloseTmr)clearTimeout(CloseTmr);
		if(timerID2)clearTimeout(timerID2);
		
		//vyska=getHeightt(cur.lastChild);
		//cur.lastChild.style.clip = "rect(0,850,0,0)";
		cur.lastChild.style.display="block";
					
		//vyska=getHeightt(cur.lastChild);
		vyska=cur.lastChild.heightt;
		cur1=cur.lastChild;
		
		if(vyska>curHeight)
		epull_down(vyska,curHeight);
		else
		epull_down2(vyska,curHeight);	
		curHeight=vyska;
		
		//alert(cur.lastChild.lastChild.lastChild.tagName+'---'+cur.lastChild.lastChild.lastChild.className);
		//var myEffect2 = cur.lastChild.lastChild.lastChild.effect('opacity', {duration: 500, transition: Fx.Transitions.linear});
		//myEffect2.start(0,1);
		

		
		t=cur.firstChild;
		if (t) {
			
			var pos = t.className.indexOf('firstlevellink');
			if (pos>=0) {
				t.className += ' hoverdata';
			}
		}

	}
	
	/*
	if(CloseTmr)clearTimeout(CloseTmr);
	var t = cur;
	CurOvr=cur;
	if(cur.prvi) CurPrvi=cur;
	else
	CurPrvi=null;	
*/

}


var t=null;
var curO=null;
var curOHeight=null;
var timerID=null;
var activatePopup;
var CloseTmr;
var OpenTmr;
var timerID2;
var curOvr;
var curOvr2;
var curOvr3;
var CurPrvi;
var CurPopup;
var cur1;
var activateMenu;
var curHeight;

function activateMenuMain(nav){
	

	
	//firstlevellink topmenul1-ifsub
	
}


function epull_down(to,nowv) {
	//alert(to);
	if(cur1){
        cur1.style.clip = "rect(0,850," + (nowv + 1) + ",0)";
		 nowv=nowv+((to-nowv)/8)+1;
		 if(nowv < to) timerID2 = setTimeout("epull_down("+to+","+nowv+")",0);
		 else {
			 timerID2 = "";
			
			 cur1=null;
		 }
	}
}

function epull_down2(to,nowv) {
	//alert(to+'xxxx'+nowv);
	if(cur1){
		cur1.style.clip = "rect(0,850,"+nowv+",0)";
		
		 nowv=nowv-5;
		 if(nowv > to) timerID2 = setTimeout("epull_down2("+to+","+nowv+")",0);
		 else {
			 timerID2 = "";
			
			 cur1=null;
		 }
		
	}
}

function epull_up(to,nowv,vyska) {
 curO.style.clip = "rect(0,850,"+nowv+",0)";
 nowv=(nowv/2)-1;
 if(nowv > to) timerID = setTimeout("epull_up("+to+","+nowv+","+vyska+")",0);
 else {
	 timerID = "";
	 curO.style.display="none";
	// curO.style.height=vyska;
	curO.style.clip = "rect(0,850,"+vyska+",0)";
	 //cur0=null;
	 //CurOvr=null;
 }
}

function deActivateA(cur) {
	if(CloseTmr)clearTimeout(CloseTmr);
	if(cur){
		vyska=getHeightt(cur.lastChild);
		curO=cur.lastChild;
		curOHeigt=vyska;
		epull_up(0,vyska,vyska);
		cur.opened=0;
		CurOvr2=null;
		curHeight=null;
		if(cur.firstChild.firstChild.src) cur.firstChild.firstChild.src = eval(cur.firstChild.firstChild.name+"_n.src");
		//var myEffect2 = cur.lastChild.lastChild.lastChild.effect('opacity', {duration: 250, transition: Fx.Transitions.linear});
		//myEffect2.start(1,0);

		t=cur.firstChild;
		if (t) {
			var pos = t.className.indexOf('firstlevellink');
			if (pos>=0) {
				t.className=t.className.replace(" hoverdata", "");
			}
		}
	}
}


var CloseTmr=null;
var OpenTmr=null;
var timerID2=null;
var CurOvr=null;
var CurOvr2=null;
var CurOvr3=null;
var CurPrvi=null;
var CurPopup=null;
var cur1=null;
var curHeight=0;

function deActivateA2(cur) {
	if(CloseTmr)clearTimeout(CloseTmr);
	CloseTmr=setTimeout("deActivateA(CurOvr2)",200);
	
}

function activateA2(cur) {
	
	cur1=cur.lastChild;
	
	if(OpenTmr)clearTimeout(OpenTmr);
	OpenTmr=setTimeout("activateA22(CurOvr)",0);
	
}

function activateA22(cur) {
	vyska=getHeightt(cur1);
	cur1.style.clip = "rect(0,850,0,0)";
	cur1.style.display="block";
	
	cur1Heigt=vyska;
	epull_down(vyska,0);
	this.opened=1;
	
}

//


// IE only makes :hover work on LI tags
activateMenu = function(nav) {
	/* Get all the list items within the menu */
	var navroot = document.getElementById(nav);

	var lis=navroot.getElementsByTagName("LI");  
		id=0;
	for (i=0; i<lis.length; i++) {
		depth=0;
		/* If the LI has another menu level */
		if(lis[i].lastChild){
		if(lis[i].lastChild.tagName=="UL" || lis[i].lastChild.tagName=="DIV"){
			//depth++;
			//lis[i].lastChild.id="ull"+id+'_'+depth;
			//alert(lis[i].lastChild.className);
			
			vyska=getHeightt(lis[i].lastChild);
			if (nav=='yacbddm') lis[i].lastChild.firstChild.heightt=vyska;
			if (nav=='yacbddm') lis[i].lastChild.heightt=vyska;
			//alert (vyska);
			
			var pos = lis[i].lastChild.className.indexOf('submenu2-item');  /// level 2
				if (pos>=0) {
					lis[i].dalsi=1;
					lis[i].opened=0;
					var bodyroot = document.getElementById('body-container');
					 var posX2=getElementLeft(bodyroot);
					 var left = getElementLeft(lis[i].lastChild);
					 //alert(lis[i].lastChild.tagName+'--'+lis[i].lastChild.className+'--'+'--'+curParPos+'--'+(left-posX2));
					lis[i].lastChild.style.left=curParPos+120;
				}
			var pos = lis[i].lastChild.className.indexOf('submenu-item');  /// level 1
				if (pos>=0) {
					// lis[i].parentNode ul kde treba nastavit margin
					
					 var bodyroot = document.getElementById('body-container');
					 var posX2=getElementLeft(bodyroot);
					 var left = getElementLeft(lis[i]);
					 //alert(lis[i].tagName+'--'+lis[i].className+'--'+(left-posX2));
					 //alert(lis[i].lastChild.lastChild.lastChild.tagName+'--'+lis[i].lastChild.lastChild.lastChild.className+'--'+(left-posX2));
					 lis[i].lastChild.lastChild.lastChild.style.paddingLeft=left-posX2+2;
					curParPos=left-posX2+2;
				}
			/* assign the function to the LI */
			var pos2 = lis[i].lastChild.className.indexOf('menu-item'); /// level 0
				if (pos2>=0) {
					lis[i].firstChild.onmouseout=function(){};
					//alert(lis[i].firstChild.onmouseout);
					lis[i].prvi=1;
					lis[i].opened=0;


				}


			lis[i].onmouseover=function() {		
					/* display the inner menu */
					if (CurPrvi) CurOvr.lastChild.style.display="none"; 
					
					//alert(this.prvi +'xx'+ this.opened);
					
					if(CloseTmr)clearTimeout(CloseTmr);
					
					if (this.prvi && this!=CurOvr2){
						if(CurOvr2){
							curHeight=getHeightt(CurOvr2.lastChild);
						CurOvr2.lastChild.style.display="none";
						if(CurOvr2.firstChild.firstChild.src) CurOvr2.firstChild.firstChild.src = eval(CurOvr2.firstChild.firstChild.name+"_n.src");
							//deActivateA(CurOvr2);
							//CurOvr2.opened=0;
						}
						//this.style.display="none";
						//alert(this.firstChild.firstChild.name);
						
						//this.firstChild.firstChild.src = eval(this.firstChild.firstChild.name+"_h.src");
						CurOvr2=this;
						activateA(this);
						this.opened=1;
					}
					else if(this.dalsi)
					{
						//alert(this.firstChild.tagName+'---'+this.firstChild.className);
						this.firstChild.className += ' hoverdata';
						this.lastChild.style.display="block";
					}
					/*if(this.prvi && this.opened==0){
						activateA2(this);
						this.opened=1;
					}else if (this.dalsi){
					*/
					
					//}
					//activateA(this);
			}
			
			lis[i].onmouseout=function() {                       
				//this.lastChild.style.display="none";
				//alert('xxx');
				//curItem=this;
				//CloseTmr=setTimeout("deActivate2(this)",1000);
				if (this.prvi){
						//if(CurOvr2){
							//CurOvr2.lastChild.style.display="none";
							
							deActivateA2(this);
							//this.opened=0;
						}
						
						//CurOvr2=this;
						//activateA(this);
						//this.opened=1;
				else if (this.dalsi==1) {
					//this.parentNode.parentNode.firstChild.firstChild.firstChild.className=this.parentNode.parentNode.firstChild.firstChild.firstChild.className.replace(" hoverdata", "");
					//#t=this.;
					//alert(this.parentNode.tagName+'---'+this.parentNode.className);
					if(this.parentNode.parentNode){
					var lis = this.parentNode.parentNode.getElementsByTagName('LI');
					  for(j=0;j<lis.length;j++) {
						 lis[j].firstChild.className=lis[j].firstChild.className.replace(" hoverdata", "");  
					  }
					/*
						lis.each(function(kwick, i) {
							 kwick.firstChild.className=kwick.firstChild.className.replace(" hoverdata", "");
					  });
						*/
					}
					/*
					if (t) {
						var pos = t.className.indexOf('firstlevellink');
						if (pos>=0) {
							t.className=t.className.replace(" hoverdata", "");
						}
					}
					*/
					//alert(this.parentNode.parentNode.firstChild.firstChild.firstChild.tagName+'---'+this.parentNode.parentNode.firstChild.firstChild.firstChild.className);
				this.lastChild.style.display="none";
				}else{
					
				}
				//this.opened=0;
				//deActivateA2(this);
			}
			
			lis[i].onclick=function() {
				//var navroot = document.getElementById('yacbddm');
				//navroot.style.display="none";
			}
		}
		}
	}
}

var curBig=-1;


function fffff(){
		lis[i].onmouseover=function() {		
			/* display the inner menu */
			if (CurPrvi) CurOvr.lastChild.style.display="none"; 
			
			/*
			vyska=getHeightt(this.lastChild);
			this.lastChild.style.clip = "rect(0,850,0,0)";
			this.lastChild.style.display="block";
			
			curO=this.lastChild;
			curOHeigt=vyska;
			epull_down(vyska,0);
			*/
			this.lastChild.style.display="block"; 
			activateA(this);
	}
	
	lis[i].onmouseout=function() {                       
		//this.lastChild.style.display="none";
		//alert('xxx');
		//curItem=this;
		//CloseTmr=setTimeout("deActivate2(this)",1000);
		if (this.dalsi==1) {
		this.lastChild.style.display="none";
		}
		deActivateA2(this);
	}
}

function swapBig(){
//	alert(curBig);
	if(curBig>-1){
		oo=document.getElementById('mainover_'+curBig);
		oo.style.display="block";
		oo=document.getElementById('popup_'+curBig);
		oo.style.display="none";
		curBig=-1;
	}
}

function activate1(){
	////activateMenu('yacbddm');
	activateMenu('yacbddm2');
	//activatePopup();
	//$('yacbddm').style.display="block";
	
	var bodyroot = document.getElementById('body-container');
	var from = document.getElementById('cs2_prodoductboxes_main_outer');
	
	if(from)from.style.display="block";
	
	
	
	//var productpopup = document.getElementById('productpopupmain');
	
	var pp = document.getElementById('cs2_prodoductboxes_main');
	if(pp){
	
	var outer = document.getElementById('top3-contentleft');
outer.style.position="absolute";		
// Position oscar
	outer.style.top=318;	
	/*	
	var clone = pp.cloneNode(true);
	
	newdiv1 = document.createElement('div'); 
	newdiv1.setAttribute('id','productpopupmain');
	newdiv1.style.width="500px";
	newdiv1.style.height="500px";
	newdiv1.style.backgroundColor="red";
	newdiv1.style.top=402;
	
	newdiv1.appendChild(clone);
	bodyroot.appendChild(newdiv1);
	
	from.removeChild(pp);
	*/
	//var szNormal = 167, szSmall  = 147, szSmall2  = 77, szFull = 207; szFullH = 154; szFull2 = 337; hght=167;
// oscar
	var szNormal = 167, szSmall  = 167, szSmall2  = 77, szFull = 167; szFullH = 154; szFull2 = 337; hght=154;
 
	var kwicks = $$("#cs2_prodoductboxes_main .productmainover");
	//alert(kwicks.length);
	//var fx = new Fx.Elements(kwicks, {wait: false, duration: 800, transition: Fx.Transitions.Back.easeOut});
	//var fx2 = new Fx.Elements(kwicks, {wait: false, duration: 800, transition: Fx.Transitions.Back.easeOut});
// oscar
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 0, transition: Fx.Transitions.Back.easeOut});
	var fx2 = new Fx.Elements(kwicks, {wait: false, duration: 0, transition: Fx.Transitions.Back.easeOut});

	
	
	
		var o = {};
		kwicks.each(function(kwick, i) {
			oo=document.getElementById('mainover_'+i);
			oo.style.display="block";
			oo=document.getElementById('popup_'+i);
			oo.style.display="none";
			o[i] = {width: [kwick.getStyle("width").toInt(), szNormal],marginTop:[kwick.getStyle("marginTop").toInt(),24],height:[kwick.getStyle("height").toInt(),130]}
		});
		fx.start(o);

	kwicks.each(function(kwick, i) {
/*		kwick.addEvent("mouseenter", function(event) {
			
			swapBig();	
				
			var o = {};
			o[i] = {width: [kwick.getStyle("width").toInt(), szFull],marginTop:[24,0],height:[kwick.getStyle("height").toInt(), szFullH]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall) o[j] = {width: [w, szSmall],marginTop:[24,24],height:[130,130]};
				}
			});
			fx.start(o);
		});
*/
		
/*		kwick.addEvent("click", function(event) {
			o=document.getElementById('mainover_'+i);
			//alert(i);
			//var myEffect = o.effect('opacity', {duration: 100, transition: Fx.Transitions.linear,onComplete:function(){
				o3=document.getElementById('mainover_'+i);
				o3.style.display="none";
				o2=document.getElementById('popup_'+i);
				
				o4=o3.parentNode;
				
				var myFx = new Fx.Style(o2, 'width').set(337);
				vyska=getHeightt(o2);
				
				o2.style.display="block";
				curBig=i;
				
				//alert(vyska);
				var myFx = new Fx.Style(o2, 'width').set(167);
				//var myFx = new Fx.Style(o2, 'marginTop').set(185-vyska);
				
				//var myFx = new Fx.Style(o4, 'width').set(337);
				//var myFx = new Fx.Style(o4, 'width').set(337);
				//var myFx = new Fx.Style(o4, 'height').set(vyska);
				//var myFx = new Fx.Style(o4, 'marginTop').set(185-vyska);
				
				var myEffect2 = o2.effect('width', {duration: 200, transition: Fx.Transitions.linear});
				myEffect2.start(167,337);
				
			//}});
			//myEffect.start(1, 0);

			//var myEffect = o2.effect('opacity', {duration: 100, transition: Fx.Transitions.linear});
			//myEffect.start(0, 1);
			
			var o = {};
			o[i] = {width: [kwick.getStyle("width").toInt(), szFull2],height:[kwick.getStyle("height").toInt(), vyska],marginTop:[kwick.getStyle("marginTop").toInt(), 185-vyska]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall2) o[j] = {width: [w, szSmall2]};
					//o[j] = {height:[hght,hght]};
				}
			});
			fx.start(o);
		});
*/
		
		
	});
	 
	$("cs2_prodoductboxes_main").addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			oo=document.getElementById('mainover_'+i);
			oo.style.display="block";
			oo=document.getElementById('popup_'+i);
			oo.style.display="none";
			o[i] = {width: [kwick.getStyle("width").toInt(), szNormal],marginTop:[kwick.getStyle("marginTop").toInt(),24],height:[kwick.getStyle("height").toInt(),130]}
		});
		fx.start(o);
	})
	}
	
	/// hoover for main menu
	/*
	var list = $$('.submenu-item li');
	list.each(function(element) {
	 
		var fx = new Fx.Styles(element, {duration:200, wait:false});
	 
		element.addEvent('mouseenter', function(){
			fx.start({
				'margin-left': 5,
				'background-color': '#666',
				color: '#ff8'
			});
		});
	 
		element.addEvent('mouseleave', function(){
			fx.start({
				'margin-left': 0,
				'background-color': '#333',
				'color': '#888'
			});
		});
	 
	});
	*/
}

if(window.addEventListener){
window.addEventListener('load', activate1, false);
}else{
	if(window.attachEvent){
window.attachEvent('onload', activate1);
	}
}

window.onunload=function(){
	var navroot = document.getElementById('yacbddm');
	//navroot.style.display="none";
}

//window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
//	activateMenu('yacbddm');
//	activateMenu('yacbddm2');
//	activatePopup();
//}
