var sm_down="$SM_code$";
var bb="multimedia";

function setSm(obj){
  sm_down= obj;
}
function vDownload(p){

url = "blinko_gold/"+bb+"/buy.bsp&SM_ALIASCATEGORY="+p+"&SM_code="+sm_down;

//alert(url)
 document.location=url;
}


function pVideo(mfile,ifile,f){

mSID = "?$SID$:";

mfile = mfile.replace(mSID,'');
ifile= ifile.replace(mSID,'');

autostart="false";
autostart="true";




if(f==1){
w=360;h=270;
}
else{
w=590;h=443;
}

if(f==2){
w=160;h=120;
}


html  = "<embed src='/fr/blinko_gold/swf/flvplayer.swf' width='"+w+"' height='"+h+"' allowfullscreen='true' allowscriptaccess='always' flashvars='&file="+mfile+"&height="+h+"&width="+w+"&autostart=true&image="+ifile+"' />"

if(f==2){
html = html + "<br/><br/>test<br/>x<a href='/fr/pmsdata.js?target=#' onclick=document.getElementById('player_video').style.display='none'>close</a>";
}





	document.getElementById('player_prw').style.display= "none";
	document.getElementById('player_video').innerHTML = html;
	document.getElementById('player_video').style.display= "block";



}

function playvideo(mfile,auto,t,f){
//alert(t)
//alert(mfile)

autostart="false";
path="videoclip";
if( mfile==undefined ){
  return;
}
if( auto == undefined ){
autostart="true";
}



if(f==1){
w=360;h=270;
}
else{
w=590;h=443;
}

//alert( p );alert(mfile);

//html  = "<embed src='/fr/blinko_gold/swf/flvplayer.swf' width='360' height='270' allowfullscreen='true' allowscriptaccess='always' flashvars='&file="+p+mfile+"&height=270&image=blinko_gold/images/preview.jpg&width=360&autostart=true' />";

html  = "<embed src='/fr/blinko_gold/swf/flvplayer.swf' width='"+w+"' height='"+h+"' allowfullscreen='true' allowscriptaccess='always' flashvars='&file=http://x.jmailer.com/it/blinkogold/"+t+"/"+mfile+"&height="+h+"&width="+w+"&autostart=true' />";

//alert(html)


	document.getElementById('player_prw').style.display= "none";
	document.getElementById('player_video').innerHTML = html;	
}

function getvideo(name,auto,type,f){

playvideo(name,true,type,f);

return;

		var url = 'blinko_gold/getcode.bsp&SM_vcode='+name+"&tagPage=index" ;

//alert( url )
		var dateMilis = new Date().getTime();
		var pars = "debugContext=1&random="+dateMilis;
					
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars, 
				onComplete: submitCodeResponse,
				
onSuccess: function(transport){       var response = transport.responseText || "no response text";        }, 
onFailure: function(){ alert('Something went wrong...'); return false; } 
			});

}


	function submitCodeResponse(originalRequest)
	{

var response = originalRequest.responseText || "no response text";        
		//document.getElementById("numpage").innerHTML=tcurrPage;
                var response = trim(originalRequest.responseText);


response= ltrim( response );
response= rtrim( response );

//alert(response)


                //document.getElementById("mtags").innerHTML=response;
                playvideo(response,true);
	}





function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if(typeof inputString != "string") { 
   	return inputString; 
   }
   
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while(ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length - 1, retValue.length);
   while(ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while(retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ") + 1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
}
