

bookmark_website = 'YoSolo.es';
bookmark_desc = "El videochat español";
website_url='http://'+bookmark_website;

function openpopup(popurl,popupname){
	var winpops=window.open(popurl,popupname,"width=800,height=600,status,scrollbars,resizable");
	return;
}

function LobbyRefresh() { document.location.href=document.location.href; }


function sendToAFriend(form){	
	with (form){	  
		window.open('sendmailfriend.php?n='+name.value+'&fn='+fname.value+'&fe='+femail.value+'&referer='+document.location.href, 'sendtoafriend', 'width=300,height=100')
	}
}


function StartPage()
{
if( document.all ){
	document.body.style.behavior='url(#default#homepage)';
	document.body.setHomePage(location.href);
}else{
	Bookmark();
}
}


function Bookmark() {
title=bookmark_website+" - "+bookmark_desc;
if( navigator.appVersion.indexOf("MSIE") > 0){
if( parseInt(navigator.appVersion)>=4 )
	window.external.AddFavorite(location.href, title);
}else{
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title, location.href,"");
}
}

}


function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}




function ie()
{
	return getInternetExplorerVersion()>0;
}


function ie6()
{
	return getInternetExplorerVersion()==6;
}

function ie7()
{
	return getInternetExplorerVersion()==7;
}


function ie8()
{
	return getInternetExplorerVersion()==8;
}


function ie9()
{
	return getInternetExplorerVersion()==9;
}


function fieldclick(field)
{
	if(!field.myclicked){
		field.myclicked=1;
		field.value='';
	}
}

function load_effect( )
{	
	function af(element) { if(element.element.style.opacity == 0){ element.element.style.opacity=1.0; }else{ element.element.style.filter="alpha(opacity = 100)"  } };
	objeto=document.getElementById('realmenu');
	om=document.getElementById('header');
	pos=findPos(om);						
	new Effect.Move(objeto, { x: pos[0], y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal });	
	op=new Effect.Opacity('realmenu', { from: 0.0, to: 1.0, duration: 0.9,afterFinish: af });
}

function click_menu(id)
{
	Effect.Puff(id, { duration: 3 });	
}

function resize()
{
	objeto=document.getElementById('realmenu');
	pos=findPos(document.getElementById('maincontenttbl'));
	return new Effect.Move(objeto, 
			{ 
				x: pos[0], 
				y: 0, 
				duration: 1,
				mode: 'absolute' 
			}
	);	
}


function rollin(id){
	new Effect.Morph(id, {style:"font-size: 16px;"});
}

function rollout(id){
}

//############# lightbox*** #################

var mposx=0;mposy=0;

var oposx=0;
var oposy=0;
var loaded=0;

window.onload=function(){
	o=document.getElementById('lightbox');
	if(o){ 
		pos=findPos(o);
		oposx=pos[0];
		oposy=pos[1];
		loaded=1
	}
}

function runlightbox(url)
{

	try{
		o=document.getElementById('lightbox');
	//			o.style.width="700px";
	//			o.style.height="500px";
	if(!o || !loaded){ return };
		o.style.position="absolute";
		o.style.left=(mposx-160)+"px";
		if(document.all){
			logicalposy=mposy- document.body.scrollTop - document.documentElement.scrollTop;
			up=logicalposy>document.documentElement.clientHeight/2
		}else{
			logicalposy=mposy- document.body.scrollTop - document.documentElement.scrollTop;
			up=logicalposy>window.innerHeight/2
		}

		//document.getElementById('debug').innerHTML="up="+up;
		if(up)
			o.style.top=(mposy+20-320)+"px";
		else
			o.style.top=(mposy+20)+"px";

		imgwrp = document.getElementById('sublightbox_imgwrap');

		imgwrp.style.position="absolute";
		imgwrp.style.left=(mposx-160+24)+"px";
		if(up)
			imgwrp.style.top=(mposy+47-320)+"px";
		else
			imgwrp.style.top=(mposy+47)+"px";

		img = document.getElementById('sublightbox');
		if(!img){
			imgwrp.innerHTML='<img id="sublightbox" src="'+url+'" border=0></img>';
		}else if( img.src != url ){
			imgwrp.innerHTML='<img id="sublightbox" src="'+url+'" border=0></img>';
		}
		o.style.visibility='visible';
		//setTimeout("hidelightbox("+level+")",2000);
	}catch(e){};
}

function hidelightbox()
{
	o=document.getElementById('sublightbox_imgwrap');
	if(o)	o.innerHTML='';
	o=document.getElementById('lightbox');
	if(o) {
		o.style.visibility='hidden';
		o.style.top 	= oposx;
		o.style.left 	= oposy;
	}
}


function getMousePosition(e){

	if (!e) var e = window.event;
	if (e.pageX || e.pageY){
		mposx = e.pageX; //+window.pageXOffset;
		mposy = e.pageY;//+window.pageYOffset;
	}else if (e.clientX || e.clientY) {
	    mposx = e.clientX+ document.body.scrollLeft + document.documentElement.scrollLeft;
	    mposy = e.clientY+ document.body.scrollTop + document.documentElement.scrollTop;
	}
	return 1;
}

