// JavaScript Document

var img_array = new Array();
var image_id = 'webbanner_main';
var swap_id = 'webbanner_swap';
var descr_id = 'webbanner_descr';
var bannerIndex = 0;
var banner_change;
var descr_change;


YUI.namespace('nsAnimations');

YUI().use('anim','node','event','dd-drag', function (Y) {
	var description_text = '';
	var posX = 0;
	var posY = -350;
	var direction = 'l'; // b... Bottom(default) || t... Top || l... Left || r... Right
	var siteid = 0;
	var lang = "cr";
	var color = '#ffffff';
	var font_size = '26';
	var index = 0;
	
	var fader = new Y.Anim({  
		node: '#webbanner_swap',  
		from: {
			opacity: 1
		},
		to: {  
			opacity: 0
		},  
		duration: 1  
	});
		
	var fadeout_descr = new Y.Anim({  
		node: '#webbanner_descr',  
		from: {
			opacity: 1
		},
		to: {  
			opacity: 0,
			top: -75
		},  
		duration: 0.5,
		easing: Y.Easing.backIn
	});
	
	var fadein_descr = new Y.Anim({  
		node: '#webbanner_descr',  
		from: {
			opacity: 0,
			top: -350,
			left: '0px'
		},
		to: {  
			opacity: 1,
			top: -330,
			left: '0px'
		},  
		duration: 0.5,
		easing: Y.Easing.backOut
	});
	
	
	var move_descr = new Y.Anim({  
		node: '#webbanner_descr',  
		to: {  
			top: -320
		},  
		duration: 4  
	});
	
	// PUBLIC FUNCTIONS
	YUI.nsAnimations.FadeIn = function() {
		fadein_descr.run()
	};
	
	YUI.nsAnimations.Fade = function(Index,PosX,PosY,Direction,text,Siteid,Lang,Color,Font_size) {
		fader.run();
		fadeout_descr.run();
		posX = PosX;
		posY = PosY;
		direction = Direction;
		description_text = text;
		siteid = Siteid;
		if(Lang!="") {
			lang = Lang;
		}
		color = Color;
		font_size = Font_size;
		document.getElementById('webbanner_item'+index).style.borderColor = '#cccccc';
		index = Index;
	}
	
	function showDescription() {
		//document.getElementById('webbanner_descr').style.height = (posY*(-1)) + 'px';
		updateDirection();
		document.getElementById('webbanner_descr').innerHTML = description_text;
		document.getElementById('webbanner_arrow').style.color = color;
		document.getElementById('webbanner_descr').style.color = color;
		document.getElementById('webbanner_descr').style.fontSize = font_size + 'px';
		document.getElementById('webbanner_item'+index).style.borderColor = '#ef0000';
		if(siteid == '' || siteid == '#') {
			document.getElementById('webbanner_link').href = ("#");
		} else {
			document.getElementById('webbanner_link').href = "index.php?lan=" + lang  + "&id=" + siteid.toString();
		}
		fadein_descr.run();
	}
	
	function updateDirection() {
		//alert('Update: ' + posX + ' ' + posY);
		if(direction == "b") {
			fadein_descr.set('from',{top: -75,left: (posX+'px'),opacity: 0});
			fadein_descr.set('to', {top:posY,left: (posX+'px'),opacity: 1});
			fadeout_descr.set('to', {top: -75,left: (posX+'px'),opacity: 0});
		} else if(direction == "l") {
			fadein_descr.set('from',{top:posY,left:0,opacity: 0});
			fadein_descr.set('to', {top:posY,left: (posX+'px'),opacity: 1});
			fadeout_descr.set('to', {top:posY,left:0,opacity: 0});
		} else if(direction == "r") {
			fadein_descr.set('from',{top:posY,left: (210+'px'),opacity: 0});
			fadein_descr.set('to', {top:posY,left: (posX+'px'),opacity: 1});
			fadeout_descr.set('to', {top:posY,left: (210+'px'),opacity: 0});
		} else if(direction == "t"){
			fadein_descr.set('from',{top: -350,left: (posX+'px'),opacity: 0});
			fadein_descr.set('to', {top:posY,left: (posX+'px'),opacity: 1});
			fadeout_descr.set('to', {top: -350,left: (posX+'px'),opacity: 0});
		}
	}
	
	YUI.nsAnimations.FadeElementIn = function (elemID,duration) {
		var fadeElementIn = new Y.Anim({
			node: elemID,
			to: {
				opacity: 1
			},
			duration: duration,
			easing: Y.Easing.easeOut
		});
		
		fadeElementIn.run();
	}
	
	YUI.nsAnimations.MoveElement = function (elemID,destinationX,destinationY,duration) {
		var fadeElementIn = new Y.Anim({
			node: elemID,
			to: {
				marginRight: destinationX,
				marginTop: destinationY
			},
			duration: duration
		});
		
		fadeElementIn.run();
	}
	
	YUI.nsAnimations.FadeElementOut = function (elemID,duration) {
		var fadeElementOut = new Y.Anim({
			node: elemID,
			to: {
				opacity: 0
			},
			duration: duration,
			easing: Y.Easing.easeIn
		});
		
		fadeElementOut.run();
	}
	
	YUI.nsAnimations.CollapseVertical = function (elemID,duration) {
		var collapseVertical = new Y.Anim({
			node: elemID,
			to: {
				width: 0,
				paddingLeft: 0,
				paddingRight: 0,
				marginRight: 0,
				marginLeft: 0
			},
			duration: duration,
			easing: Y.Easing.easeOut
		});
		
		collapseVertical.run();
	}
	
	YUI.nsAnimations.ZoomIn = function (elemID,duration,toWidth,toHeight) {
		var zoomIn = new Y.Anim({
			node: elemID,
			to: {
				width: toWidth,
				height: toHeight
			},
			duration: duration,
			easing: Y.Easing.easeIn
		});
		
		zoomIn.run();
	}
	
	YUI.nsAnimations.Console = function () {
		var drag = new Y.DD.Drag({
			node: '#console'
		});
	}
	
	fadeout_descr.on('end',showDescription);
});

