$(document).ready(function() {


	$('.widget-syndicate img').dropShadow({left: 6, top: 6, blur: 2});	
	
	$('.widget-cloud li a').dropShadow({left: 3, top: 3, blur: 2});	
	//$('iframe').dropShadow({left: 6, top: 6, blur: 2});
	//$('#adverts').dropShadow({left: 6, top: 6, blur: 2});

	if (jQuery.browser.msie) {

		if (jQuery.browser.version > "6.0") {

			$('#header-name img').dropShadow({left: 6, top: 6, blur: 2});

		}
  		
	}
	else {

			$('#header-name img').dropShadow({left: 6, top: 6, blur: 2});
	}



	$('.openSports').click(
		function() {
	
			url = $(this).text();

			$('#sports').animate(
				{height:"290px"}, 2000, function() { 
					$('#newsbox').height(250);
			});

			if (url.indexOf("Top") > -1) {

				url = "top";

			}

			makeTheCall("http://2whoa.com/dominate/xml/"+url.toLowerCase()+".xml");
	});

});

function makeTheCall(url) {

	myArray = new Array();
	myArray1 = new Array();
	myArray2 = new Array();


	$.ajax({	

		//type: "GET",
		url: url,
		cache: 'false',
		dataType: "xml",

		error: function() { alert("CAn not read."); },

		success: function(xml) { 


			var text = xml;


			$(text).find('item').each(function(i) {

				myArray[i] = $(this).find('title').text();

				myArray1[i] = $(this).find('link').text();
						
				myArray2[i] = $(this).find('description').text();
	
				});

			var run = 0;
						
			runIt();

			function runIt() {

				$('.text').stop();

				ast = myArray1[run].indexOf('*');
				link = myArray1[run].substring(ast+1,myArray1[run].length);

				link = link.replace('?','&amp;');
				
				$('#newsbox').html('<div class="text"><h2 class="headline"></h2><div class="abstract"><p>'+myArray2[run]+'</p></div></div><a href="#" class="closeSports">Close</a>');

				bind();

				$('.headline').html('<a href="readTest.php?page='+link+'keepThis=true&amp;TB_iframe=true&amp;height=500&amp;width=500" class="thinkbox">'+myArray[run]+'</a>');

				$('.headline a').attr("class","thickbox");


				img = $('.abstract img');

				$('.abstract a').replaceWith(img);

				$('.abstract p:last').append(' <a href="readTest.php?page='+link+'keepThis=true&amp;TB_iframe=true&amp;height=500&amp;width=500" class="thinkbox">Read More...</a>');

				$('.text a').attr("class","thickbox");

				getSet();

				run = run+1;
												
				$('.text').fadeOut(15000, function() {

						$('.box').html();
						setTimeout(runIt,'200');
					});


				if (run == myArray.length) {
	
					run = 0;
				}			
			}

		}

	});

}

function bind() {

    $('.closeSports').bind("click", function(e){
     
		$('#sports').animate(
			{height:"0px"}, 2000, function() { 
				$('#sports').css("display","none");
				$('.text').stop();
		});
    });


}