// JavaScript Document

jQuery(function($){
	$(document).ready(function(){
	
		 $("#bottomArea ul li").hover(function(){
		   $(this).addClass("hover");
		   
		 },function(){
		   $(this).removeClass("hover");
		 }).click(function(event){
		 	//$('a', this).trigger('click');
		   	location.href = $('a', this).attr('href');
		   	//event.stopPropagation(); add event.stopPropagation() to the click listener function on <a>, that way it won't fire the click for the parent TD.
		 });
		 
		 
		 $("#bottomArea ul li.separator").hover(function(event){
			$(this).removeClass("hover");
		 },function(event){
		   $(this).removeClass("hover");
		 }).click(function(event){
		 });
		
		$('#bottomArea ul li .icon img').attr('src', 'assets_site/images/blank.gif');
		
		
		$('#scrollPane').jScrollPane({scrollbarWidth:8});
		
		var contentAreaHeight = $('#contentArea').height();
		var vpFlashSWFheight = $('#vpFlashSWF').height();
		$('#vpFlashSWF.snapToBottom').css("top",(contentAreaHeight - vpFlashSWFheight) +"px");
		
		/*
		var fixFloatClear = 0;
		if(is_ie6){
			fixFloatClear = 2;
		}
		*/
		
		 
		$("#pageTitleFlash").each( function() { 	
			var txta = $("#pageTitleSWF", this).html();
			var twidth = $("#pageTitleSWF", this).width();
			var theight = $("#pageTitleSWF", this).height();
			
			txta = normalizeHTML(txta);
			
			$("#pageTitleSWF", this).flash("/assets_site/swf/text/flashTitle.swf", {
					width: twidth, // Recommended
					height: theight, // Recommended
				
				flashvars: {
					txt : txta
				},
					paremeters: {
					base : ".",
					wmode : "transparent"
				}
			
			})
		});
		
		
		$("#contentArea .boxSys").each( function() { 	
			var txta = $("#sysBoxTitleSWF", this).html();
			var twidth = $("#sysBoxTitleSWF", this).width();
			var theight = $("#sysBoxTitleSWF", this).height();
			var trel = $("#sysBoxTitleSWF", this).attr('rel');
			
			
			txta = normalizeHTML(txta);
			
			$("#sysBoxTitleSWF:first", this).flash("/assets_site/swf/text/flashBoxSysTitle.swf", {
					width: twidth, // Recommended
					height: theight, // Recommended
				
				flashvars: {
					txt : txta,
					lineColor : trel
				},
					paremeters: {
					base : ".",
					wmode : "transparent"
				}
			
			})
		});
		 
	 
	
	});
	
});


function setTopMenuActive(el){
	$("#navigation ul li a."+el).addClass("active");
}


function setBottomMenuActive(el){
	$("#bottomArea ul li."+el).addClass("active");
}


function setMenuAreaActive(el){
	$("#menuArea ul li."+el).addClass("active");
}

function normalizeHTML(txta){

	var regExp = /<([^>]+)/g;
		
	txta = txta.replace(regExp,
	function (p1){
		var regExp2 = /(\s\w+)=([^ \f\n\r\t\v"]+)/g;
		return p1.replace(regExp2, "$1=\'$2\'");
	});
	txta = txta.replace(/<SPAN/g,'<span')
	txta = txta.replace(/<\/SPAN/g,'</span')
	
	return txta;
}

function proceedContent(from, to){
	/*
	var fromHTML = $(from).html();
	$(to).html(fromHTML);
	*/

	if(from == undefined){
		from = "#content";
	}
	if(to == undefined){
		to = "#proceededContent";
	}
	$(to).append($(from));
}

function proceedHeadline(from, to){
	if(from == undefined){
		from = "#headline";
	}
	if(to == undefined){
		to = "#proceededHeadline";
	}
	$(to).append($(from));
}