﻿var myBodyWidth,myBodyHeight
onResizeVerScrollArray = new Array;
function resizeEvent(){
	
	 myBodyWidth = 790
	 myBodyHeight = 490;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myBodyWidth = window.innerWidth;
		myBodyHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myBodyWidth = document.documentElement.clientWidth;
		myBodyHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myBodyWidth = document.body.clientWidth;
		myBodyHeight = document.body.clientHeight;
	}
	if(document.getElementById("mainStage")){
		//alert(document.getElementById("mainStage"))
		document.getElementById("body_mouseover").style.width = (myBodyWidth-10).toString() + "px"
		document.getElementById("body_mouseover").style.height = (myBodyHeight-10).toString() + "px"
		
		document.getElementById("mainStage").style.width = (myBodyWidth-4).toString() + "px"
		document.getElementById("horScrollBar_mainStage").style.width = (myBodyWidth-4).toString() + "px"
		document.getElementById("bottom_stage").style.width = (myBodyWidth-10).toString() + "px"
		var bottom_stageHeight =  myBodyHeight-435<100?100: myBodyHeight-435
		document.getElementById("bottom_stage").style.height = bottom_stageHeight.toString() + "px"
		
		var externalText_wrapperHeight =  myBodyHeight-510<35?35: myBodyHeight-510
		document.getElementById("externalTextWrapper").style.height = externalText_wrapperHeight.toString() + "px"
		document.getElementById("scrollBarVer_externalTextWrapper").style.height = externalText_wrapperHeight.toString() + "px"
		
		document.getElementById("popUp").style.height = myBodyHeight.toString() + "px"
		
		var popUpStageHeight= (myBodyHeight-75)<150? 150:myBodyHeight-75;
		
		document.getElementById("popUpScrollStage").style.height =popUpStageHeight.toString() + "px"
		document.getElementById("scrollBarVer_popUpScrollStage").style.height =popUpStageHeight.toString() + "px"
		document.getElementById("scrollBarVer_popUpScrollStage").maxHeightGrouth =  popUpStageHeight
		if(document.getElementById("popInnerStage"))document.getElementById("popInnerStage").maxHeightGrouth =  popUpStageHeight+5
		var menuHeight = myBodyHeight -470 > 63 ? myBodyHeight -470 :63
		var n
		for(n=0;n<onResizeVerScrollArray.length; n++){
			document.getElementById(onResizeVerScrollArray[n]).getElementsByTagName("DIV")[0].style.height = menuHeight.toString()+"px"
			
		}
	}
	
	
}
var popupImag = false
var anyScrollMouseOver = false
/*****************************************/
onLoadArr[onLoadArr.length] = resizeEvent
function close_popUpLayer(){
	document.getElementById("popUp").style.visibility = "hidden"
	document.getElementById("popUpScrollStage").getElementsByTagName("DIV")[0].innerHTML= "&nbsp;"
	popupImag = false
}
function open_popUpLayer(htm){
	
	document.getElementById("popUp").style.visibility = "visible"
	document.getElementById("popUpScrollStage").getElementsByTagName("DIV")[0].innerHTML= htm
	popupImag = true
}
function initiatePageContents(){
	var mStage =  document.getElementById("mainStage")
	if(mStage){
		var pageDivs = mStage.getElementsByTagName("DIV")
		var n
		for(n=0;n<pageDivs.length;n++){
			switch(pageDivs[n].className){
				case "imgBlow":
					pageDivs[n].startMe = behavior_imgBlow_1
					pageDivs[n].startMe()
					
				
				break
				
				
			}
		}
	
	}
}
onLoadArr[onLoadArr.length] = initiatePageContents
var blowObjectArry = new Array;
/************** Behaviors *************************/
function behavior_imgBlow_1(){
	var alfaDivider = 1.7
	var ME = this
	blowObjectArry[blowObjectArry.length] = ME
	var mOver = false
	var play = false
	var  setOpacity
	var baloonText = ME.getElementsByTagName("P")[0]
	var baloonBG = ME.getElementsByTagName("SPAN")[0]
	var flash_name = baloonBG.id
	flash_name = "f" + flash_name.substring(1,flash_name.length)
	var mag_flash_name = "m" +  flash_name.substring(1,flash_name.length)
	var flash_movieBG = getFlashMovie(flash_name)
	var flash_movieMAG = false 
	
	//alert(flash_movieBG)
	var IMGES =  ME.getElementsByTagName("IMG")
	//var baloonBG_top = IMGES[1]
	//var baloonBG_bottom = IMGES[2]
	var baloon = ME.getElementsByTagName("DIV")[0]
	ME.baloon = baloon
	if (bowserType=="explorer6"){baloon.style.width="170px"; baloon.style.height="70px";baloonText.style.width="140px" }
	var currOp = 0
	var s
	var anker = ME.getElementsByTagName("A")[0]
	for(i=0; i<IMGES.length; i++)IMGES[i].alt = ""
	
	function startBaloon(){
		baloon.style.display="block"
		baloonBG.style.height=baloonText.offsetHeight.toString() + "px"
		if (baloonText.innerHTML.length > 3 || anker){
			
			ME.onmouseover = function(){
				mOver = true	
				if(!play){
					play=true
					setOpacity()
				}
				return false
			}
			ME.onmouseout = function(){
				if(!mOver) return false
				mOver = false	
				if(!play){
					play=true
					setOpacity()
				}
			}
		}
	}
	s= setTimeout(startBaloon,1000)
	var anker = ME.getElementsByTagName("A")[0]
	if(anker){
		 flash_movieMAG =  getFlashMovie(mag_flash_name)
		var urlType=anker.href.substring(anker.href.length-3).toLowerCase()
		anker.onclick = function(){
			if (urlType=="jpg" || urlType=="png" || urlType=="gif" || urlType=="bmp"){
				open_popUpLayer('<img src="'+ anker.href + '">')
				return false
			}else{
				
				return true
			}
		}
	}
	setOpacity = function(){
		currOp += mOver?  10 : -10;
			
			if(isAlphaFilterSupported(baloonText)){
				baloonText.filters.alpha.opacity=currOp
				
			}else{
				baloonText.style.opacity = currOp/100		
				
			}
			try{
				flash_movieBG.setOp(currOp/100/alfaDivider)
				if (flash_movieMAG)flash_movieMAG.setOp(currOp/100/alfaDivider)
			}catch(e){}
			if(currOp==100 || currOp==0){
			
				if(currOp==100){
				
				}
				play = false
				return false	
			}
		
		clearTimeout(s)
		s=setTimeout(setOpacity,30)
		
	}
	//baloonBG.style.height= (ME.offsetHeight-10).toString + "px"
	function setBGHeight(){
		baloonBG.style.height= (baloon.offsetHeight).toString() + "px"
		
	}
	
	//setTimeout(setBGHeight,2000)
}
function setIE6(){
	if (bowserType=="explorer6"){
		document.getElementsByTagName("HTML")[0].style.overflowY='scroll'
	}
	resizeEvent()
}




