var next_video_id;
var video_id;
var channel_id;
var browser;
var artist_player=false;
var next_page;
//var video_id;
function refresh_player(){
	if (autorefresh==true){
		if(browser!="IE"){
			if (artist_player){
			send_data(next_video_id+"|"+channel_id,53,'flashcontent');	
			}else{
			send_data(next_video_id,22,'flashcontent');
			}
		}else{
			if(next_page!=""){
			//alert(next_page);
			document.location = next_page;
			}
			
			
		}
	}
}

var xmlHttp;
var _xt;
var _div_id;

function show_load() { 
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE 
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth; 
    myHeight = document.documentElement.clientHeight; 
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth; 
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight ); 
 //var lft = 0, top = 0;
 var lft = (myWidth/2)-75;
 var top = (myHeight/2)-50 ; 
 //alert(lft + " 000 " + top );
 var str = "<div class=\"show_load\" align=center><IMG src=\"/images/spinner.gif\" align=\"center\">&nbsp;&nbsp;<b>Loading ...</b></div>";
 
 /*document.getElementById('load_splash').style.left=lft;
 document.getElementById('load_splash').style.top=top;
 document.getElementById('load_splash').style.width="150px";
 document.getElementById('load_splash').style.height="100px";
 document.getElementById('load_splash').innerHTML= str;
 document.getElementById('load_splash').style.visibility="visible";
 */
 
 if (_div_id != null){
	document.getElementById(_div_id).innerHTML= str;
 	document.getElementById(_div_id).style.visibility="visible";
	//document.getElementById(_div_id).style.height="100px";
	//document.getElementById(_div_id).style.align="center";
 }
 
}
//---------------------------------------------------------------------------------------------------------

function hide_load(){
//document.getElementById(_div_id).style.visibility="hidden"; 
}

function GetXmlHttpObject(handler)
{ 
	var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
			objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
	return objXMLHttp
}



function show_data(param,xt,_div)
{

//alert("from this field " + param);
var obj = document.getElementById(param);
var str = obj.value;
//alert(obj.options[obj.selectedIndex].text);
_div_id = _div;
//alert("This value passed " + str);
_xt = xt;
//alert("Task number : " + _xt);
//alert("going to effect this : " + _div_id);
show_load();
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
		
		var url=location.protocol + "//" + location.hostname +"/xjax/xjax.php";
		url=url+"?xt="+xt
		url=url+"&var="+str
		url=url+"&sid="+sid
		url=url+"&xid="+Math.random()
		//alert(url);
		xmlHttp.onreadystatechange=stateChanged
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
} 



function send_data(param,xt,_div)
{

//alert(param);
//var obj = document.getElementById(param);
var str = param;
if (xt=="22"){  next_video_id = param; }
//alert(str);
_xt = xt;
_div_id = _div;
//alert(_xt);
if (_xt!=61){
	show_load();
}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
		var url=location.protocol + "//" + location.hostname +"/xjax/xjax.php";
		url=url+"?xt="+xt
		url=url+"&var="+str
		url=url+"&sid="+sid
		url=url+"&xid="+Math.random()
		//alert(url);
		
		xmlHttp.onreadystatechange=stateChanged
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
} 
		


