
//Abrir pagina en otra web
//if (top.location != self.location)top.location = self.location;
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	var scrollvar="yes";
	var resizable="no";
	if(myname=="popchat") {scrollvar="no"; resizable="yes";}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=" + scrollvar + ",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=" + resizable + "";win=window.open(mypage,myname,settings);
	win.focus();
}

var menuwidth=240
var scrollspeed=8
var scrollspeedOut=2
var menucontents
var isIE = navigator.userAgent.toLowerCase().indexOf('msie') >= 0;

document.write('<span id="tempTopMenu" style="visibility:hidden;position:absolute;top:-100;left:-5000"></span>')

var actualwidth
var cross_scroll
var loadedyes=0
var movemenutime
var closeDivMenu
var activeDivMenu




function showDivMenu(event, idmenu) {
	var eventTarget = getEventSource(event);
	if (closeDivMenu) { clearTimeout(closeDivMenu); }
	if (activeDivMenu && activeDivMenu != idmenu) { hideDivMenu(activeDivMenu, 1); }
	eventTarget.style.position = "relative";
	document.getElementById(idmenu).style.top =	eventTarget.offsetTop+eventTarget.offsetHeight-14+'px';
	document.getElementById(idmenu).style.left = eventTarget.offsetLeft-4+'px';
	eventTarget.style.position = "static";
	document.getElementById(idmenu).style.display = 'block';
	activeDivMenu = idmenu;
}

function hideDivMenu(idmenu, command) {
	if (command == 1) document.getElementById(idmenu).style.display = 'none';
	else closeDivMenu=setTimeout("hideDivMenu('"+idmenu+"', 1)", 250);
}

function ArribaDivMenu(idmenu) {
	clearTimeout(closeDivMenu);
}

function getEventSource(event) {
  return isIE ? event.srcElement : event.target;
}



function setUpDivMenu(idmenu) {
	if (!idmenu) idmenu = "scrollTop"
	
	menucontents = document.getElementById(idmenu).innerHTML
	document.getElementById("tempTopMenu").innerHTML = menucontents

	cross_scroll=document.getElementById("testTopMenu")
	cross_scroll.innerHTML=menucontents
	cross_scroll.style.left=0
	actualwidth=document.getElementById("tempTopMenu").offsetWidth
	whereMoveOut = 2
	if (movemenutime) clearTimeout(movemenutime)
	loadedyes=1
	movealone()
	
}

function movealone() {

	if (loadedyes){
		if (parseInt(cross_scroll.style.left) > (menuwidth-actualwidth) && whereMoveOut == 2) {
			cross_scroll.style.left= parseInt(cross_scroll.style.left) - scrollspeedOut+"px"
		}
		else if (parseInt(cross_scroll.style.left)<0 && whereMoveOut == 1) {
			cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeedOut+"px"
		}
		else {
			if (whereMoveOut == 2) whereMoveOut = 1
			else whereMoveOut = 2
		}
		movemenutime=setTimeout("movealone()",50)
	}
}

function moveleft(){
	if (loadedyes){
		if (parseInt(cross_scroll.style.left) > (menuwidth-actualwidth))
			cross_scroll.style.left= parseInt(cross_scroll.style.left) - scrollspeed+"px"
		whereMoveOut = 2
	}
	lefttime=setTimeout("moveleft()",50)
}

function moveright(){
	if (loadedyes){
		if (parseInt(cross_scroll.style.left)<0)
			cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px"
		whereMoveOut = 1
	}
	righttime=setTimeout("moveright()",50)
}

function setUrltoLink(linkName, newUrl){
	document.getElementById(linkName).href = newUrl;
}

function showHiddeEle(eleID, show) {
	if (show) document.getElementById(eleID).style.visibility="visible";
	else document.getElementById(eleID).style.visibility="hidden";
}

function changeImgSize(pic, maxWidth, maxHeight){
	//In the PHP IMG bbcode: style="display:none;" onLoad="changeImgSize(this, 520, 520)";

	pic.style.display = 'block';
	var old_x = pic.offsetWidth;
	var old_y = pic.offsetHeight;
	var changes = 0;

	if (maxWidth < old_x) { changes = 1; old_y = Math.round(maxWidth / old_x * old_y); old_x = maxWidth; }
	if (maxHeight < old_y) { changes = 1; old_x = Math.round(maxHeight / old_y * old_x); old_y = maxHeight; }

	if (changes == 1) {
		pic.width = old_x;
		pic.height = old_y;
		pickLink=document.createElement('a');
		pickLink.setAttribute('href',pic.src); 
		pickLink.setAttribute('target','_blank'); 
		pic.parentNode.insertBefore(pickLink,pic.nextSibling);
		pickLink.appendChild(pic);
	}
}

function getFlashMovieObject(movieName) {
	if (window.document[movieName]) return window.document[movieName];
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; 
	}
	else return document.getElementById(movieName);
}

function PlayFlashMovie() {
	var flashMovie=getFlashMovieObject('minivideo');
	flashMovie.Play();
}