// JavaScript Document




function removePreloader() { //DOM
		if (document.getElementById){
			document.getElementById('preloader').style.visibility='hidden';
		} else {
			if (document.layers){ //NS4
				document.preloader.visibility = 'hidden';
			} else { //IE4
				document.all.preloader.style.visibility = 'hidden';
			}
		}
}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  }
  else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}



// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000
// Duration of crossfade (seconds)
var crossFadeDuration = 3
// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below
var Links = new Array()
Pic[0] = '/images/sponsors/bw/casa_de_ceramica.gif';
Pic[1] = '/images/sponsors/bw/cintron.gif';
Pic[2] = '/images/sponsors/bw/dub.gif';
Pic[3] = '/images/sponsors/bw/polanti.gif';
Links[0] = 'http://www.alfonsosgomez.com/contact/advertise.asp';
Links[1] = 'http://www.alfonsosgomez.com/contact/advertise.asp';
Links[2] = 'http://www.alfonsosgomez.com/contact/advertise.asp';
Links[3] = 'http://www.alfonsosgomez.com/contact/advertise.asp';
var t
var j = 0
var currentIndex = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
    preLoad[i] = new Image()
    preLoad[i].src = Pic[i]
}

/*
	can be envoked onLoad   <body onload='runSlideShow()'>
	image tag should look like <img src='/images/E/E602312.jpg' name='SlideShow' width=320 height=237>
*/
function runSlideShow(){
	currentIndex = j
	if (document.all){
      document.images.SlideShow.style.filter='blendTrans(duration=2)'
      document.images.SlideShow.style.filter='blendTrans(duration=crossFadeDuration)'
      document.images.SlideShow.filters.blendTrans.Apply()      
    }
    document.images.SlideShow.src = preLoad[j].src
    if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
    }
    j = j + 1

    if (j > (p-1)) j=0
        t = setTimeout('runSlideShow()', slideShowSpeed)
}
function gotoLink(){
	//location.href = Links[currentIndex];
	URL = Links[currentIndex];

	var windowVar;
	var leftPos, topPos, wdwWidth, wdwHeight;
	wdwWidth = "760";
	wdwHeight = "450";
	leftPos = screen.width/2 - wdwWidth/2;
	topPos = screen.height/2 - wdwHeight/2 - 60;

	//var windowAttributes = "width=" + wdwWidth + ",height=" + wdwHeight + ",toolbar=0,menubar=0,scrollbars=1,resizable=1,status=0,location=0,directories=0,copyhistory=0,left=" + leftPos + ",top=" + topPos + ""
	//windowVar = window.open(URL, "lapa_RW", windowAttributes);
	location.href=URL;
}


function photo_zoom(imgName) {
	document.getElementById('photo_zoomed').innerHTML = "(<a href='" + imgName + "' target=_blank>view full size</a>)<br><br>" + "<img src='" + imgName + "' width=760>";
}


function video_show(videoPath) {
//	document.getElementById('photo_zoomed').innerHTML = "<a href=#>img src='" + imgName + "'>";
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}

function P7_hideDiv(evt) { //v1.3 by PVII
 var b,relT,mT=false; 
 if(document.layers){b=evt.target;if(b.p7aHide){
  b.visibility="hidden";}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){b=event.srcElement;
  while(b!=null){if(b.tagName=="DIV" && b.p7ahD){mT=true;break;}b=b.parentElement;}
  if(!b.contains(event.toElement)){b.style.visibility="hidden";}
 }else if(document.getElementById){b=evt.currentTarget;relT=evt.relatedTarget;
  while(relT!=null){if(b==relT){mT=true;break;}
  relT=relT.parentNode;}if(!mT){b.style.visibility="hidden";}}
}

function P7_autoHide() { //v1.3 by PVII
 var i,g,args=P7_autoHide.arguments;
 for(i=0;i<args.length;i++){if((g=MM_findObj(args[i]))!=null){
  g.p7aHide=true;if(document.layers){
  g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideDiv;g.p7ahD=true;}}
}


var popUpWin=0;
function MM_openwindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function showDiv(divId) {
	divStyle = document.getElementById(divId).style;
	divStyle.display = "block";
}

function hideDiv(divId) {
	divStyle = document.getElementById(divId).style;
	divStyle.display = "none";
}

function setContents(cID,cHTML) {
	var tmpCnt = document.getElementById(cID);  
	if (cHTML == '') {
		tmpCnt.innerHTML = '&nbsp;';
	} else {
		tmpCnt.innerHTML = cHTML;
	}

}



function toggleDisplay(divId) {
	divStyle = document.getElementById(divId).style;
	if ( (divStyle.display == "block") || (divStyle.display == "") ) {
		divStyle.display = "none";
	} else {
		divStyle.display = "block";
	}
}


function loadMenus() {
	P7_autoHide('menu_news','menu_media','menu_bio','menu_account','menu_contact');
}

window.onload = loadMenus;

