/***********************************************************
My TuVi 1.2
© 2010, Ayoub Media (www.ayoubmedia.com). All rights reserved.
************************************************************/

var swfVars = 'mytuviPath='+mytuviPath+'&mytuviPreview='+mytuviPreview+'&youtubeSrearchTerm='+youtubeSrearchTerm+'&mytuviTitle='+mytuviTitle+'&youtubeUserID='+youtubeUserID+'&mytuviAutoPlay='+mytuviAutoPlay+'&youtubeStartupVideoID='+youtubeStartupVideoID+'&youtubeStartupVideoTitle='+youtubeStartupVideoTitle+'&youtubeVideosSortBy='+youtubeVideosSortBy+'&mytuviVideosListAtStart='+mytuviVideosListAtStart+'&updateMyTuViVL='+updateYouTubeVideoListEvery+'&mytuviMyWebsiteTitle='+mytuviMyWebsiteTitle+'&mytuviMyWebsiteURL='+mytuviMyWebsiteURL+'&mytuviPlayFrom='+mytuviPlayFrom+'&mytuviBackgroundColor='+mytuviBackgroundColor+'&mytuviTitleColor='+mytuviTitleColor+'&mytuviUseSkin='+mytuviUseSkin;
var my_tuviPlayer = '<object width="250" height="320" id="mytuviSwf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">'
+'<param name="movie" value="'+mytuviPath+'/mytuviFree.swf"></param>'
+'<param name="allowFullScreen" value="false"></param>'
+'<param name="allowScriptAccess" value="always" />'
+'<param name="wmode" value="transparent" />'
+'<param name="flashVars" value="'+swfVars+'" />'
+'<embed src="'+mytuviPath+'/mytuviFree.swf"'
+'type="application/x-shockwave-flash" name="mytuviSwf" allowscriptaccess="always" allowfullscreen="false" width="250" height="320" wmode="transparent" flashVars="'+swfVars+'">'
+'</embed></object>';
if (hasRequestedVersion==false)
	{
		var flashError = '<div>myTuVi youTube mini player requires flash player version 10 or higher<br>'+
						 '<a href="http://www.adobe.com/go/getflash/" target="_top">Please click here to get Flash Player</a></div>';
		document.write(flashError);
	}
else
	{
		document.write(my_tuviPlayer);	
	}

/*checking browser type*/
function getMytuviObj(movieName) {
	 if (navigator.appName.indexOf("Microsoft") != -1) {
		 return window[movieName];
	 } else {
		 return document[movieName];
	 }
}

/*sending messages to mytuvi player*/
function sendMessageToMytuvi(msg) {
	 var swf = getMytuviObj("mytuviSwf");
	 if(typeof swf.sendSwfMessage == 'function')
	 swf.sendSwfMessage(msg);
}

/*opening youtube video in popup window*/
function mytuviGetYouTubeVideo(vdContent,vdTtl)
{
if (mytuviPreview=="no"){
var mytuviVideoObj = '<div style="border:1px solid #333;background-color:#555;"><div style="padding:2px 0 2px 10px; ">'
+'<div style="float:right;width:40px"><img src="'+mytuviPath+'/images/colose_page.gif" style="cursor:pointer" onclick="mytuvi_remove()" /></div>'
+'<div style="float:left;width:60px"><a href="http://www.mytuvi.com" target="_blank"><img src="'+mytuviPath+'/images/mytuvi.png" border="0"></a></div><div id="pageCoverTitle" style="font-family:arial;font-size:12px;font-weight:bold;vertical-align:middle;color:#FFFFFF;text-align:left">'+vdTtl+'</div>'
+'</div>'
+'<div style="border:1px solid #555;background-color:#000;padding:2px">'+vdContent+'</div></div>';

if(document.getElementById("mytuviContent") === null){
	$("body").append("<div id='mytuviContent' style='display:none'></div>");
}
document.getElementById('mytuviContent').innerHTML = "";
document.getElementById('mytuviContent').innerHTML = mytuviVideoObj;
mytuvi_show('',"#mytuvi_inline?height=400&width=608&inlineId=mytuviContent&modal=true",'');
	}
else
	{
		alert('You are in preview mode');
	}	
}

function removeMytuviPopup(){
	document.getElementById('mytuviContent').innerHTML = "";
	mytuvi_remove();	
}
function mytuviLoaded(){
window.onunload = function() {
	if ($(this).html()==null)
	window.onunload = sendMessageToMytuvi('close##');
	};
}
