/*

1 default selection is Main Playlist


*/
var isPlaying = false;
var isPopOut = false;
var isAudioLink = false;
var isVideoLink = false;
var isYouTubeLink = false;
var usingQuicktimePlaylist = false;
var quicktimePlaylistUrl = false;

// usingIphone checks if the user is on an iphone
function usingIphone(){
	
	result = false;
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { 
		
			//alert("IPHONE DETECTED");
			result = true;
	}
	return result;
}

function	iphoneMusicList(elementIdName){
			
	var htmlData ='<img src="images/insightMedia.png" alt="" width="441" height="332" />';
	document.getElementById(elementIdName).innerHTML=htmlData;	
	
}

function iphoneSearchSongs(elementIdName){
			
	var htmlData ="";
	document.getElementById(elementIdName).innerHTML=htmlData;	
	
}

// Returns a youtube player
function returnYoutubePlayerHtml(widthOf, heightOf, url, autoplayTF){	
	// if width is not empty
	/*
	if (widthOf > 0 ){} else{
		widthOf = "310";
	}

	// if width is not empty
	if (heightOf > 0 ){} else{
		heightOf = "252";
	}
*/
		//heightOf = "344";
	//	widthOf = "425";
//

	//var htmlData ='<object width="'+ widthOf +'" height="'+ heightOf +'"><param name="movie" value="'+ url +autoplayTF+'"></param>``<embed src="'+ url +autoplayTF+'" type="application/x-shockwave-flash" width="'+ widthOf +'" height="'+ heightOf +'"></embed></object>';
	
	
	/*
		<object width="416" height="337"><param name="movie" value="http://www.youtube.com/cp/vjVQa1PpcFNq01nGq-9YknrxcU12vyjwt1OEuHEsol8="></param><embed src="http://www.youtube.com/cp/vjVQa1PpcFNq01nGq-9YknrxcU12vyjwt1OEuHEsol8=" type="application/x-shockwave-flash" width="416" height="337"></embed></object>
		*/
	
	var htmlData = '<object width="'+ widthOf +'" height="'+ heightOf +'"><param name="movie" value="'+ url +autoplayTF+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+ url +autoplayTF+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+ widthOf +'" height="'+ heightOf +'"></embed></object>'
	
	
	return htmlData;
}



// Initializes the video player based on iphone detection, youtube, or internal video link
function initializePlayer(widthOf, heightOf,variables, elementIdName){
	/*
	<object width="310" height="252"><param name="movie" value="http://www.youtube.com/cp/vjVQa1PpcFNq01nGq-9YknrxcU12vyjwt1OEuHEsol8=&autoplay=1"></param><embed src="http://www.youtube.com/cp/vjVQa1PpcFNq01nGq-9YknrxcU12vyjwt1OEuHEsol8=&autoplay=1" type="application/x-shockwave-flash" width="310" height="252"></embed></object>
	
	
	
	
	*/
	
	//alert(variales);
	
	 if (usingIphone() == true){
		
  		
		var htmlData = returnYoutubePlayerHtml("425", "344", 	"http://www.youtube.com/v/emKXXorNq6I&hl=en&fs=1&rel=", "0");
		//play(variables, shouldPopOut, elementIdName);
		document.getElementById(elementIdName).innerHTML=htmlData;	

	 }else{
		// alert("NOT IPHONE DETECTED");
	  returnInsightPlayerHtml(widthOf,heightOf, variables,elementIdName);
	 }
}



// should determine if entered url is youtube link, audio, or linked video
function play(variables, shouldPopOut, elementIdName){
	
		// Default is English
	var htmlData = '';
	
	// check what type of file the link is
	
	if (isYouTubeLink == true){


	}else if (isAudioLink == true){
		
	}else if (isVideoLink == true){
		
	}
	
	
	
	
	
	
	
	if (shouldPopOut == true){
		// create a popup with the player
		
	}else{
		// put the html in the inline element
		document.getElementById(elementIdName).innerHTML=htmlData;	
	}
}


// plays QuicktimePlaylist
function quicktimePlayist(playlistUrl, shouldPopOut, elementIdName){
	
}

// stops whatever medium is playing
function stopMedia(url, shouldPopOut, elementIdName){
	
}

// opens youtubePlayer
function openYouTube(url, shouldPopOut, elementIdName){
	
}

// opens Quicktime Video Player
function openQuicktimeVideo(url, shouldPopOut, elementIdName){
	
}

// opens Quicktime Audio Player
function openQuicktimeVideo(url, shouldPopOut, elementIdName){
	
}

// Returns new quicktime html data from entered information
function returnNewQuicktimeVideoHtml(widthOf, heightOf, source, autoplayTF, cacheTF, controllerTF, loopTF){	
	var htmlData ='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+ widthOf +'" '
      +'height="'+ heightOf +'" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
      +'<param name="src" value="'+source+'">'
      +'<param name="autoplay" value="'+autoplayTF+'">'
      +'<param name="cache" value="'+cacheTF+'">'
      +'<param name="controller" value="'+controllerTF+'">'
      +'<param name="loop" value="'+loopTF+'">'
      +'<embed src="'+source+'" width="'+widthOf+'" height="'+heightOf+'" autoplay="'+autoplayTF+'"'
      +'controller="true" loop="'+loopTF+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'
	  +'</object>';
	return htmlData;
}


// returns insight video
function returnInsightPlayerHtml(widthOf, heightOf, flashvariables, elementIdName){	

	<!-- START VIDEO   THIS IS THE AREA FOR THE VIDEO PLAYER   USE YOUTUBE OR THE CSTOM VIDEO PLAYER   -->
	//alert("Will create insight video");//widthOf, heightOf,
	AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width',				widthOf,'height',heightOf,'title','Insight Media Player','src','InsightXPlayer','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','InsightXPlayer' , 'flashvars',flashvariables); //end AC code

	var htmlData ='<noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0"'
	+ 'width="'+widthOf+'" height="'+heightOf+'" title="Insight Media Player">'
	+ '<param name="movie" value="InsightXPlayer.swf" />'
	+ '<param name="quality" value="high" />'
    + '<param name="FlashVars" value="'+flashvariables+'">'
    + '<embed src="InsightXPlayer.swf" quality="high"' 
	+ 'pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"'
	+ 'type="application/x-shockwave-flash" width="'+widthOf+'" height="'+heightOf+'"></embed>'
    + '</object></noscript>';
        
	<!-- END VIDEO   THIS IS THE AREA FOR THE VIDEO PLAYER   USE YOUTUBE OR THE CSTOM VIDEO PLAYER   -->		
	return htmlData;
}
