

$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "xml/data.xml",
        dataType: "xml",
        success: xmlParser
    });
	
	$.ajax({
        type: "GET",
        //url: "/xml/data.xml",
        url: "xml/ticker.xml",
        dataType: "xml",
        success: xmlParserTicker
    });
});



function xmlParser(xml) {
    $(xml).find("slider").each(function () {
	var l  = $(this).find("link").text();
	var t = $(this).find("link").attr("target");
	var img = $(this).find("img").text();
	
	if(l) {
		if(t) {
			$("#slider").append('<a href="' + l + '" target="'+t+'"><img src="' + img + '" alt="" width="740" height="329" /></a>');
		}else{
			$("#slider").append('<a href="' + l + '"><img src="' + img + '" alt="" width="740" height="329" /></a>');
		}
		
	}else{
		$("#slider").append('<span><img src="' + img + '" alt="" width="740" height="329" /></span>');
	}
    });
	slider();
};

function xmlParserTicker(xml) {
	//alert($(xml).find("item").find("title").text());
    $(xml).find("item").each(function () {
		var t = $(this).find("link").attr("target");
		if( $(this).find("link").text() == ""){
			$("ul#news03").append('<li>' + $(this).find("title").text() + '</li>');
		}else{
			
			if(t){
			$("ul#news03").append('<li><a href="' + $(this).find("link").text() + '" target="'+t+'">' + $(this).find("title").text() + '</a></li>');
			}else{
			$("ul#news03").append('<li><a href="' + $(this).find("link").text() + '">' + $(this).find("title").text() + '</a></li>');
			}
			
		}
    });
	
	ticker();
};



/* slider */

function slider(){

	

	$('#slider').nivoSlider({

	effect:'fade',

	prevText: '',

	nextText: '',

	animSpeed: 400,

	pauseTime: 5000,
	
	controlNav:true,
	
	controlNavThumbsSearch: '.jpg',
	
    controlNavThumbsReplace: '_t.jpg'

	});

}


/* ticker */
function ticker(){
	$(function(){
		$('ul#news03').bxSlider({
		controls: false,
		speed: 500,
		pager: false,
		auto: true,
		pause: 5000
		});
	});
}
