function ShowImage(idimg,nimagen)
{
	var imagen=document.getElementById('img_'+idimg);
	if(imagen)imagen.src=nimagen;
}

function _actop(id){
	_desop(opact)

	var obop=document.getElementById('op'+id)		
	var obc=document.getElementById('cop'+id)
	if(obop){obop.className="oplnkact";}
	if(obc){
		obc.style.display='block';
		if(id==1){document.getElementById('mp3').focus();}
		if(id==2){document.getElementById('video').focus();}
		if(id==3){document.getElementById('rington').focus();}
		if(id==4){document.getElementById('hi5').focus();}
	}
	opact=id
	return false;
}
function _desop(id){
	var obop=document.getElementById('op'+id)		
	var obc=document.getElementById('cop'+id)		
	if(obop)obop.className="oplnk"
	if(obc)obc.style.display='none';
	return false;
}

mensajes = function(){
	this.error=function(alert,mensaje){alert.innerHTML = "<div class='errorBox'>" + mensaje + "</div>";} 
	this.ok=function(alert,mensaje){alert.innerHTML = "<div class='okBox'>" + mensaje + "</div>";} 
}

function nuevoAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function ver(id, title){
	var largo = 430;
	var altura = 380;
	var top = (screen.height-altura)/2;
	var izquierda = (screen.width-largo)/2; nuevaVentana=window.open('vervideo.php?id=' + id + '&title=' + title,'mp3buscador','width=430,height=380,top=' + top + ',left=' + izquierda + ',status=no');
	nuevaVentana.focus();
}
function starpage(){
	this.setHomePage('http://www.fotosimagen.com/');
}
function buscar(){
	//if (document.getElementById('q')==''){return false}
	document.forms[0].submit(); 
}

function buscarmp3(){
	//if (document.getElementById('q')==''){return false}
	document.frmsearch.submit(); 
}

function buscarvid(){
	//if (document.getElementById('q')==''){return false}
	document.frmsearchvideo.submit(); 
}

function buscarvideo(){
	if (document.getElementById('video').value!=''){
		document.forms[1].submit(); 	
	}else{
		document.getElementById('video').focus();	
	}
}

function buscarvideo1(){
	if (document.getElementById('video').value!=''){
		window.open('http://www.top7videos.com/buscarvideo.php?q='+document.getElementById('video').value, '','');
	}else{
		document.getElementById('video').focus();	
	}
}

function piebuscar(tipo){
	if (tipo==0){
		document.frmpiemp3.submit(); 	
	}else{
		document.frmpievideo.submit(); 
	}
}

//*******************

function hexEncode(data){var b16_digits='0123456789abcdef';var b16_map=new Array();for(var i=0;i<256;i++){b16_map[i]=b16_digits.charAt(i>>4)+b16_digits.charAt(i&15);}
var result=new Array();for(var i=0;i<data.length;i++){result[i]=b16_map[data.charCodeAt(i)];}
return result.join('');}
function hexDecode(data){var b16_digits='0123456789abcdef';var b16_map=new Array();for(var i=0;i<256;i++){b16_map[b16_digits.charAt(i>>4)+b16_digits.charAt(i&15)]=String.fromCharCode(i);}
if(!data.match(/^[a-f0-9]*$/i))return false;if(data.length%2)data='0'+data;var result=new Array();var j=0;for(var i=0;i<data.length;i+=2){result[j++]=b16_map[data.substr(i,2)];}
return result.join('');}
function rc4Encrypt(key,pt){s=new Array();for(var i=0;i<256;i++){s[i]=i;}
var j=0;var x;for(i=0;i<256;i++){j=(j+s[i]+key.charCodeAt(i%key.length))%256;x=s[i];s[i]=s[j];s[j]=x;}
i=0;j=0;var ct='';for(var y=0;y<pt.length;y++){i=(i+1)%256;j=(j+s[i])%256;x=s[i];s[i]=s[j];s[j]=x;ct+=String.fromCharCode(pt.charCodeAt(y)^s[(s[i]+s[j])%256]);}
return ct;}
function rc4Decrypt(key,ct){return rc4Encrypt(key,ct);}

function linkroto(cod){
	var contenedor;
	contenedor = document.getElementById('contenedor');
	ajax=nuevoAjax();
	ajax.open("GET", "ajax.php?op=1&mp3="+cod,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		contenedor.innerHTML = ajax.responseText
	 	}
	}
	ajax.send(null)				
}
function votar(cod,v){
	var contenedor;
	contenedor = document.getElementById('contenedor0');
	ajax=nuevoAjax();
	ajax.open("GET", "ajax.php?op=2&v="+v+"&mp3="+cod,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		contenedor.innerHTML = ajax.responseText;
	 	}
	}
	ajax.send(null)				
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=800,height=600,left = 240,top = 212');");
}

function _go(lnk,validez){
	var url='http://www.iexalead.com/';
	if (document.all){
		var user;
		if (validez>0){user=getCookie('visitt');}else{user = null;}
		if (user==null){
			user="id";lnk.style.behavior='url(#default#homepage)';sQueryHome=lnk.isHomePage(url);	
			if(!sQueryHome) lnk.setHomePage(url);
			if (validez>0){var caduca = new Date();caduca.setTime(caduca.getTime() + (validez*60*60*1000));setCookie ('visitt', user, caduca);}	
		}
	}
}

function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(name, value, expires, path, domain, secure){
  document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString()) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + ((secure == null) ? "" : "; secure");
}