function init() {
	this.img_array = arguments;
	startFader();
}

function startFader() {
	if(this.banner_change == null) {
		this.banner_change = setInterval("swapBannerAuto()",4000);
	}
}

function stopFader() {
	clearInterval(this.banner_change);
	this.banner_change = null;
}

// Switch to next Banner
function swapBannerAuto() {
	document.getElementById(swap_id).style.backgroundImage = document.getElementById(image_id).style.backgroundImage;
	document.getElementById(swap_id).style.opacity = '1';
	document.getElementById(swap_id).style.filter = 'alpha(opacity = 100)';
	
	bannerIndex++;
	if(bannerIndex >= img_array.length) {
		bannerIndex = 0;
	}
	
	var elem_array = img_array[bannerIndex].split('|');
	document.getElementById(image_id).style.backgroundImage = 'url(' + elem_array[0] +  ')';
	YUI.nsAnimations.Fade(parseInt(elem_array[9]),parseInt(elem_array[4]),parseInt(elem_array[5]),elem_array[6],elem_array[1],elem_array[2],elem_array[3],elem_array[7],elem_array[8]);
}

// Switch to Banner with given Index manually. Stops autoswitching.
function swapBannerManual(index) {
	if(index == bannerIndex) {
		return;	
	}
	
	stopFader();
	
	document.getElementById(swap_id).style.opacity = '1';
	document.getElementById(swap_id).style.filter = 'alpha(opacity = 100)';
	document.getElementById(swap_id).style.backgroundImage = document.getElementById(image_id).style.backgroundImage;
	
	bannerIndex = index;
	if(bannerIndex >= img_array.length) {
		bannerIndex = 0;
	}
	
	var elem_array = img_array[bannerIndex].split('|');
	document.getElementById(image_id).style.backgroundImage = 'url(' + elem_array[0] +  ')';
	YUI.nsAnimations.Fade(parseInt(elem_array[9]),parseInt(elem_array[4]),parseInt(elem_array[5]),elem_array[6],elem_array[1],elem_array[2],elem_array[3],elem_array[7],elem_array[8]);
}


// ------
// LogoChanger-Logic
// ------

var logo_array = new Array();
var logoviewer_width = 500;
var element_width = 88;
var element_height = 88;
var element_margin = 20;
var logoviewer;
var uniqueCounter = 0;
var prev_logo_array = new Array();
var logoviewer_timer;
var logos_created = false;
var mouseOverLogo = false;
var logo_banner_started = false;

function initLogoBanner() {
	this.logo_array = arguments;
	logoviewer = document.getElementById('header_adv');
}

