//INIT NEWS SECTION 

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isIE6 = false;
if(isIE){
	var str = navigator.appVersion;
	var len = str.substr(0,str.indexOf("MSIE")).length
	if(str.substr(len+5,3) == "6.0"){
		isIE6 = true;	
	}
}

function getNewsIndex(){
	var str = "<ul>";
	for(var i=0;i<feeds.length;i++){
		var date = feeds[i][3];
		var cont = feeds[i][0].replace("&lt;","<").replace("&gt;",">");
		str += "<li><a href='news.html' target='_parent'><span style='font-weigth:bold'>"+date+"</span><br/><br/>"+cont+"</a></li>";		
	}
	str+"</ul>";
	$("#newsDiv").html(str);
	
	$('#newsBox').serialScroll({
		target:'#newsDiv',
		items:'li', 
		prev:'img.prev',
		next:'img.next',
		axis:'xy',
		duration:700,
		force:false, 
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){}
	});
}

function getNewsArticles(){
	var htmlStr = "";
	
	var className = "normal";
	var id = "decrease";
	var icon = "images/btn_news_decrease.gif";
	
	for(var i=0;i<feeds.length;i++){
		var title =  feeds[i][0]
		title = title.replace(/&lt;/g,"<").replace(/&gt;/g,">");
		var description = feeds[i][1]
		description = description.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,"\"");
		var url = feeds[i][2];
		var pubDate = feeds[i][3];
		/*
		if(i!=0){
			className = "newscontent";	
			icon = "images/btn_news_plus.gif";
			id = "plus";
		}
		*/
		
		if(isIE6){
			topLeft = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="10" height="10" id="topleft" align="middle"><param name="movie" value="images/topleft.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="images/topleft.swf" quality="high" wmode="transparent" width="10" height="10" name="topleft" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
			topRight = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="10" height="10" id="topright" align="middle"><param name="movie" value="images/topright.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="images/topright.swf" quality="high" wmode="transparent" width="10" height="10" name="topright" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
			bottomRight = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="10" height="10" id="bottomright" align="middle"><param name="movie" value="images/bottomright.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="images/bottomright.swf" quality="high" wmode="transparent" width="10" height="10" name="bottomright" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
			bottomLeft = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="10" height="10" id="bottomleft" align="middle"><param name="movie" value="images/bottomleft.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="images/bottomleft.swf" quality="high" wmode="transparent" width="10" height="10" name="bottomleft" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		}else{
			topLeft = '<img  src="images/topleft.png" width="10" height="10" alt="">';
			topRight = '<img  src="images/topright.png" width="10" height="10" alt="">';
			bottomRight = '<img  src="images/bottomright.png" width="10" height="10" alt="">';
			bottomLeft = '<img  src="images/bottomleft.png" width="10" height="10" alt="">';
		}
		
		htmlStr +='<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td class="td_10" valign="top"><span class="connerImg1" style="width:10px;height:10px;">'+topLeft+'</span></td><td class="translucentborder_top"><img src="images/spacer.gif" width="100" height="10" alt=""></td><td><span class="connerImg2" style="width:10px;height:10px;">'+topRight+'</span></td></tr><tr><td class="translucentborder"><img src="images/spacer.gif" width="10" height="10" alt=""></td><td class="table_content"><div class="transcontainer"><div class="translucentbkg"><div class="opaquetext"><div class="newsheader"><div class="newsheader_title" style="height:auto"><span class="newsheader_titletext">';
		htmlStr +='<a href="'+url+'" target="_blank">'+title+'</a></span><br/><span style="font-weight: bold">'+pubDate+'</span></div><div class="newsheader_icon"><a href="javascript:void(0)"><img id="'+id+'" src="'+icon+'" alt="Expend The News" width="23" height="23" vspace="7"></a></div></div><div id="newsDiv'+i+'" class="'+className+'" style="padding-top:2px"><img src="images/spacer.gif" alt="" width="50" height="10">'+ description +'</div></div></div></div></td><td class="translucentborder"><img src="images/spacer.gif" width="10" height="10" alt=""></td></tr><tr><td><span class="connerImg3" style="width:10px;height:10px;">'+bottomLeft+'</span></td><td class="translucentborder_top"><img src="images/spacer.gif" width="100" height="10" alt=""></td><td><span class="connerImg4" style="width:10px;height:10px;">'+bottomRight+'</span></td></tr></table><img src="images/spacer.gif" alt="" width="300" height="10">';			
	}
		//init content
		$("#newsSection").html(htmlStr);
		
		//init button
		$("#newsSection").find(".newsheader_icon").find("a").click(function(){
			var img = $(this).find("img")
			var imgID = img.attr("id");
			
			var id = $(this).parents().parents().next().attr("id");
			var content = ($("#"+id));
			if(imgID == "decrease"){
				content.removeClass("normal");
				content.addClass("newscontent");
				img.attr("id","plus")
				img.attr("src","images/btn_news_plus.gif")
			}else{
				content.removeClass("newscontent");
				content.addClass("normal");
				img.attr("id","decrease")
				img.attr("src","images/btn_news_decrease.gif")
			}
		 });
		//IE 6
		$("#footer").css("bottom","0px");
}

$(document).ready(function(){
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	if(!isIE){
		$("#newsBox").css("left","-5px");	
	}
	getNewsIndex();
	getNewsArticles();	
});