// MAIN Javascript
function bindplaytrailer(){
$("#playtrailer_text").click(function(){
		$("#content").html('<div id="homepage_closebutton"></div><div id="homepage_video_wrapper"><div id="homepage_video"><video id="mainhtml5vid" width="675" height="335" controls poster="./images/portvid_thmb1.jpg"><source src="http://www.jemglo.org/video/main_jemglo.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2"" /><source src="http://www.jemglo.org/video/main_jemglo.webm" type="video/webm; codecs="vp8, vorbis"" /><source src="http://www.jemglo.org/video/main_jemglo.ogg" type="video/ogg; codecs="theora, vorbis"" /><object width="598" height="472" type="application/x-shockwave-flash" data="./scripts//player.swf"><param name="movie" value="./scripts/player.swf" /><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="flashvars" value="file=http://www.jemglo.org/video/main_jemglo.flv&skin=./js/skins/nacht.xml"><img src="./images/portvid_thmb1.jpg" width="600" height="442" alt="__TITLE__"title="No video playback capabilities, please download the video below" /></object></video></div></div>');
		var flashplayer = './js/player.swf';
		var homeflashvars = {
			'file':'http://www.jemglo.org/video/main_jemglo.flv',
			'skin':'./js/skins/nacht.xml',
			'image':'./images/portvid_thmb1.jpg',
			'autostart':'true',
			'controlbar.position':'over',
			'controlbar.idlehide':'true',
			'stretching':'fill'
		};
		var homeparams = {
			'allowfullscreen':'true',
			'allowscriptaccess':'always',
			'bgcolor':'#000',
			'WMODE':'opaque'
		};
		var homeattributes = {
			'id':'homepage_video',
			'name':'homepage_video'
		};
		swfobject.embedSWF(flashplayer, 'homepage_video', '675', '335', '9', 'false', homeflashvars, homeparams, homeattributes);
		$("#content").hide().css({background: '#FFFFFF'});
		$("#content").css({ backgroundColor: '#282828' }).fadeTo(500, 1, function(){
		
			$("#homepage_video").css({ margin: '0 auto' });
			$("#homepage_video").show();
			$("#homepage_closebutton").click(function(){
				$("#content").css("background-image", "url(./images/contentback.jpg)"); 
				$("#content").html('<div id="main_content_left"><div id="mainleft_text"><p>JEMGLO is an award-winning nonprofit <br />documentary and multimedia production <br />company focused on subjects broadly <br />related to Jewish culture around the world.</p></div></div><div id="main_content_right"><div id="mainright_text"><p>We have produced seven documentaries that have been aired on public broadcasting stations across the US and at sites ranging from the United Nations to global festivals to government embassies. An eighth documentary is currently in the film festival circuit and has already been an Official Selection at over 20 prestigious festivals, garnering coveted awards <br />at three. JEMGLO has also produced short videos for Internet and <br />other venue viewing.</p><div id="playtrailer_text">PLAY TRAILER</div></div></div><div class="clearfloat"></div>');
			bindplaytrailer();
			});
		
		
		});
		
	});
}

function RMroundedcornersbutton(){
	$(".borderradius body").prepend('<a class="rmrounded">Rounded Corners ON (click to test)</a>')
	var $removeRCbtn = $('.rmrounded');
	$removeRCbtn.css({'cursor': 'pointer', 'font-size': '10px', 'position': 'fixed', 'top': '5px', 'left': '5px', 'color': 'red'});
	$removeRCbtn.toggle(function() {
		$("#page_inner_container").css({'border-radius': '0','-webkit-border-radius': '0','-moz-border-radius': '0'});
		$("#footer").css({'border-radius': '0','-webkit-border-radius': '0','-moz-border-radius': '0'});
		$removeRCbtn.html('Rounded Corners OFF (click to test)');
		$removeRCbtn.css({'color': 'blue'});
	}, function() {
		$("#page_inner_container").css({'border-radius': '15px','-webkit-border-radius': '15px','-moz-border-radius': '15px'});
		$("#footer").css({'border-bottom-left-radius': '15px','-webkit-border-bottom-left-radius': '15px','-moz-border-radius-bottomleft': '15px'});
		$("#footer").css({'border-bottom-right-radius': '15px','-webkit-border-bottom-right-radius': '15px','-moz-border-radius-bottomright': '15px'});
		$removeRCbtn.html('Rounded Corners ON (click to test)');
		$removeRCbtn.css({'color': 'red'});
	});
}


function addJavascript(jsname,pos) {
	var th = document.getElementsByTagName(pos)[0];
	var s = document.createElement('script');
	s.setAttribute('type','text/javascript');
	s.setAttribute('src',jsname);
	th.appendChild(s);
}

$(document).ready(function () {
	bindplaytrailer();
	
	//RMroundedcornersbutton(); //ADD remove corner button for testing 
	//addJavascript('http://livejs.com/live.js#css','body');
	//$.getScript("http://livejs.com/live.js#css");
});