function createLogoElement() {
	COut("createLogoElement(): Creating new logo element (Index " + uniqueCounter + ")");
	
	do {
		var rand = Math.floor(Math.random()*logo_array.length);
		var elem_array = logo_array[rand].split('|');
	} while(prev_logo_array.toString().indexOf(elem_array[0]) != -1)
	
	if(prev_logo_array.length > (logo_array.length-10)) {
		prev_logo_array.shift();	
	}
	prev_logo_array.push(elem_array[0]);
	
	var width = parseInt(elem_array[1],10);
	var height = parseInt(elem_array[2],10);
	
	if(width > element_width) {
		var rfact = element_width/width;
		width*=rfact;
		height*=rfact;
	}
	
	if(height > element_height) {
		var rfact = element_height/height;
		width*=rfact;
		height*=rfact;
	}
	
	
	if(document.getElementById('logo'+uniqueCounter) != null) {
		var removeElement = document.getElementById('logo'+uniqueCounter);
		logoviewer.removeChild(removeElement);	
	}
	
	var elem_link = document.createElement('a');
	elem_link.setAttribute('id','logo'+uniqueCounter);
	elem_link.setAttribute('class','logo_elem');
	elem_link.setAttribute('className','logo_elem');
	elem_link.setAttribute('href','?lan='+elem_array[4]+'&id='+elem_array[3]);
	elem_link.setAttribute('target','_self');
	elem_link.style.opacity = 0.0;
	elem_link.style.filter = "alpha(opacity=0)";
	
	var elem_img = new Image();
	elem_img.src = elem_array[0];
	elem_img.style.width = parseInt(width,10)+'px';
	elem_img.style.height = parseInt(height,10)+'px';
	elem_img.border = 0;
	elem_img.setAttribute('id','logo_image'+uniqueCounter);
	elem_img.align = 'center';
	elem_img.style.top = (((element_height+12)/2)-(height/2))+'px';
	elem_img.style.left = (((element_width+12)/2)-(width/2))+'px';
	elem_img.style.opacity = 0.0;
	elem_img.style.filter = "alpha(opacity=0);";
	
	var logoName = document.createElement('div');
	logoName.setAttribute('id','logoName'+uniqueCounter);
	logoName.setAttribute('style','position:absolute; width:88px; opacity:0.0; filter:alpha(opacity=0);');
	logoName.innerHTML = elem_array[5];
	
	elem_link.appendChild(elem_img);
	logoviewer.appendChild(elem_link);
	
	YUI.nsAnimations.FadeElementIn('#logo'+uniqueCounter,0.5);
	YUI.nsAnimations.FadeElementIn('#logo_image'+uniqueCounter,0.5);
	uniqueCounter++;
	
	if(uniqueCounter >= parseInt(logoviewer_width/(element_width+element_margin))) {
		uniqueCounter = 0;
		logos_created = true;
		if(mouseOverLogo == false) {
			logoviewer_timer = setTimeout('deleteLogoElement()',2500);
		}
	} else if(logos_created == true) {
		if(mouseOverLogo == false) {
			logoviewer_timer = setTimeout('deleteLogoElement()',2500);
		}
	} else {
		setTimeout('createLogoElement()',500);
	}
}

function deleteLogoElement() {
	if(mouseOverLogo == false) {
		COut("deleteLogoElement(): Deleting Element " + uniqueCounter);
		
		YUI.nsAnimations.FadeElementOut('#logo'+uniqueCounter,0.5);
		YUI.nsAnimations.FadeElementOut('#logo_image'+uniqueCounter,0.4);
		
		setTimeout('YUI.nsAnimations.CollapseVertical(\'#logo'+uniqueCounter+'\',0.5)',500);
		setTimeout('createLogoElement()',1000);
	}
}

function stopLogoBanner() {
	if(mouseOverLogo == false && logos_created == true) {
		COut("stopLogoBanner(): MouseOver occured, stop Logo Banner");
		clearTimeout(logoviewer_timer);
		mouseOverLogo = true;
	}
	
}

function startLogoBanner() {
	mouseOverLogo = false;
	if(logos_created == true) {
		COut("startLogoBanner(): MouseOver ended, starting Logo Banner");
		logoviewer_timer = setTimeout('deleteLogoElement()',1500);
	} else {
		if(logo_array.length > 0 && logo_banner_started == false) {
			COut("startLogoBanner(): Starting Logo Banner");
			setTimeout('createLogoElement()',500);
			logo_banner_started = true;
		} else if (logo_array.length == 0) {
			COut("startLogoBanner(): logo_array = ZERO - trying again in 500 ms");
			setTimeout('startLogoBanner()',500);
		}
	}
}

