// XeniaSevillano.com General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/web-works/)


// ***** Popup windows *****

var WINDOW_TOP=10, WINDOW_LEFT=10, SYSTRAY_HEIGHT=64, WINDOW_TITLEBAR=24;

var lastPopup=null;

function openPopup(page,targetWindow,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+",top="+WINDOW_TOP+",left="+WINDOW_LEFT+
    ",status=no,location=no,toolbar=no,menubar=no"+",resizable="+resize+",scrollbars="+scroll;
  lastPopup=window.open(page,targetWindow,options,true);
  lastPopup.window.focus();
  return lastPopup;
}


function showImage(image,title,width,height,alternativePath) {
  if (alternativePath===undefined) alternativePath="";
  totalWidth=width+40;
  if (totalWidth>screen.width-WINDOW_LEFT-8)
    totalWidth=screen.width-WINDOW_LEFT-8;
  totalHeight=height+(title ? 90 : 75);
  if (totalHeight>screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR)
    totalHeight=screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR;
  openPopup("/Image.php?image="+escape(image)+"&path="+escape(alternativePath)+"&title="+escape(title)+"&width="+width,"Images",totalWidth,totalHeight,true,true);
  return false;
}



// ***** Cookies *****

var expirationYears=1, expirationMonths=0, expirationDays=0;

function setCookie(name,value){
 var date=new Date();
 if (expirationYears>0) date.setFullYear(date.getFullYear()+expirationYears);
 if (expirationMonths>0) date.setMonth(date.getMonth()+expirationMonts);
 if (expirationDays>0) date.setDate(date.getDate()+expirationDays);
 document.cookie=name+"="+value+";path=/;expires="+date.toGMTString();
}


function getCookie(name){
 var startIndex,endIndex;

 startIndex=document.cookie.indexOf(name);
 if (startIndex!=-1){
   startIndex=document.cookie.indexOf("=",startIndex)+1;
   endIndex=document.cookie.indexOf(";",startIndex);
   if (endIndex==-1) endIndex=document.cookie.length;
   return document.cookie.substring(startIndex,endIndex);
 }
 else return null;
}



// ***** Style switcher *****

var
 linksArray, stylesArray=new Array(), agent=navigator.userAgent.toUpperCase();

 // getting styles
 if (document.getElementsByTagName && stylesArray.push) {
   linksArray=document.getElementsByTagName("link");
   for(i=0;i<linksArray.length;i++) {
     if (linksArray[i].getAttribute("rel").indexOf("stylesheet")!=-1) {
       stylesArray.push(linksArray[i]);
       // initializacion of the stylesheet disable state by code for workaround some IE bugs
       if (linksArray[i].getAttribute("rel").indexOf("alternate stylesheet")!=-1)
         stylesArray[stylesArray.length-1].disabled=true;
       else stylesArray[stylesArray.length-1].disabled=false;
     }
   }
 }
 if (getCookie("style")=="day") setDayStyle();

function setStyle(name,enabled){
 var i,title;
 for(i=0;i<stylesArray.length;i++) {
   title=stylesArray[i].getAttribute("title");
   if (title==null) title="";
   if (title==name) stylesArray[i].disabled=!enabled;
 } // of for
}


function setNightStyle() {
 setStyle("night",true);
 setStyle("day",false);
 setCookie("style","night");
 return false;
}

function setDayStyle() {
 setStyle("day",true);
 setStyle("night",false);
 setCookie("style","day");
 return false;
}



// ***** Display adjustments *****

var topOffset;

if (garbo) topOffset=45; //=50; forcing scroll bars for garbo, so the bg image is properly center always (also makes adjustments work in IE 5.x)
 else topOffset=150;

function adjustSize() {
 if (document.getElementById) {
   var element=document.getElementById("container");
   if (element && document.documentElement.offsetHeight && element.offsetHeight) {
     documentHeight=document.documentElement.offsetHeight;
     if (element.offsetHeight<documentHeight-topOffset)
        element.style.height=String(documentHeight-topOffset)+'px';
   }
 }
}

window.onresize=adjustSize;
window.onload=adjustSize;



// ***** Misc *****

function maskedEmail(domain,text,name,suffix) {
 var address=name+'@'+domain+'.'+suffix;
 if (text=="") text=address;
 document.write('<a hr'+'ef="ma'+'i'+'lto:'+address+'">'+text+'</a>');
}

function toggleControls(showControls) {
  var video;
  video=document.getElementById("video");
  if (video)
    if (showControls) video.style.height="265px";
    else video.style.height="240px";
}


// XeniaSevillano.com General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/web-works/)

