//convert all user agent names to lower case so that we don't have to worry about how they're served up by the browser
var agent = navigator.userAgent.toLowerCase();
isUAMobile =!!(agent.match(/(iPhone|iPod|blackberry|android 0.5|htc|lg|midp|mmp|mobile|nokia|opera mini|palm|pocket|psp|sgh|smartphone|symbian|treo mini|Playstation Portable|SonyEricsson|Samsung|MobileExplorer|PalmSource|Benq|Windows Phone|Windows Mobile|IEMobile|Windows CE|Nintendo Wii)/i));
if (isUAMobile == true){ 
	//if the user is using a small device/screen resolution, show these css:
	loadext("/css/global.mobile.css","css", "screen, projection, handheld");
} else {
	//if the user is using a device/screen resolution over 600 pixels, show these css:
	loadext("/css/tabs2.css","css", "projection, screen");
	loadext("/css/global.css","css", "projection, screen");
	loadext("/css/index.css","css", "projection, screen");
	loadext("/css/tabs-numbered.css","css", "projection, screen");
	loadext("/css/thickbox.css","css", "print, projection, screen");
	loadext("/css/utility.css","css", "print, projection, screen");
	loadext("/css/jquery.fancybox-1.3.1.css","css", "print, projection, screen");
}
				
$(document).ready(function(){
	//if the user is using a handheld device or game console		
	if (isUAMobile == true){ 
		// then show only the breaking news list
		$.getScript('/js/xml.mobile.news.js', function(){
			createBreakingList();
		});
		/*var mt = $('meta[name=viewport]');
		mt = mt.length ? mt : $('<meta name="viewport" />').appendTo('head');
		mt.attr('content', 'width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;');*/
		$('#content-1').after($('#nav-main2'));
	} else {
		//if the user is using a non-handheld device, attach these js:
		//Featured content:
		$.getScript('/js/ui.tabs.js', function(){
			var myTabs = $('#featured-content').tabs();
			myTabs.tabs().tabs('rotate' , 9500, false );
			myTabs.tabs('option', 'fx', { opacity: 'toggle' });								   
		});
		//Menu:
		$.getScript('/js/menu.js');
		//translation:
		$.getScript('/js/jquery.translate-1.3.9.min.js');
			$.getScript('/js/cookie.js', function(){
				//all scripts nested in this cookie script are 
				//DEPENDENT upon the cookie script and 
				//cannot be moved outside of this function
				/* Survey - this is for the OCS surveys - uncomment and change the variable anter the "/s/"
					to the new survey variable
					$.getScript('/js/jquery.surveymonkey.js', function(){ 
					createSurvey("http://www.surveymonkey.com/s/3RHNH7M", 400, 280);								   
				});*/
				//These are for the content and image zooms 
					$.getScript('/js/jquery.bigframe.min.js');
					$.getScript('/js/jquery.fancybox-1.3.1.pack.js');	
					$.getScript('/js/thickbox.js', function(){
						//translate is dependent upon cookie AND thickbox
						$.getScript('/js/translate.v4.js');	
					});					   
		});
		//by default this is invisible for mobile devices
		$("#featured-content div").css({"visibility":"visible"});
		//load the menu
		$.getScript('/js/xml.menu.js', function(){
			createNav();								
		});
		//load new in corrections
		$.getScript('/js/xml.nic.js', function(){
			createNICList();							   
		});
		//load breaking news
		$.getScript('/js/xml.news.js', function(){
			createBreakingList();								
		});
		//load videos
		$.getScript('/js/xml.videos.js', function(){
			createVideoList();										  
		});
		//load utilities
		$.getScript('/js/utility.js', function(){ 
			resizeText();								   
		});	
	}
	//attach any js that has to be used globally (for big or small screens) here:
});  