// ------
// News Sider Change Logic
// ------

var news_array = Array();
var news_index = 1;
var news_timer;

function initNewsSider() {
	COut("initNewsSider(): Initialization");	
	this.news_array = arguments;
	
	if(news_array.length > 1) {
		startNewsSider();
	}
}

function swapNewsSider() {
	COut("swapNewsSider(): Switch content, then fade in");
	
	var news_element = document.getElementById('right_bubble_news');
	
	var news_element_array = news_array[news_index].split('|');
	news_element.childNodes[0].innerHTML = news_element_array[0];
	news_element.childNodes[1].innerHTML = news_element_array[1];
	
	document.getElementById('right_bubble_news_link').href = "index.php?lan=" + news_element_array[3] + "&id=" + news_element_array[2];
	
	YUI.nsAnimations.FadeElementIn('#right_bubble_news',0.5);
	startNewsSider();
	news_index = (news_index+1)%news_array.length;
	news_timer = setTimeout("fadeNewsSider();",2500);
}

function fadeNewsSider() {
	COut("fadeNewsSider(): Fade out news content");
	
	YUI.nsAnimations.FadeElementOut('#right_bubble_news',0.5);
	setTimeout("swapNewsSider();",500);
}

var newsSiderRunning = false;

function stopNewsSider() {
	if(newsSiderRunning) {
		COut("stopNewsSider(): Stop news fading (Timer " + news_timer + ")");
		clearTimeout(news_timer);
		newsSiderRunning = false;
	}
}

function startNewsSider() {
	if(!newsSiderRunning) {
		news_timer = setTimeout("fadeNewsSider();",2500);
		COut("startNewsSider(): Start news fading (Timer " + news_timer + ")");
		newsSiderRunning = true;
	}
}

function is_child_of(parent, child) {
	if( child != null ) {			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}

function OnMouseOut(element, event, JavaScript_code) {
	var current_mouse_target = null;
	if( event.toElement ) {				
		current_mouse_target 			 = event.toElement;
	} else if( event.relatedTarget ) {				
		current_mouse_target 			 = event.relatedTarget;
	}
	if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
		eval(JavaScript_code);
	}
}

function addEvent( obj, type, fn )
{
   if (obj.addEventListener) {
      obj.addEventListener( type, fn, false );
   } else if (obj.attachEvent) {
      obj["e"+type+fn] = fn;
      obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
      obj.attachEvent( "on"+type, obj[type+fn] );
   }
}

function removeEvent( obj, type, fn )
{
   if (obj.removeEventListener) {
      obj.removeEventListener( type, fn, false );
   } else if (obj.detachEvent) {
      obj.detachEvent( "on"+type, obj[type+fn] );
      obj[type+fn] = null;
      obj["e"+type+fn] = null;
   }
}

//-------- WESTGATE INTERACTIVE MAP ---------//
var mapCreated = false;
var mapPath = "";
var mapWidth = 0;
var mapHeight = 0;
var mapScale = 1.0;
var posX = -1;
var posY = -1;
var mapName = "";
var mapLogo = "";
var logoWidth = 0;
var logoHeight = 0;

function createMap(pathMap,width,height,X,Y,name,pathLogo,lWidth,lHeight) {
	
	if(mapCreated == true) {
		COut("createMap(): Could not create map, it's already open.");		
		return;	
	}
	
	mapPath = pathMap;
	mapWidth = width;
	mapHeight = height;
	posX = X;
	posY = Y;
	mapName = name;
	mapLogo = pathLogo;
	logoWidth = lWidth;
	logoHeight = lHeight;
	
	var winW = 630, winH = 460;

	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	
	if(winW < (mapWidth+60) || winH < (mapHeight+80)) {
		if(winW < (mapWidth+60)) {
			COut("createMap(): Window width smaller than picture width, scaling image!");
			mapScale = winW/(mapWidth+60);
		}
		if(winH < ((mapHeight+80)*mapScale)) {
			COut("createMap(): Window height smaller than picture height, scaling image!");
			mapScale = winH/(mapHeight+80);	
		}
	}
	
	
	COut("createMap(): Creating Map - Scale" + mapScale + "- Pos:" + posX + "/" + posY);
	COut(document.body);
	
	var map = document.createElement('div');
	map.id = 'locationMap';
	map.className = 'locationMap';
	map.align = 'center';
	map.innerHTML = '<div class="mapImage" >LOADING ...<br /><br /><img src="cms/content/image/HP_Files/shop/loader.gif" border="0" /></div><br /><img style="position: absolute; width:1px;height:1px;" src="' + mapPath + '" border="0" onload="javascript:showMap();"/>';
	
	document.body.appendChild(map);
	mapCreated = true;
}