function stateChanged() 
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	//alert(_xt);
	//alert(xmlHttp.responseText);
	//alert(_div_id);
	if (_xt!=61){
		hide_load();
	}
			if (_xt==1){
			   var flv_data = xmlHttp.responseText;
			   if (flv_data!="error"){
			   var flv_arr = flv_data.split("|");
			   var flv_file = flv_arr[0]; 
			   var flv_artist_name = flv_arr[1]; 
			   var flv_track_name = flv_arr[2]; 
			   video_id = next_video_id;
			  	//alert("now playing "+video_id);
			   next_video_id = flv_arr[3];
			   
			   document.getElementById('video_name_div').innerHTML= "&quot;" + flv_track_name + "&quot;";
			    //alert("new video id "+next_video_id);
			   //alert('flv='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1');
			   var so = new SWFObject("flash/player2.swf", "flick2play", "500", "350", "8", "#242424");
			   so.useExpressInstall('flash/expressinstall.swf');
			   so.addParam('allowScriptAccess',"sameDomain");
			   so.addParam('allowFullScreen',"true");
			   //so.addParam('flashVars','flv='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1');
			   // version 2 -- so.addParam('flashVars','file=images.xml&artist_name=Pink&track_name=Who Knew&autoplay=1&videotype=xml&rating=3.5&viewed=345678');
			   var flv_type = flv_arr[4];
			   var flv_rating = flv_arr[5];
			   var flv_view = flv_arr[6];
			   so.addParam('flashVars','file='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1&videotype='+ flv_type +'&rating='+ flv_rating +'&viewed='+ flv_view +'');
			    if(navigator.appName=="Netscape")
				 {
				  so.addParam('wmode',"transparent");
				 }
				 else
				 {
				  so.addParam('wmode',"window");
				 }
			   so.write(_div_id);
			   }else{
				   document.getElementById(_div_id).innerHTML = "Faceing Some Trouble Loading this video";
			   }
			}else if ((_xt==22) || (_xt==53)){
				var flv_data = xmlHttp.responseText;
				//alert(flv_data);
			   if (flv_data!="error"){
			   var flv_arr = flv_data.split("|");
			   var flv_file = flv_arr[0]; 
			   var flv_artist_name = flv_arr[1]; 
			   var flv_track_name = flv_arr[2]; 
			   video_id = next_video_id;
			   //alert("now playing "+video_id);
			   next_video_id = flv_arr[3];
			   //alert("next video id "+next_video_id);
			   //alert('flv='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1');
			   var so = new SWFObject("flash/player2.swf", "flick2play", "500", "350", "8", "#242424");
			   so.useExpressInstall('flash/expressinstall.swf');
			   so.addParam('allowScriptAccess',"sameDomain");
			   so.addParam('allowFullScreen',"true");
			   //so.addParam('flashVars','flv='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1');
			   // version 2 -- so.addParam('flashVars','file=images.xml&artist_name=Pink&track_name=Who Knew&autoplay=1&videotype=xml&rating=3.5&viewed=345678');
			   var flv_type = flv_arr[4];
			   var flv_rating = flv_arr[5];
			   var flv_view = flv_arr[6];
			   so.addParam('flashVars','file='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1&videotype='+ flv_type +'&rating='+ flv_rating +'&viewed='+ flv_view +'');
			    if(navigator.appName=="Netscape")
				 {
				  so.addParam('wmode',"transparent");
				 }
				 else
				 {
				  so.addParam('wmode',"window");
				 }
			   so.write(_div_id);
			   }else{
				   document.getElementById(_div_id).innerHTML = "Faceing Some Trouble Loading this video, Please Try Again";
			   }
			}else if (_xt==23){
				//alert(xmlHttp.responseText);
				document.getElementById(_div_id).innerHTML =xmlHttp.responseText;
				document.getElementById(_div_id).style.display ="";
			}else if (_xt==6){
				document.getElementById(_div_id).innerHTML =xmlHttp.responseText;
				//alert("The video has been deleted sucessfully");
			}else if (_xt==4){
				document.getElementById(_div_id).innerHTML =xmlHttp.responseText;
				alert("The image has been deleted sucessfully from image gallery");
			}else if (_xt==3){
				document.getElementById(_div_id).innerHTML =xmlHttp.responseText;
				alert("The image has been deleted sucessfully from your profile");
			}else if ((_xt==17)){
				var fo = new FlashObject("fileUpload.swf", "fileUpload", "275", "100", "8", "#333333");
				fo.addParam("quality", "high");
				fo.addParam("FlashVars", "redirect=true&redirectUrl=http://www.flick2play.com/artist/upload.php&passFileDetails=Y&uploadFileName=http://www.flick2play.com/artist/upload.php&custom=1");
				 if(navigator.appName=="Netscape")
				 {
				  fo.addParam('wmode',"transparent");
				 }
				 else
				 {
				  fo.addParam('wmode',"window");
				 }
			   fo.write(_div_id);
			  
			}else if ((_xt==47)){
				var fo = new FlashObject("fileUpload.swf", "fileUpload", "275", "100", "8", "#666666");
				fo.addParam("quality", "high");
				fo.addParam("FlashVars", "redirect=true&redirectUrl=http://www.flick2play.com/artist/create_video1.php&passFileDetails=Y&uploadFileName=http://www.flick2play.com/artist/create_video1.php&custom=1");
				 if(navigator.appName=="Netscape")
				 {
				  fo.addParam('wmode',"transparent");
				 }
				 else
				 {
				  fo.addParam('wmode',"window");
				 }
			   fo.write(_div_id);
			/*}else if ((_xt==52)){
				// echo $file."|".$video_data['artist_name']."|".$video_data['name']."|0|".$video_data['videotype']."|".$video_data['rating']."|".$video_data['viewed'];
				var flv_data = xmlHttp.responseText;
				alert(flv_data);
			   if (flv_data!="error"){
			   var flv_arr = flv_data.split("|");
			   var flv_file = flv_arr[0]; 
			   var flv_artist_name = flv_arr[1]; 
			   var flv_track_name = flv_arr[2]; 
			   video_id = next_video_id;
			   next_video_id = flv_arr[3];
   			   
			   //document.getElementById('video_name_div').innerHTML= "&quot;" + flv_track_name + "&quot;";
			    //alert("new video id "+next_video_id);
			   //alert('flv='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1');
			   var so = new SWFObject("flash/player2.swf", "flick2play", "500", "350", "8", "#242424");
			   so.useExpressInstall('flash/expressinstall.swf');
			   // version 2 -- so.addParam('flashVars','file=images.xml&artist_name=Pink&track_name=Who Knew&autoplay=1&videotype=xml&rating=3.5&viewed=345678');
			   var flv_type = flv_arr[4];
			   var flv_rating = flv_arr[5];
			   var flv_view = flv_arr[6];
			   so.addParam('flashVars','file='+ flv_file +'&artist_name='+ flv_artist_name +'&track_name='+ flv_track_name +'&autoplay=1&videotype='+ flv_type +'&rating='+ flv_rating +'&viewed='+ flv_view +'');
			   alert(_div_id);
			   so.write(_div_id);
			   }else{
				   document.getElementById(_div_id).innerHTML = "Faceing Some Trouble Loading this video";
			   }*/
			}else if ((_xt==13)){
				document.getElementById(_div_id).innerHTML =xmlHttp.responseText;
				
				//alert(xmlHttp.responseText);
			}else if ((_xt==61)){
				document.getElementById(_div_id).innerHTML=xmlHttp.responseText+document.getElementById(_div_id).innerHTML;
			}else{
				document.getElementById(_div_id).innerHTML =xmlHttp.responseText;
				//document.getElementById('result').value =xmlHttp.responseText;
			}
	} 
} 

	
