var wipeOut;
var wipeIn;
var currentAnimation;
var isStart=0;
var xPos;
var yPos;
var divObj;
var divId;
var divObjOld;
var FadeTime;
var WipeTime;

function showImageHover( row, id){
if ( document.getElementById("menu"+id+"") ){
	document.getElementById("menu"+id+"").src="uploads/tx_txnewcustommenu/"+row+"";
   }
 
}

function showImageNormal( no, cur, id){
	if ( newcustommenu_isMausInDivObj(id) ){
	document.getElementById("menu"+id+"").src="uploads/tx_txnewcustommenu/"+cur+"";
	}


}

function txnewcustommenu_getSubUlPos(id){
	if(document.getElementById("naviSubUL"+id+"")){
        var cords = dojo.coords("naviSubLI"+id+"");
        var x= cords.l;
	var y = cords.t;
}
	if(document.getElementById("naviSubUL"+id+"")){
		document.getElementById("naviSubUL"+id+"").style.position="absolute";
		document.getElementById("naviSubUL"+id+"").style.left=x;
		document.getElementById("naviSubUL"+id+"").style.top=y+40;
	}
}

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		if(navRoot) 
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
				 	}
					 node.onmouseout=function() {
					 	this.className=this.className.replace(" over", "");
				 	}
			 	}
		 	}
	}
}

window.onload=startList;

document.onmousemove=newcustommenu_getMouseCoordinates;

function txnewcustommenu_animImage(activeImage, id){
	document.getElementById("animImage"+id+"").src="uploads/tx_txnewcustommenu/"+activeImage+"";
}	
  
function newcustommenu_doAnimation(index, id) {
    
  divObj="animDiv"+id+"";
	newcustommenu_isDivObjVisible(id);
	divId=id;
	
	if(divObjOld != divObj ){
		 
		if( document.getElementById(divObjOld) ){
			document.getElementById(divObjOld).style.display="none";
		}
		divObjOld = divObj;
	}
	
	switch(index) {
	case 1:
	  wipeOutForMenuItem(id);
	  break;
	case 2: 
	  wipeInForMenuItem(id);
	  break;
	
	}
}  

function wipeOutForMenuItem(id) {

	FadeTimeOut=50;
	WipeTimeOut=50;
	
	if ( !newcustommenu_isMausInDivObj(id) ) {
		var fade, wipe;
	
		fade = dojo.fadeOut({node: divObj,duration: FadeTimeOut});
		wipe = dojo.fx.wipeOut({node: divObj,duration: WipeTimeOut});
		wipeOut = dojo.fx.combine([wipe,fade]);
		currentAnimation = wipeOut;
		//console.log('wipeOut animation out');
		currentAnimation.play();
		
	}
	else {
		pauseAnimation();
		//document.getElementById(id).setAttribute('onmouseover', '');
	}
	
}
 
function wipeInForMenuItem(id) {
		
	var fade, wipe;

	fade = dojo.fadeIn({node: divObj,duration: 1});
	wipe = dojo.fx.wipeIn({node: divObj,duration: 500});
	wipeIn = dojo.fx.combine([fade,wipe]);
	currentAnimation = wipeIn;
	//console.log('wipeIn animation started');
	currentAnimation.play();
	
	
}  

function pauseAnimation(){
	if(currentAnimation && currentAnimation.status() == "playing"){
		currentAnimation.pause();
	}
}

function resumeAnimation(){
	if(currentAnimation && currentAnimation.status() == "paused"){
		currentAnimation.play();
	}
}



function newcustommenu_getMouseCoordinates( event )
{
	if (!event) event = window.event;
	
	xPos = event.clientX;
	yPos = event.clientY;
	
	if( isStart==1 ){
		if( !newcustommenu_isMausInDivObj() ){
			newcustommenu_doAnimation(1, 3);
			resumeAnimation();
		}

	}
	
}

function newcustommenu_isDivObjVisible(id){
	
	
	if(document.getElementById(divObj)){ 
		if(document.getElementById(divObj).style.display!="none"){
		
			isStart=1;
			return true;
			//console.log('isVisible');
			
		}
		else {
		
			isStart=0;
			return true;
			
		}
	}	
}

function newcustommenu_isMausInDivObj(id){
	
	var isIn=false;
	if(newcustommenu_isDivObjVisible(id)){
		//console.log('P1');
		var cord = dojo.coords(divObj);
    var xDiv = cord.x;
		var yDiv = cord.y;
		var heightDiv = cord.h;
		
		if ( xPos > xDiv && xPos < (xDiv+910)) {
			if (yPos >= (yDiv -30)&& yPos <= (yDiv+heightDiv) ){
				 isIn=true;
			}
			
		}
	}
	return isIn;
}
  