function showMap() {
	
	if(mapLogo!='' && logoWidth>0 && logoHeight>0) {
		var logoScaler = 1.0;
		if(logoWidth>200) {
			logoScaler = 200/logoWidth;
		}
		
		if((logoHeight*logoScaler)>60) {
			logoScaler = 60/logoHeight;
		}
	} else {
		logoScaler = 0;	
	}
	
	var mapBubble = '<div class="mapBubble" style="top:'+Math.round((posY*mapScale)+40-105)+'px; margin-left:';
	
	if(logoScaler != 0) {
		mapBubble += Math.round((posX*mapScale)+20-((logoWidth*logoScaler)/2)-26) +'px;">';
	} else {
		mapBubble += Math.round((posX*mapScale)+20-75-26) +'px;">';
	}
	
	mapBubble += '<div class="mapBubbleLeft"></div>';
	mapBubble += '<div class="mapBubbleCenter">';
	if(mapLogo!='') {
		
		mapBubble += '<img src="'+mapLogo+'" width="'+Math.round(logoWidth*logoScaler)+'" height="'+Math.round(logoHeight*logoScaler)+'" style="margin-top:15px;" align="absmiddle" />';
	} else {
		mapBubble += '<h2 style="width:150px;height:60px;margin-top:15px;">'+mapName+'</h2>';
	}
	mapBubble += '</div>';
	mapBubble += '<div class="mapBubbleRight"></div>';
	mapBubble += '</div>';
	
	document.getElementById('locationMap').innerHTML = '<div id="mapStruct" style="width:' + Math.round(mapWidth*mapScale+40) + 'px; opacity:0;" >'+
	'<div style="position:absolute; top: 10px; margin-left: -10px; width: 30px; height: 30px; background-image:url(cms/inc/fancyzoom/images-global/zoom/closebox.png); cursor:pointer;" onclick="javascript:closeMap();" ></div>'+mapBubble+
	'<img class="mapImage" id="mapImage" src="' + mapPath + '" width="' + Math.round(mapWidth*mapScale) + '" height="' + Math.round(mapHeight*mapScale) + '"/></div>';
	YUI.nsAnimations.FadeElementIn('#mapStruct',1);
}

function closeMap() {
	YUI.nsAnimations.FadeElementOut('#locationMap',0.2);
	
	setTimeout("javascript:document.body.removeChild(document.getElementById('locationMap'));",200);
	mapPath = '';
	mapWidth = 0;
	mapHeight = 0;
	posX = 0
	posY = 0;
	mapName = '';
	mapLogo = '';
	logoWidth = 0;
	logoHeight = 0;
	mapCreated=false;	
}

//-------- JAVASCRIPT DEBUG CONSOLE ---------//

var console_lines = 0;
var console_pause = false;
var console_buffer = "";

function startConsole() {
	var console = document.createElement('div');
	console.id = 'console';
	console.style.position = 'fixed'; 
	console.style.zIndex = 10000; 
	console.style.top = '10px'; 
	console.style.left = '10px'; 
	console.style.width = '300px'; 
	console.style.padding = '15px'; 
	console.style.backgroundColor = '#000000'; 
	console.style.color = '#FFFFFF'; 
	console.style.opacity = '0.8';
	console.style.filter = "alpha(opacity=80);";
	console.style.borderRadius = '10px';
	console.style.border = 'solid #dddddd 2px';
	console.style.WebkitBoxShadow = "rgba(0, 0, 0, 125) 0px 0px 10px";
	console.innerHTML = '<div id="console_close" style="display:block; position: absolute; top: -10px; left: 312px; width: 30px; height: 30px; background-image:url(cms/inc/fancyzoom/images-global/zoom/closebox.png); cursor:pointer;" onclick="javascript:CClose();"></div><b>JAVASCRIPT CONSOLE:</b><br /><a id="CPause" href="#" onclick="javascript:CPause();"><font color="#cccccc">Pause</font></a><a id="CResume" href="#" onclick="javascript:CResume();" style="display:none;"><font color="#cccccc">Resume</font></a><br />\n<br />\n<div id="console_txt" style="overflow:auto; height:500px;"></div>\n</div>\n<div>';
	//addEvent(console,'mousedown','javascript:YUI.nsAnimations.Drag("#console");','');
	document.body.appendChild(console);
	YUI.nsAnimations.Console();
}

