(function($){
get_magcover = function() {

	$.ajax({
                 type: "GET",
                 url: "feature\/magazine.xml",
                 dataType: "xml",
                 cache: false,
                 success: function(xml) {

		//cover should link go in xml doc
		var coverimg =$(xml).find('coverimg:first').text();
		var covertxt =$(xml).find('covertxt:first').text();
		var cover80= covertxt.substring(0,200);
		
 		cover80 = "<p style='font-size:14px;font-weight:bold;color:#f00'>CLICK COVER FOR THIS WEEK'S ISSUE<\/p>" + cover80 + " ... <a href=\"#mag_popup\" rel=\"magazine\">click for more<\/a>";	
 	
covertxt = covertxt +
'<a class="newslink" href="http://www.boyz.co.uk/onlineViewer/viewer.php" target="_blank">&nbsp;Check the issue out right now here online. <\/a>';


		$('.greybg1 .greybgtext').html(cover80);
		$('#mag_popup').html(covertxt);
		
		
$("a[rel=magazine]").livequery(function(){	
		$(this).fancybox({
		 		//'titleShow'     : true,
		 		//'titlePosition'  : 'inside',
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic'
				//'titleFormat' : function(){ return '<span style="color:#555;font-size:14px;font-weight:bold">'+this.title+'<\/span>';}		
		});	
		});	

		}//end success  
	});		    

    }           
})(jQuery);


(function($){
get_otwhome = function() {
	$.ajax({
                 type: "GET",
                 url: "feature\/otw_home.xml",
                 dataType: ($.browser.msie) ? "text" : "xml",
                 cache: false,
                 success: function(data) {
                 
var xml;
if (typeof data == "string") {
   xml = new ActiveXObject("Microsoft.XMLDOM");
   xml.async = false;
   xml.loadXML(data);
} else {
   xml = data;
}              
                 
                 
			var counter=1;
				
			var otwid;
			var otwvenue;
			var otwimg;
			var otwhead;
			var otwbody;
			var otwsection;
			var otwtype;
			
			var otw_id;
			var otwtext;
			var otwdate;
/*
var currentTime = new Date();
var month_url = currentTime.getMonth()+1;
var year_url = currentTime.getFullYear();
var date_url = month_url+"-"+ year_url;
*/
			
		$(xml).find('item').each(function(){			
			otwid = $(this).find('id').text();
			otwvenue = $(this).find('name').text();
			otwimg = $(this).find('img').text();
			otwhead = $(this).find('headtext').text();
			otwbody = $(this).find('bodytext').text();
			otwsection = $(this).find('section').text();
			otwtype = $(this).find('type').text();
			otwdate = $(this).find('date').text();
						
			otw_id = 'otw'+counter;
			counter=counter+1;
						
			$('#'+otw_id+' .photos a img').attr({
			src: './feature/otw_home/'+otwimg
			});
			
			$('#'+otw_id+' .photo-text a').attr({
			href: 'index.php?p='+otwsection+'&type='+otwtype+'&id='+otwid
			});


//split into array - see if date is < today's date
var dateparts = new Array(); 
dateparts = otwdate.split('/'); 		
var listdate = dateparts[2]+"/"+dateparts[1]+"/"+dateparts[0];
//is date less than today - format Ymd
if (Date.parse(listdate) < Date.parse(currentDate) ) {
otwdate = "";
}


if (otwdate !="") {
			otwdate	= otwdate.replace(/\//g,'-');
			$('#'+otw_id+' .photos a').attr({
			title: otwvenue,
			href: 'index.php?p='+otwsection+'&type='+otwtype+'&id='+otwid+'&date='+otwdate
			});	
			otwtext = '<div><a class="photoName" href="index.php?p='+otwsection+'&type='+otwtype+'&id='+otwid+'&date='+otwdate+'">'+otwhead+'<\/a><p>'+otwbody+'<\/p><\/div>';
} else {

			$('#'+otw_id+' .photos a').attr({
			title: otwvenue,
			href: 'index.php?p='+otwsection+'&type='+otwtype+'&id='+otwid
			});
			otwtext = '<div><a class="photoName" href="index.php?p='+otwsection+'&type='+otwtype+'&id='+otwid+'">'+otwhead+'<\/a><p>'+otwbody+'<\/p><\/div>';
}


			
			$('#'+otw_id+' .photo-text').html(otwtext);
	
	
		});
		
			
		}//end success
       	});   

    }           
})(jQuery);






