// Temporarily added to prevent console.log errors in IE
if (typeof console == 'undefined') { window.console = function(){}; console.log = function(a){}; }
// site specific javascript
if(!$.browser.safari)
{
	$(document).ready(function(){
		behavior_binder();
	});
}
else
{
	$(window).load(function(){
		behavior_binder();
	});
}
/*
Binds behaviors
** can be re-run whenever there are DOM changes
*/
function behavior_binder(){

	if($.browser.safari)
	{
		var ignoreMe = document.body.offsetWidth;
	}
	if(window.create_dl!==undefined && typeof(window.create_dl)==='function'){
		create_dl();
	}
	if(window.initialize_header!==undefined && typeof(window.initialize_header)==='function'){
		initialize_header();
	}

	
/* ADD FIRST/LAST TO LI
		adds a class 'first' to the first LI, and a 'last' to the last LI and 'first last' to a single LI
	*/
	$('ul').each(function(i){
		$(this).children('li:not(.hidden):first').addClass('first');
		$(this).children('li:not(.hidden):last').addClass('last');
	});
	
// END ADD FIRST/LAST TO LI
	
/* SITE BUTTON */
	$(".site_btn").wrapInner('<span class="site_btn_mid"></span>');
	$(".site_btn").prepend('<span class="site_btn_left"></span>');
	$(".site_btn").append('<span class="site_btn_right"></span>');
	$(".site_btn_alt").wrapInner('<span class="site_btn_alt_mid"></span>');
	$(".site_btn_alt").prepend('<span class="site_btn_alt_left"></span>');
	$(".site_btn_alt").append('<span class="site_btn_alt_right"></span>');
/* MEDIA THUMBNAIL ICONS */
	// To add media icons to the thumbnails in a module, 
	// add the module id to the thumb_icons array
	var thumb_icons = ["#more",
			"#lo_mejor_de_la_semana", 
			"#mod_video_highlights",
			"#mod_browse_photos",
			"#mod_featured_photos"];
	for ( var x=0;x<thumb_icons.length;x++){
		$(thumb_icons[x]+" .media_article").append('<span class="media_article_icon"></span>');
		$(thumb_icons[x]+" .media_photo").append('<span class="media_photo_icon"></span>');
		$(thumb_icons[x]+" .media_video").append('<span class="media_video_icon"></span>');
	}
	
/* DROP TABS */
	$(".drop_tab li a").wrapInner('<span class="drop_tab_mid"></span>');
	$(".drop_tab li a").prepend('<span class="drop_tab_left"></span>');
	$(".drop_tab li a").append('<span class="drop_tab_right"></span>');
	//converts all module_head h3's to DIN font
	$('.module_head h3').drawFont();
	$('.module_head_links h3 a').drawFont();
	$('#tv_listings .listings_title').drawFont();
	$('#commenting').snasCommenting({action_function:function(){MGRad.refreshAds();}});
	$('ul.rating_stars').snasRate();
	$('#survey_of_the_day .module_content').snasPoll({action_function:function(){MGRad.refreshAds();}});
	$('#encuesta_del_dia .module_content').snasPoll({action_function:function(){MGRad.refreshAds();}});
	$('#login_user, #login_password').one("focus", function(e){
											$(this).attr('value', '');
											});


/* SEND TO A FRIEND */
	$('.share_btn, .send_to_friend').click(function(){ sn_show_sendToFriend(); return false; });

}