function COut(txt) {	
	if(document.getElementById('console') != null) {
		console_lines++;
		console_buffer = '<b>[ ' + console_lines + ' ]</b> ' + txt + '<br />\n' + console_buffer;
		if(console_pause == false) {
			document.getElementById('console_txt').innerHTML = console_buffer;
		}
	}
}

function CPause() {
	console_pause = true;
	document.getElementById('CPause').style.display = 'none';
	document.getElementById('CResume').style.display = 'inline';
}

function CResume() {
	console_pause = false;	
	document.getElementById('CPause').style.display = 'inline';
	document.getElementById('CResume').style.display = 'none';
}

function CClose() {
	document.getElementById('console').style.display = "none";
}

// -----------------

var height;
var timer;
var isClicked = false;
	
function clearPatternBox() {
	if(isClicked == false) {
		document.getElementById('pattern').value='';
		isClicked = true;
	}
}

function MoveFooter() {
	document.getElementById('footer').style.bottom = '-50px';
	height = -50;
	timer = setInterval("FooterMovement()",10);
}

function FooterMovement() {
	document.getElementById('footer').style.bottom = height + 'px';
	height++;
	if(height > 0) {
		clearTimeout(timer);
	}
}

var snowArray = new Array();
var snowHeightArray = new Array();
var snowGeneratorTimer;
var snowMovementTimer;

function GenerateFlake() {
	if(snowArray.length >= 30) {
		clearTimeout(snowGeneratorTimer);
	}
	var snowflake = new Image();
	var rdm = (Math.floor(Math.random()*6)+1);
	
	if(rdm > 3) {
		rdm = 1;
	}
	
	snowflake.src = "cms/content/image/HP_Files/snowflake" + rdm + ".png";
	snowflake.id = rdm;
	snowflake.style.position = 'absolute';
	snowflake.style.top = '-10px';
	
	var windowWidth = 0;
	if (navigator.appName.indexOf("Microsoft")!=-1) {
 		windowWidth = document.body.offsetWidth;
	} else {
		windowWidth = window.innerWidth;
	}
	
	snowflake.style.right = Math.floor(Math.random()*windowWidth) + 'px';
	
	document.getElementById('snow').appendChild(snowflake);
	
	snowHeightArray.push(-10);
	snowArray.push(snowflake);
}

function MoveFlakes() {
	for(var i=0; i<snowArray.length; i++) {
		if(snowArray[i].id == "1") {
			snowHeightArray[i] = parseInt(snowHeightArray[i]) + 1;
		} else if(snowArray[i].id == "2") {
			snowHeightArray[i] = parseInt(snowHeightArray[i]) + 2;
		} else if(snowArray[i].id == "3") {
			snowHeightArray[i] = parseInt(snowHeightArray[i]) + 3;
		}
		
		snowArray[i].style.top = parseInt(snowHeightArray[i]) + 'px';
		
		if(parseInt(snowHeightArray[i]) >= 200) {
			snowArray[i].style.top = '-10px';
			snowHeightArray[i] = -10;
			
			var windowWidth = 0;
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				windowWidth = document.body.offsetWidth;
			} else {
				windowWidth = window.innerWidth;
			}
			
			snowArray[i].style.right = Math.floor(Math.random()*windowWidth) + 'px';
		}
	}
}

function StartSnow() {
	var browserName=navigator.appName;
	if (browserName=="Microsoft Internet Explorer")
	{
	/*@cc_on 
	if (@_jscript_version < 5.7)
	{
		return;
	}
	@*/
	}

	snowGeneratorTimer = setInterval("GenerateFlake()",500);
	snowMovementTimer = setInterval("MoveFlakes()",(1000/30));
}

function StopSnow() {
	clearTimeout(snowMovementTimer);
}


