﻿// My onLoad function
function onloadEvents() {
  try
 {
   load();
 }
 catch(err)
 {
  //Handle errors here
  checkCookie();
  }
 //checkCookie();
}

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 setCookie(c_name,value,expiredays) {
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie() {
  GuinchoSound=getCookie('GuinchoSound');
  if (GuinchoSound == ""){
    GuinchoSound = "on";
    setCookie('GuinchoSound',"on",365);
    PlaySound();
  }
  else {
    if (GuinchoSound == "on") {
    PlaySound();
    }
    else {
      document.getElementById("tooglesoundon").style.display = "inline";
      document.getElementById("tooglesoundoff").style.display = "none";
    }
  }
}
function setSoundOff() {
  setCookie('GuinchoSound',"off",365);
  document.getElementById("tooglesoundon").style.display = "inline";
  document.getElementById("tooglesoundoff").style.display = "none";
  StopSound();
}
function setSoundOn() {
  setCookie('GuinchoSound',"on",365);
  document.getElementById("tooglesoundoff").style.display = "inline";
  document.getElementById("tooglesoundon").style.display = "none";
  PlaySound();
}

function PlaySound() {
 document.getElementById('SoundHolder').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width=10 height=10><param name="movie" value="/Files/System/Guincho/sound.swf"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="Transparent" /><embed src="/Files/System/Guincho/sound.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" menu="false"  width=1 height=1 wmode="Transparent"><\/embed><\/object>';
}

function StopSound() {
 document.getElementById('SoundHolder').innerHTML = "";
}



function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function ShowParagraph(TheParagraphID) {
  var TheParagraphs = getElementsByClass('FG_B11-T11Paragraph');
  for (i=0; i<TheParagraphs.length; i++) {
    document.getElementsByClass('FG_B11-T11Paragraph')[i].style.display = "none";
//    TheParagraphs[i].style.display = "none";
  }
  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";
}

//Functions PT
function SParagraphGaleria(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 148).style.display = "none";
  document.getElementById('ParagraphContent' + 149).style.display = "none";
  document.getElementById('ParagraphContent' + 150).style.display = "none";
  document.getElementById('ParagraphContent' + 152).style.display = "none";
  document.getElementById('ParagraphContent' + 153).style.display = "none";
 
  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";
}

function MyShowHide(TheParagraphID) {
  for(i=0; i < myParagraphIds.length; i++){
   document.getElementById('ParagraphContent' + myParagraphIds[i]).style.display = "none";
  }
  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "block";
}

function SParagraphBar(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 124).style.display = "none";
  document.getElementById('ParagraphContent' + 125).style.display = "none";

  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";
}

function SParagraphReunioes(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 126).style.display = "none";
  document.getElementById('ParagraphContent' + 127).style.display = "none";
  document.getElementById('ParagraphContent' + 128).style.display = "none";

  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";

}

function SParagraphProgramas(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 106).style.display = "none";
  document.getElementById('ParagraphContent' + 87).style.display = "none";
  document.getElementById('ParagraphContent' + 88).style.display = "none";

  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";

}

//Funtions EN
function SParagraphGallery(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 463).style.display = "none";
  document.getElementById('ParagraphContent' + 468).style.display = "none";
  document.getElementById('ParagraphContent' + 469).style.display = "none";
  document.getElementById('ParagraphContent' + 470).style.display = "none";
  document.getElementById('ParagraphContent' + 471).style.display = "none";
 
  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";
}

function SParagraphPrograms(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 398).style.display = "none";
  document.getElementById('ParagraphContent' + 396).style.display = "none";
  document.getElementById('ParagraphContent' + 533).style.display = "none";

  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";

}

function SParagraphMeetings(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 459).style.display = "none";
  document.getElementById('ParagraphContent' + 460).style.display = "none";
  document.getElementById('ParagraphContent' + 461).style.display = "none";

  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";

}

function SParagraphRes(TheParagraphID) {
  
  document.getElementById('ParagraphContent' + 448).style.display = "none";
  document.getElementById('ParagraphContent' + 449).style.display = "none";

  document.getElementById('ParagraphContent' + TheParagraphID).style.display = "";
}

function SlideToggle(paragraphId) {
  if (jQuery('#ParagraphContent' + paragraphId).css('display')== 'none') {
    jQuery('.SlideParagraph').each( function (idx) {
      if (jQuery('.SlideParagraph').length-1 != idx) {
        jQuery(this).slideUp("slow");
      }
      else {
        jQuery(this).slideUp("slow", function() {
          jQuery('#ParagraphContent' + paragraphId).slideDown("slow");
        });
      }
    });
  }
}
