	// global variables
	var json_object
	

	
	//debug config
	function getHost() {
                        var url = window.location.href;
                        var nohttp = url.split('//')[1];
                        var hostPort = nohttp.split('/')[0]
                        return hostPort;
            }		
	var host_path = 'php/'
	
	
	/* handles upimage rollover event */ 
	up_rollimage = new Array()
	   
	up_rollimage[0] = new Image(40,32) 
	up_rollimage[0].src = "../images/fpfeed/up_static.jpg" 

	up_rollimage[1] = new Image(40,32)
	up_rollimage[1].src = "../images/fpfeed/up_hover.jpg"
	
	function UpSwapOut(){		
		if(document.UpArrowImg.src ==  up_rollimage[0].src){
			document.UpArrowImg.src = up_rollimage[1].src;
		}
	    return true;
    }

	function UpSwapBack(){	
		if(document.UpArrowImg.src ==  up_rollimage[1].src){
			document.UpArrowImg.src = up_rollimage[0].src; 
		}
	    return true;
	}
	
	/* handles downimage rollover event */ 
	down_rollimage = new Array()
	   
	down_rollimage[0] = new Image(40,32) 
	down_rollimage[0].src = "../images/fpfeed/down_static.jpg" 

	down_rollimage[1] = new Image(40,32)
	down_rollimage[1].src = "../images/fpfeed/down_hover.jpg"
	
	function DownSwapOut(){
		if(document.DownArrowImg.src == down_rollimage[0].src){
			document.DownArrowImg.src = down_rollimage[1].src;
		}
	    return true;
    }

	function DownSwapBack(){
		if(document.DownArrowImg.src == down_rollimage[1].src){
			document.DownArrowImg.src = down_rollimage[0].src; 
		}
	    return true;
	}

	function ContentTitle(json,index){		
		html = '<a href="'+json[index].url+'" TARGET="_blank" >' + json[index].title + '</a>';
		return html;
	}
	
	function ContentDate(json,index){		
		html = json[index].pubdate;
		return html;
	}
	
	function ContentDescription(json,index){		
		html = json[index].description;
		return html;
	}
	
	function ContentSource(json,index){		
		html = json[index].source;
		return html;
	}
	
	function ContentImage(json,index){			
		if(json[index].image != ""){
			html = '<img src="'+json[index].image+'">' ;
		}else{
			html = '<img src="../images/fpfeed/noimage.jpg">' ;
		
		}
		return html;
	}
	
	
	
	function GetFeedItem(index){
	
			$("#ContentTitle").before('<div class="frontheaderlink-blue" id="ContentTitle">' +ContentTitle(json_object,index)+'</div>').remove();
			$("#ContentDate").before('<div class="text-sidebarheading-grey" id="ContentDate">' +ContentDate(json_object,index)+'</div>').remove();
			$("#ContentDescription").before('<div class="text-frontfirstbox"div id="ContentDescription">' +ContentDescription(json_object,index)+'</div>').remove();
			$("#ContentSource").before('<div class="text-sidebarheading-blue" id="ContentSource">' +ContentSource(json_object,index)+'</div>').remove();		
		
			$("#ContentImage").before('<div id="ContentImage" >' +ContentImage(json_object,index)+'</div>').remove();	
	
		if( index == 0){	// first item selected 					
			UpArrowSrc = "../images/fpfeed/up_g.jpg" ;
			DownArrowSrc = "../images/fpfeed/down_static.jpg" ;							
			
			PrevIndex = 0
			NextIndex = 1
			
		}else if(index == (json_object.length - 1) ) { // last item in list
			UpArrowSrc = "../images/fpfeed/up_static.jpg" ;
			DownArrowSrc = "../images/fpfeed/down_g.jpg" ;
			
			PrevIndex = Number(index)-1
			NextIndex = index
		
		}else{
			UpArrowSrc = "../images/fpfeed/up_static.jpg" ;
			DownArrowSrc = "../images/fpfeed/down_static.jpg" ;
			
			PrevIndex = Number(index)-1			
			NextIndex = Number(index)+1			
		}
			
		$("#UpImage").before('<div id="UpImage" ><img name="UpArrowImg"  onMouseOver="UpSwapOut()" onMouseOut="UpSwapBack()" onClick="GetFeedItem(\''+PrevIndex+'\')" border="0" src="'+UpArrowSrc+'"></div>').remove();
		
		$("#DownImage").before('<div id="DownImage" ><img name="DownArrowImg"  onMouseOver="DownSwapOut()" onMouseOut="DownSwapBack()" onClick="GetFeedItem(\''+NextIndex+'\')" border="0" src="'+DownArrowSrc+'"></div>').remove();
	}
	
/* acquires mixx data from server */
$(document).ready(function(){ 

host = getHost();
	// loads initial page
	$.getJSON(			
		"http://" + host +"/" + host_path + "rss.php",

		function(data){
			json_object = data 									
			$("#ContentTitle").append(ContentTitle(json_object,0))						
			$("#ContentDate").append(ContentDate(json_object,0))						
			$("#ContentDescription").append(ContentDescription(json_object,0))						
			$("#ContentSource").append(ContentSource(json_object,0))						
			$("#ContentImage").append(ContentImage(json_object,0));
					
			$("#UpImage").append('<img name="UpArrowImg"  onMouseOver="UpSwapOut()" onMouseOut="UpSwapBack()" onClick="GetFeedItem(\'0\')" border="0" src="../images/fpfeed/up_g.jpg">');
		
			$("#DownImage").append('<img name="DownArrowImg"  onMouseOver="DownSwapOut()" onMouseOut="DownSwapBack()" onClick="GetFeedItem(\'1\')" border="0" src="../images/fpfeed/down_static.jpg">');
		
		
		
		
		}
	);		

	
	
});