//$(window).click(getMousePosition);

function findPos(obj)
{
    var curleft = curtop = 0;
    if (obj.offsetParent) {
	curleft = obj.offsetLeft;
	curtop = obj.offsetTop;
	while (obj = obj.offsetParent) {
	    curleft += obj.offsetLeft;
	    curtop += obj.offsetTop;
	}
    }
    return [curleft,curtop];
}

function maxWindow()
{
	window.moveTo(0,0);

	if (document.all)
	{
	  top.window.resizeTo(screen.availWidth,screen.availHeight);
	}else{
	    top.window.outerHeight = screen.availHeight;
	    top.window.outerWidth = screen.availWidth;
	}
}

function runtextbox(id)
{
	try{
		o=document.getElementById('textbox');
		o.style.position="absolute";
		o.style.left=(mposx-125)+"px";
		o.style.top=(mposy+20)+"px";
		document.getElementById('textboxcontent').innerHTML = document.getElementById('desc'+id).innerHTML;
		document.getElementById('textboxtitle').innerHTML = document.getElementById('title'+id).innerHTML;
		o.style.visibility='visible';
	//setTimeout("hidelightbox("+level+")",2000);
	}catch(e){};

	
}

function hidetextbox()
{
	try{
		o=document.getElementById('sublightbox_imgwrap');
		//o.innerHTML='';
		o=document.getElementById('textbox');
		o.style.visibility='hidden';
	}catch(e){};
}

function getCookie(c_name)
{
	if (document.cookie.length>0){
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
	{ 
	c_start=c_start + c_name.length+1; 
	c_end=document.cookie.indexOf(";",c_start);
	if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	} 
	}
	return "";
}


function govideo(video_src,thumb_src){
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="400" height="300" id="pay_flash_swf" align="middle">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="util/mediaplayer.swf" />');
	document.write('<param name="FlashVars" value="&repeat=true&volume=0&mute=true&usefullscreen=false&autostart=true&overstretch=none&height=300&width=400&image='+encodeURI(thumb_src)+'&file='+encodeURI(video_src)+'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="overstretch" value="fit" />');
	document.write('<param name="bgcolor" value="#FFFFFF" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="mute" value="true" />');
	document.write('<param name="repeat" value="true" />');
	document.write('<param name="volume" value="0" />');
	document.write('<param name="allowfullscreen" value="false" />');
	document.write('<param name="usefullscreen" value="false" />');
	document.write('<embed src="util/mediaplayer.swf" usefullscreen="false" wmode="transparent" menu="false" allowfullscreen="false" FlashVars="&volume=0&repeat=true&mute=true&usefullscreen=false&overstretch=fit&autostart=true&overstretch=none&height=300&width=400&image='+encodeURI(thumb_src)+'&file='+encodeURI(video_src)+'" quality="high" bgcolor="#FFFFFF" width="400" height="300" name="pay_flash_swf" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}


function playerReady(obj) {
var id = obj['id'];
var version = obj['version'];
var client = obj['client'];
alert('player '+id+' has been instantiated');

};



function Set_Cookie( name, value, expires, path, domain, secure ){
	setCookie( name, value, expires, path, domain, secure ) 
}

function setCookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
    
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


/*
// This reload the page depending of the language

// cookie detector to avoid infinite loops
rd=Math.random();
Set_Cookie('cookie_detector_hp',rd);

if(getCookie('cookie_detector_hp')!=rd){
    cookies=0;
    //alert('tienes las cookies disabled');
}else{
    //alert('tienes cookies');
    cookies=1;
}

img=[];
function preload_img(url){i=new Image(); i.src=url; img.push(i) }
*/


function swapper()
{
	this.state=0;

	this.display = function (id)
	{
		if( this.state ){
			this.state=0;
		}else{
			this.state=1;
		}

		obj= document.getElementById(id);

		if( !obj ) return;

		if( this.state ){
			obj.style.display='block';	
		}else{
			obj.style.display='none';	
		}
	}
}

var dialogLastWindow=null;

function dialog(url,width,height,wind)
{
	if(!wind){
		wind="_blank";
	}
	dialogLastWindow=window.open(url, wind,'width='+width+',height='+height+',status=0,toolbar=0,resizable=1,location=0,scrollbars=1');
	dialogLastWindow.moveTo( (screen.width - width) / 2, (screen.height - height) / 2 );
	dialogLastWindow.focus();
}

function dialogTop(url,width,height,wind)
{
	if(!wind){
		wind="_blank";
	}
	dialogLastWindow=window.open(url, wind,'width='+width+',height='+height+',status=0,toolbar=0,resizable=1,location=0,scrollbars=1');
	dialogLastWindow.moveTo( (screen.width - width) / 2, 0 );
	dialogLastWindow.focus();
}

function dialogClose()
{
//	dialogLastWindow.close();
}


function onErrorLobbyImage(objId){
	var oo=document.getElementById(objId); 
	oo.onerror=void(0); 
	oo.src='http://www.yosolo.es/previews/salasincam.jpg';
}



