/*----------------------------------------------------------------*/
/*	© 2009 Hal Lindsey Media Ministries
/*	JavaScript functions for The Hal Lindsey Report: homepage
/*----------------------------------------------------------------*/

function swfirImages(){
	// Featured Headline Image
	var swfimg = new swfir();
	swfimg.specify('src', '/scripts/swfir.swf');
	swfimg.specify('border-color', 'FFFFFF');
	swfimg.specify('border-width', '3');
	swfimg.specify('border-radius', '10');
	swfimg.specify('shadow-color', '707070');
	swfimg.specify('shadow-blur-x', '2');
	swfimg.specify('shadow-blur-y', '2');
	swfimg.specify('shadow-strength', '10');
	swfimg.specify('shadow-offset', '0');
	swfimg.swap('#headline_image img');
	
	// Other Headlines Images
	var browser = getBrowser();
	if(browser['name'] != "ie"){
		var swfimg2 = new swfir();
		swfimg2.specify('src', '/scripts/swfir.swf');
		swfimg2.specify('border-color', '707070');
		swfimg2.specify('border-width', '1');
		swfimg2.specify('border-radius', '6');
		swfimg2.swap('.recent_headline .thumbnail img');
	}
}

var current_video = 0;

function playVideo(i, id, title, autoPlay){
	current_video = i;
	updateViewCount(id);
	$('.featured_video').attr('class','featured_video');
	$('#featured_video_'+i).attr('class','featured_video current');
	$('#current_video #video_title span').fadeOut('medium', function(){
		if(title.length > 28) title = title.substring(0,25) + "...";
		$('#current_video #video_title span').html(title);
		$('#current_video #video_title span').fadeIn();
		var soVideo = new SWFObject("/swf/HL_video_player_small.swf", "HL_video_player_small", "452", "298", "8", "", true);
		soVideo.addParam("base", "/");
		soVideo.addParam("menu", "false");
		soVideo.addParam("wmode", "transparent");
		soVideo.addParam("allowFullScreen", "true");
		soVideo.addVariable("vidfile", ""+id);
		if(autoPlay) soVideo.addVariable("do_autoPlay","yes");
		soVideo.write("flash_video");
	});
}

function nextVideo(){
	var next_video = (current_video < 2) ? current_video + 1 : 0;
	var id = $('#video_id_'+next_video).val();
	var title = $('#video_title_'+next_video).val();
	playVideo(next_video, id, title, true);
}

function updateViewCount(videoID){
	$.ajax({
		type : "POST",
		url : "/includes/ajax/ajax_views.php",
		data : "type=video&id="+videoID,
		cache : false
	});
}

function viewNews(ctg){
	var current = $('#news_tabs a.current').attr('id').replace('tab_','');
	$('#news_tabs a').attr('class','');
	$('#tab_'+ctg).attr('class','current');
	/*$('#'+current).fadeOut('medium', function(){
		$('#'+ctg).fadeIn();
	});*/
	$('#'+current).hide();
	$('#'+ctg).show()
	
}