// JavaScript Document
var activeSub="";
var fadeInterval;
var fadeValue=0;
var check=0;
function showSubNavi(element){
	if(element.getElementsByTagName("ul").length>0){
		var subNaviList=element.getElementsByTagName("ul")[0];
		subNaviList.style.display="block";
		/*
		subNaviList.style.opacity=0;
		fadeValue=0;
		subNaviList.style.filter='alpha(opacity=0)';
		fadeInterval=window.setInterval(function(){fadeIn(subNaviList);},5);
		*/
		check=1;
		activeSub=subNaviList;	
		
		}
}

function fadeIn(element){
	if(fadeValue<100){
		fadeValue+=10;
		element.style.opacity=fadeValue/100;
		element.style.filter='alpha(opacity='+fadeValue+')';
	}
	else{
		window.clearInterval(fadeInterval);	
		
	}
}

function hideSubNavi(element){
	if(element.getElementsByTagName("ul").length>0){
		var subNaviList=element.getElementsByTagName("ul")[0];
		subNaviList.style.display="none";
		window.setTimeout(new Function("check=0;"),20);;
	}
}

function addMouseOverEffect(){
	if(document.getElementById("mainNaviList")){
		var naviList=document.getElementById("mainNaviList");
		for(var i=0;i<naviList.childNodes.length;i++){
			var menu=naviList.childNodes[i];
			if(menu.nodeName=="LI"){
				hideSubNavi(menu);	
				menu.onmouseover=function(){
					if(activeSub!=""){
						activeSub.style.display="none";	
					}
					showSubNavi(this);	
				}
				if(menu.getElementsByTagName("ul").length>0){
					menu.getElementsByTagName("ul")[0].onmouseout=function(){
						hideSubNavi(this.parentNode);		
					}
				
				}
			}
		}	
		naviList.onmouseout=function(){
			if(activeSub!="" && check==0){
				activeSub.style.display="none";	
			}	
		}
	}
}

var maxcount=50;
var counter=0;
function showStarLights(count){
	if(count){
		maxcount=count;
	}
	
	var i=counter;
	var minNumber=0;
	var maxNumber=0;
	var availWidth=document.getElementById("mainContainer").offsetWidth;
	var contentWidth=document.getElementById("contentContainer").offsetWidth;
	var imgSrcArray=new Array("star_light_yellow.gif","star_light_yellow.gif","star_light_orange.gif","star_light_red.gif");
	if(document.getElementById("contentarea1")){
		var contentarea1=document.getElementById("contentBackground");
		var contentContainer=document.getElementById("contentContainer");
		var forbiddenXL=contentContainer.offsetLeft+contentarea1.offsetLeft-20;
		var forbiddenXR=forbiddenXL+contentarea1.offsetWidth+20;
	}
	else{
		var forbiddenXL=0;
		var forbiddenXR=0;
	}
				
	
		var leftPos=(getRandomNumber((availWidth-50)/10)*10);
		var topPos=(getRandomNumber(33)*10)+6;
		if(topPos<130){
			var imgSrc="star_light_yellow.gif";
			var mcColor="0xFFFF99";
		}
		if(topPos>130 && topPos<260){
			var imgSrc="star_light_orange.gif";
			var mcColor="0xF99451";
		}
		if(topPos>260){
			var imgSrc="star_light_red.gif";
			var mcColor="0xFF0000";
		}
		//var imgSrc="star_light_yellow.gif";
		
		if(!document.getElementById("starLight"+i)){
			/*
			var starLight=document.createElement("img");	
			starLight.id="starLight"+i;
			starLight.src="shared/images/"+imgSrc;
			starLight.alt="";
			starLight.style.position="absolute";
			starLight.style.opacity=0;
			*/
			var swfObject='<object type="application/x-shockwave-flash" data="shared/flash/fadeEffect.swf?mcColor='+mcColor+'" width="8" height="8"><param name="movie" value="shared/flash/fadeEffect.swf?mcColor='+mcColor+'" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><param name="quality" value="high" /></object>';
			var starLight=document.createElement("div");
			starLight.id="starLight"+i;
			starLight.width="8";
			starLight.height="8";
			starLight.style.position="absolute";
			starLight.innerHTML=swfObject;
			/*
			var param=document.createElement("param");
			param.name="movie";
			param.value="shared/flash/fadeEffect.swf";
			starLight.appendChild(param);
			param.name="scale";
			param.value="noscale";
			starLight.appendChild(param);
			param.name="wmode";
			param.value="transparent";
			starLight.appendChild(param);
			param.name="quality";
			param.value="high";
			starLight.appendChild(param);
			*/
			
			
			document.getElementById("mainContainer").appendChild(starLight);
		}
		else{
			var starLight=document.getElementById("starLight"+i);
		}
		if(forbiddenXL!=0 && forbiddenXR!=0){
			if(leftPos<forbiddenXL || leftPos>forbiddenXR){
				starLight.style.top=topPos+"px";
				starLight.style.left=leftPos+"px";
				starLight.src=starLight.src;
			}
			else{
				starLight.parentNode.removeChild(starLight);
			}
			
		}
		else{
			starLight.style.top=topPos+"px";
			starLight.style.left=leftPos+"px";
			starLight.src=starLight.src;
		}
		
	if(i<maxcount){
		counter+=1;
		window.setTimeout("showStarLights()",300);	
	}

//window.setTimeout("showStarLights()",1000);
}

/*
var counter=0;
var direction="in";
var waitTime=20;
var interval2;
*/

//window.setTimeout("fadeElement()",1000);

function fadeElement(){
	var tmpWait=waitTime;
	if(document.getElementById("starLight"+counter)){
		
		element=document.getElementById("starLight"+counter);
		element.style.opacity=0;
		var interval2=window.setInterval(function(){
				if(direction=="in"){
					//alert("ha");
					element.style.opacity=parseFloat(element.style.opacity)+0.1;
					if(element.style.opacity>=1){
						direction="wait";
						
					}
				}
				if(direction=="wait"){
					if(waitTime>0){
						waitTime-=1;	
					}
					else{
						direction="out";
						waitTime=tmpWait;
						
					}
				}
				if(direction=="out"){
					element.style.opacity=parseFloat(element.style.opacity)-0.1;
					if(element.style.opacity<=0){
						window.clearInterval(interval2);
						direction="in"
						if(counter<99){
								counter+=1;	
							}
							else{
								counter=0;	
							}
						fadeElement();
					
					}
					
				}
			//alert(element.style.opacity);	
			},20);
		
		
	}
	
}

function getRandomNumber(maxNumber){
	var myNumber = Math.floor((Math.random()*maxNumber)+1);
	return myNumber;
}
