// JavaScript Document
//var i=0;
flowplayer("player", {src: "http://www.cinecomcast.com/flw/flowplayer.commercial-3.1.2.swf", wmode: 'opaque'},
		   {
		   key: '@3f9bce52ec750d84504',
		   		clip:{
					scaling:'orig'
		   		},
		   	   
		playlist: [ 
         {url: 'http://www.cinecomcast.com/c_cinecomcast/jingle.flv', scaling: 'fit'}
        ], 
		   
	
		   		onLoad: function(){ 
        			fetchAdress(); 
    	   		}, 
		   	
				onFinish: function() { 
		var uri = 'http://anet.tradedoubler.com/anet?type(iframe)loc(54520)' + new String (Math.random()).substring (2, 11);
		document.getElementById('myOverlay').style.visibility = 'visible';
        document.getElementById('myOverlay').innerHTML = '<div id="internaloverlay"><iframe src="'+uri +'" width="300" height="250" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>';
		registerads();
		
    			},
	

			
				plugins: {
					controls: {
					playlist: true, 
					bufferColor: '#00357d',
					progressColor: '#7a9cd8',
					backgroundColor: '#c6d3e3',
					buttonOverColor: '#8ab8fd',
					buttonColor: '#00357d',
					timeBgColor: '#FFFFFF',
					timeColor: '#8ab8fd',
					durationColor: '#00357d'	
					},
					hello:  { 
					url: 'http://www.cinecomcast.com/c_cinecomcast/logo.swf', 
					top: 0, 		
					right:260
					}
				   
				},
			
				canvas: {backgroundColor: "#000000",backgroundGradient:"none"}


		});
function fetchAdress(){
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
	}catch (e){
	// Internet Explorer Browsers
	try{
	ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try{
	ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e){
	// Something went wrong
	alert("Your browser broke!");
	return false;
	}
	}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//return ajaxRequest.responseText;
			//alert(ajaxRequest.responseText);
			$f().addClip({url: ajaxRequest.responseText, position: 5},0);
			$f().getPlugin("hello").fadeTo(0.5, 1000);
		}
	}
	var vidID = document.getElementById('player').name;
	ajaxRequest.open("GET", "http://www.cinecomcast.com/fetchfeeds.php?vidID="+vidID+"&media=1", true);
	ajaxRequest.send(null); 
}

function hideads(){
document.getElementById('myOverlay').style.visibility='hidden';
}

function registerads(){
	var ajaxRequest2;  // The variable that makes Ajax possible!
	try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest2 = new XMLHttpRequest();
	}catch (e){
	// Internet Explorer Browsers
	try{
	ajaxRequest2 = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try{
	ajaxRequest2 = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e){
	// Something went wrong
	alert("Your browser broke!");
	return false;
	}
	}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest2.onreadystatechange = function(){
		if(ajaxRequest2.readyState == 4){

			
		}
	}
	var vidID = document.getElementById('player').name;
	ajaxRequest2.open("GET", "http://www.cinecomcast.com/registerads.php?vidID="+vidID+"&media=1", true);
	ajaxRequest2.send(null); 	
}
