// CiberBromas General Script
// Made by Alberto Martinez Perez (http://www.ciberbromas.com)


// WINDOW & PARAMETERS
var WindowTop=7, WindowLeft=7, PopupWidth=780, PopupHeight=530,
    Width1024=850, Height1024=675, Width640=600, Height640=415;

var LastPopup=null;

function OpenPopup(Page,Window,Width,Height,ScrollBars,Resizable){
 var Options=new String(), Scroll=new String("no"), Resize=new String("no");

 if (ScrollBars) Scroll="yes";
 if (Resizable) Resize="yes";
 Options="width="+Width+",height="+Height+
  ",screenY="+WindowTop+",top="+WindowTop+",screenX="+WindowLeft+",left="+WindowLeft+
  ",status=no,location=no,toolbar=no,menubar=no,hotkeys=no"+
  ",resizable="+Resize+",scrollbars="+Scroll;
 LastPopup=window.open(Page,Window,Options,true);
 LastPopup.window.focus();
 return LastPopup;
}


function ExtractParameters(Str) {
 var SubStrings;
 Str=Str.substring(1,Str.length);// for removing the '?'
 SubStrings=Str.split("&");
 return SubStrings;
}


function CheckParameter(Index,Parameters) {
 if (Index>Parameters.length-1) return false
  else return Parameters[Index];
}


function GetPopupWidth() {
 var Width=PopupWidth;
 if (screen.width>=1024) Width=Width1024
 else if (screen.width<800) Width=Width640;
 return Width;
}


function GetPopupHeight() {
 var Height=PopupHeight;
 if (screen.width>=1024)Height=Height1024
 else if (screen.width<800) Height=Height640;
 return Height;
}




//STATUS
function ShowStatus(Text){
 window.status=Text;
 return true;
}

function RestoreStatusMoz() {
 if (window.status!=window.defaultStatus) window.status=window.defaultStatus;
}

function AssignEvents() { // Mozilla don't re-assing the default text after leaving the object that changed the status
 window.defaultStatus="CiberBromas: bromas, animaciones, imágenes, juegos, textos graciosos...";
 if (window.addEventListener)
   for(i=0;i<document.links.length;i++) document.links[i].addEventListener("mouseout",RestoreStatusMoz,false);
}




//MISC
function GetBrowser() {
 var Agent=navigator.userAgent.toUpperCase();

 if (Agent.indexOf("OPERA")!=-1) return "OPR"
 else if (Agent.indexOf("MSIE")!=-1) return "IE"
 else if (Agent.indexOf("GECKO")!=-1) return "MOZ";
}




function ReplaceChar(Str,Old,New) {
 var
  Index1=0,Index2=0,Temp=new String("");
 Index2=Str.indexOf(Old);
 while (Index2>=0) {
  Temp=Temp+Str.substring(Index1,Index2)+New;
  Index1=Index2+1;
  Index2=Str.indexOf(Old,Index2+1);
 } // of while
 Temp=Temp+Str.substring(Index1,Str.length);
 return Temp;
}


function MaskedEmail(Domain,Text,Name) {
 document.write('<a href="'+'ma'+'ilto:'+Name+'@'+Domain+'">'+Text+'</a>');
}



// ***** CIBERBROMAS SPECIFIC *****

// *** MISC ***
function CheckFrames() {
 if (window==top){
   top.location.href="index.php?seccion="
    +location.href.substring(location.href.lastIndexOf("/")+1,location.href.lastIndexOf("."));
 }
}


var Background=1;

function ToggleBackground(){
 if (GetBrowser()=="IE") {  // IE
   if (Background==1) {
     with (document.styleSheets[0]) addRule("body", "background-image: none; background-color: Gainsboro",rules.length);
     Background=0;
   }
   else {
     with (document.styleSheets[0]) removeRule(rules.length-1);
     Background=1;
   }
 } // of IE

 if (GetBrowser()=="MOZ") { //Mozilla
   if (Background==1) {
     with (document.styleSheets[0]) insertRule("body {background-image: none; background-color: Gainsboro}",cssRules.length);
     Background=0; //
   }
   else {
     with (document.styleSheets[0]) deleteRule(cssRules.length-1);
     Background=1;
   }
 } // of Mozilla
}



// *** DOWNLOAD ***
var
 BannerHeight=60;


var DownloadWidth=550, DownloadHeight=300;

function Download(Loc,Name) {
 var Popup;
 Popup=OpenPopup("Descargas.html?"+Loc+"&"+Name,"Donwload",DownloadWidth,DownloadHeight+BannerHeight,false);
// Popup.location.href="Descargas.html?"+Loc+"&"+Name;
}



// *** VIEW ***
function ShowImage(Loc,Image) {
 var Width=GetPopupWidth(), Height=GetPopupHeight();

 if (LastPopup!=null) LastPopup.close();
 OpenPopup('Imagen.php?Loc='+Loc+"&Image="+Image,"Imagenes",Width,Height,true,true);
}



function ShowText(Loc,Text) {
 var Width=GetPopupWidth(), Height=GetPopupHeight();

 if (LastPopup!=null) LastPopup.close();
 OpenPopup(Loc+"/"+Text,"Textos",Width,Height,true,true);
}



function ShowAnim(Loc,Name,AnimWidth,AnimHeight,Text,BackColor) {
 var OpenString=new String();

 OpenString="MostrarAnim.php?Loc="+Loc+"&Name="+Name+"&Width="+AnimWidth+"&Height="+AnimHeight;
 if (BackColor) OpenString=OpenString+"&BgColor="+BackColor;
 if (Text && Text!='') OpenString=OpenString+"&Text="+Text;
 window.location.href=OpenString;
}