onLoadArr[onLoadArr.length] = setIE6
//var startAnyScroll = false
function set_bodyMouseMove(){
	var startAnyScroll = false
	var scrlVer = document.getElementById("horScrollBar_mainStage")
	document.onmousemove=function(e){
		//document.title="aa"
		if(window.event) e = window.event
		xMPoz = e.clientX
		if (xMPoz > myBodyWidth-30 ){
			if(!startAnyScroll && scrlVer  && !popupImag  ){
				if(scrlVer.public_scrllLeft()){
					startAnyScroll = true
					document.onmouseout = function(){
						scrlVer.public_stop()
						startAnyScroll = false
						document.onmouseout  = ""
						
					}
				}
			}
			
		}else if(xMPoz < 30 && scrlVer  ){
			if(!startAnyScroll && scrlVer  && !popupImag ){
				if(scrlVer.public_scrllRight()){
					startAnyScroll = true
					document.onmouseout = function(){
						scrlVer.public_stop()
						startAnyScroll = false
						document.onmouseout  = ""
						
					}
				}
			}
		}else if(startAnyScroll){
			startAnyScroll = false
			document.onmouseout  = ""
			scrlVer.public_stop()
			
		}
		
		
	}
	
}




function startUnload(){
	document.body.onunload=function(){
		for(n=0; n<blowObjectArry.length; n++){
			blowObjectArry[n].baloon.style.display = "none"	
			
		}	
	}
	 
		 
	 
}
onLoadArr[onLoadArr.length]  = set_bodyMouseMove
onLoadArr[onLoadArr.length]  = startUnload


function isAlphaFilterSupported(obj){
	if (obj.filters){
		if(obj.filters.alpha)  return true
					
	}
	return false
	
	
}


















