function popup(page) {
	window.open(page, 'popup', 'height=400,width=400,scrollbars,resizable');
}

function toggleInfo(a) {
	var selector = '#' + a;
	$(selector).slideToggle();
	return false;
}

// navigation
var majors = new Array('rankings');
function toggle(a, b) {
	if (!document.getElementById) return true;
	if (b==1) for (var i=majors.length-1; i>=0; i--) if (majors[i] != a) document.getElementById(majors[i]).style.display='none';
	a=document.getElementById(a);
	a.style.display=(a.style.display=='block')?'none':'block';
	return false;
}

function playVideo(div_id, file, image, duration, width, height, video_link, caption) {
	if (width == "") {
		width = "320";
	}
	if (height == "") {
		height = "260";
	}
	
	flashvars = "file=" + file;
	if (image != "") {
		flashvars = flashvars + "&image=/images/" + image;
	}
	if (duration != "") {
		flashvars = flashvars + "&duration=" + duration;
	}
	if (video_link != "") {
		flashvars = flashvars + "&link=" + video_link;
	}
	flashvars = flashvars + "&autostart=true&fullscreen=true&stretching=fill&backcolor=004000&frontcolor=ffffff&lightcolor=ffffff&plugins=googlytics-1";
	
	var so = new SWFObject('/mediaplayer/player.swf','mpl',width,height,'8');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','true');
	so.addParam('wmode','transparent');
	so.addVariable('flashvars', flashvars);
	so.write(div_id);	

	$('#video_caption').html(caption);
}

function openYTVideo(yt_id, tb_width, tb_height) {
	var tb_url = '/video_player.php?yt_id=' + yt_id + '&yt_w=' + tb_width + '&yt_h=' + tb_height + '&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=' + tb_height + '&width=' + tb_width;
	tb_show("",tb_url,"");
}

function showVideo(show_id, hide_id) {
	var hide_selector = '#' + hide_id;
	$(hide_selector).hide();
	
	var show_selector = '#' + show_id;
	$(show_selector).fadeIn('slow');
}

function toggleSkillVideo(vid_state) {
	var video_html = '<h1>Skill Technique Videos</h1>';
	video_html = video_html + '<div id="skill_video" style="margin-bottom:10px; text-align:center;">';
	video_html = video_html + '<object width="560" height="240">';
	video_html = video_html + '<param name="movie" value="http://www.youtube.com/v/Q4F452Jodw8&hl=en_US&fs=1"></param>';
	video_html = video_html + '<param name="allowFullScreen" value="true"></param>';
	video_html = video_html + '<param name="allowscriptaccess" value="always"></param>';
	video_html = video_html + '<embed src="http://www.youtube.com/v/Q4F452Jodw8&hl=en_US&fs=1" type="application/x-shockwave-flash" width="560" height="349" allowscriptaccess="always" allowfullscreen="true"></embed>';
	video_html = video_html + '</object>';
	video_html = video_html + '</div>';	
	video_html = video_html + '<div style="margin-left:13px;"><a href="javascript:toggleSkillVideo(\'hide\');">Close video</a> | <a href="javascript:self.parent.tb_remove();">Close window</a></div>';	
	
	if (vid_state == "show") {
		var hidden_html = $('#info').html();
		$('#info_hidden').html(hidden_html);
		$('#info').html(video_html);	
	} else {
		var show_html = $('#info_hidden').html();
		$('#info').html(show_html);	
	}
}

function getYTEmbedCode(width, height, yt_id, caption, div_id, caption_style) {
	var video_html = '<object width="' + width + '" height="' + height + '"><param name="movie" value="http://www.youtube.com/v/' + yt_id + '&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="autoplay" value="1"></param><param name="wmode" value="transaparent"></param><embed src="http://www.youtube.com/v/' + yt_id + '&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" autoplay="1" wmode="transparent" width="' + width + '" height="' + height + '"></embed></object>';
	if (caption != null) {
		if (caption_style == null) {
			caption_style = "font-size:12px; padding:10px 6px 6px 2px; background-color:#fff;";
		}
		video_html = video_html + '<div id="video_caption" style="' + caption_style + '">' + caption + '</div>';
	}
	
	if (div_id != null) {
		var div_selector = '#' + div_id;
		$(div_selector).width(width).html(video_html);
	} else {
		return video_html;
	}
}