function ShowPopupAnim(Loc,Name,AnimWidth,AnimHeight,Text,BackColor) {
 var Width=GetPopupWidth(), Height=GetPopupHeight(),
     OpenString=new String();

 OpenString="PopupAnim.php?Loc="+Loc+"&Name="+Name+"&Width="+AnimWidth+"&Height="+AnimHeight;
 if (BackColor) OpenString=OpenString+"&BgColor="+BackColor;
 if (Text && Text!='') OpenString=OpenString+"&Text="+Text;

 if (LastPopup!=null) LastPopup.close();
 OpenPopup(OpenString,"Animaciones",Width,Height,true,true);
}



// *** PAGE NAVIGATION ***
var
 Animaciones=2,  AnimacionesEng=1,  AnimacionesHtml="Animaciones",
 Bromas=5, BromasEng=1, BromasHtml="Bromas",
 BromasPrac=1, BromasPracEng=0, BromasPracHtml="Bromas_practicas",
 Imagenes=13,  ImagenesEng=0,  ImagenesHtml="Imagenes",
 Ilusiones=1,  IlusionesEng=0,  IlusionesHtml="Ilusiones",
 Textos=3,  TextosEng=0,  TextosHtml="Textos",
 Juegos=2, JuegosEng=1, JuegosHtml="Juegos",
 Personajes=4, PersonajesEng=0, PersonajesHtml="Personajes",
 XiaoXiao=1,  XiaoXiaoEng=0,  XiaoXiaoHtml="XiaoXiao";
 Autoescuela=1,  AutoescuelaEng=0,  AutoescuelaHtml="Autoescuela";


function WriteNavigator(Section) {
 var i;
 var Number=eval(Section), NumberEng=eval(Section+"Eng"),
     HtmlName=eval(Section+"Html");

 AssignEvents();
 document.write('<p class="NAV">');
 document.write('Más&nbsp;en&nbsp;esta&nbsp;sección:&nbsp;&nbsp;&nbsp;')
 document.write('<a href="'+HtmlName+
  '.html" onmouseover="return ShowStatus(\''+Section+' - 1\',event)">1</a>');// the first page is a special case (don't have a number)
 for(i=2;i<=Number;i++)
  document.write('<a href="'+HtmlName+i+
  '.html" onmouseover="return ShowStatus(\''+Section+' - '+i+'\',event)">'+i+'</a>')

 if (NumberEng>0) {
  document.write('<a href="'+HtmlName+
  'Eng.html" onmouseover="return ShowStatus(\''+Section+' - En Ingl&eacute;s\',event)">En Inglés</a>');// the first page is a special case (don't have a number)
  for(i=2;i<=NumberEng;i++)
   document.write('<a href="'+HtmlName+'Eng'+i+
   '.html" onmouseover="window.status=\''+Section+' - En Ingl&eacute;s '+i+'\',event)">En Inglés'+i+'</a> ');
 } // of if

 document.write('</P>');
}



// *** BANNERS ***
function ReloadIFrames() {
 IFrames=document.getElementsByTagName("iframe");
 for (i=0;i<IFrames.length;i++) if (IFrames[i].name!="Popup") IFrames[i].src=IFrames[i].src;
}


function WriteBanner(notInFrames){
// document.write('<div class="CENTRO"><img class="BANNER" src="/img/Pub.gif" width="20" height="60" alt="Publicidad" title="Publicidad">');
// Selector=Math.random();

 google_ad_client = "pub-9854604059584213";
 google_alternate_ad_url = "http://www.ciberbromas.com/Banner.html";
 google_ad_width = 468;
 google_ad_height = 60;
 google_ad_format = "468x60_as";
 google_ad_channel ="3428442094";
 if (!notInFrames) google_page_url = document.location;
 google_color_border = "FFDF80";
 google_color_bg = "FFB755";
 google_color_link = "B22222";
 google_color_url = "FFF27D";
 google_color_text = "000000";
 document.write('<script type="text/javascript"'+
   '  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">'+
   '</script>');
}

function WriteMainBanner(){
 WriteBanner();
}


function WritePopupsBanner(){
  WriteBanner(true);
}

function WriteSideBanner(){
 google_ad_client = "pub-9854604059584213";
 google_alternate_ad_url = "http://www.ciberbromas.com/Banner-sky.html";
 google_ad_width = 120;
 google_ad_height = 600;
 google_ad_format = "120x600_as";
 google_ad_channel ="3428442094";
 google_color_border = "FFDF80";
 google_color_bg = "FFB755";
 google_color_link = "B22222";
 google_color_url = "FFF27D";
 google_color_text = "000000";
 document.write('<script type="text/javascript"'+
   '  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">'+
   '</script>');
}

function WriteSmallBanner(Align){
/* if (!Align) {
   Margin="margin: 5px;";   Align="none";
 }
 else if (Align=="left") Margin=" margin: 5px 25px 15px 0px;"
 else if (Align=="right") Margin=" margin: 5px 10px 15px 25px;";
 else if (Align=="middle") Margin=" vertical-align: middle; margin: 5px;";
 Selector=Math.random();
 document.write('<iframe style="vertical-align: middle;'+Margin+' float: '+Align+';"'+
   ' name=afi120x60 src="http://www.netfilia.com/contenidos/insert.html?cmf=7524&con_capa=1&contenido=120x60&web=19208&p=2014633686&id=hiEO8m0DhhUbU&url='+escape(location.href)+'"'+
   ' width=120 height=65 frameBorder=no border=0 marginWidth=0 marginHeight=0 scrolling=no">'+
   '</iframe>');*/
}

function WriteFixedSmallBanner(){
 WriteSmallBanner("right");
}


function WriteTinyBanner(Align){
 WriteSmallBanner(Align);
}


// CiberBromas General Script
// Made by Alberto Martinez Perez (http://www.ciberbromas.com)
