// JavaScript Document

function tab(p) {
	
if (p=='2') {	
document.getElementById('p1').className='p1_off';
document.getElementById('p2').className='p2_on';
document.getElementById('cont1').className='ocultar';
document.getElementById('cont2').className='';
} 
else if (p=='1') {	
document.getElementById('p1').className='p1_on';
document.getElementById('p2').className='p2_off';
document.getElementById('cont1').className='';
document.getElementById('cont2').className='ocultar';
}


}


function fnSet() {
parent.location.href='/';	
	} 

	
	/*
	function fnSet() {
	
	HomePage = top.location.href;
	if (document.layers)
	setNSHomepage(HomePage);
	else 
	if (document.all) {
	this.style.behavior='url(#default#homepage)';
	this.setHomePage(HomePage);
	}
	else
	
	//alert('Esta opcion no es soportada por su navegador');
	parent.location.href='/';	

}

*/
function favoritos() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("Frases para mi Facebook","http://www.frasesparamifacebook.com/",""); }
else { window.external.AddFavorite("http://www.frasesparamifacebook.com/","Frases para mi Facebook"); } }




function ajax_dialog(urlToLoad , linkTitle , div , width , height ){
	tab = document.getElementById(div);
	if (!tab){
		$('body').append('<div id="'+div+'"></div>');
		$('#' + div).dialog({
				modal: true,
				open: function (){
					$(this).html("Cargando...");
					$(this).load(urlToLoad);
				},         
				height: height,
				width: width,
				title: linkTitle,
				close: function(){ $('#'+div).remove(); } 
			});
	}
    return false;
}



function InvitarAmigos(){

	ajax_dialog('invita_amigos.htm' , 'Invita a tus Amigos' , 'invitar_amigos' , 445 , 370);
	return false ;
}



function AjaxLoad(__url ,  __variables , __donde , _metodo , _tipo , _value){
	if (typeof (_metodo) == "undefined") { _metodo = 'true' ; }
	$.ajax( {
		async:_metodo,
		dataType: "html",
		type: "POST",
		url: __url ,
		data: __variables,
		global: true,
		ifModified: false,
		processData:true,
		contentType: "application/x-www-form-urlencoded",
		success: function(datos){
			if (typeof (_tipo) == "undefined") { $(__donde).html(datos); }
			if( _tipo == "html"){ $(__donde).html(datos); }
			if( _tipo == "append"){ $(__donde).append(datos); }
			if( _tipo == "prepend"){ $(__donde).prepend(datos); }
			if( _tipo == "attr"){ 
				if (typeof (_value) == "undefined") {
					$(__donde).attr('value' , datos);
				} else {
					$(__donde).attr(_value , datos);	
				}
			}
		}
	});
	return false ;
}




function TOPTEN(){
	AjaxLoad('controladores/top.php' , null , '#lostopten' , true);	
	setTimeout("TOPTEN()",30000)
	return false;
}




function rand (min, max) {
    var argc = arguments.length;
    if (argc === 0) {
        min = 0;
        max = 2147483647;
    } else if (argc === 1) {
        throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
    }
    return Math.floor(Math.random() * (max - min + 1)) + min;
}



function banner_rotatorio(){
	var Banners = new Array(4)
	Banners[0] = '1.jpg';
	Banners[1] = '2.jpg';
	Banners[2] = '3.jpg';
        Banners[3] = '4.jpg';
	var Rand = rand(0 , 3);
	$('#banner_rotatorio').attr('src' , 'ico/banners/' + Banners[Rand]);
	setTimeout("banner_rotatorio()",7000)
	return false;
}
