function openWindow(url,width,height) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
	window.open(url,'newWin','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}

//alternative popup script
function popUp(strURL,strType,strHeight,strWidth) {
	var strOptions="";
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
	if (strType=="scroll") strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;
	window.open(strURL, 'newWin', strOptions);
}



function toggleRow(DivName){ 
	with (document.getElementById(DivName).style) {
		if (display == "none")	display = ""
		else 					display = "none";
	}
} 

function PopupPic(sPicURL) { 
    window.open( sPicURL, "", "resizable=1,HEIGHT=100,WIDTH=100"); 
 }
 
//	display popup foto at exact size
function display_image(theimage,width,height,fotoTitle,skinPath,webTitle) {
	var height=height+90;
	var joinTitle	=	webTitle+" - "+fotoTitle;
	PreView = window.open("", "FOTO", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width="+width+",height="+height+"");
	PreView.document.open();
	PreView.document.write("<HTML><HEAD>");
	PreView.document.write("<TITLE>"+joinTitle+" - </TITLE>");
	PreView.document.write("<link rel='stylesheet' href='"+skinPath+"style.php' type='text/css'>");
	PreView.document.write("</HEAD>");
	PreView.document.write("<BODY leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' onload='self.focus();'>");
	PreView.document.write("<div id='top_bar' style='height:40px;'>");
	PreView.document.write("<div id='top_bar_slogan'>"+fotoTitle+"</div>");
	PreView.document.write("</div>");
	PreView.document.write("<IMG HSPACE=0 VSPACE=0 " + "SRC='" + theimage + "' alt='"+fotoTitle+"'>");
	//PreView.document.write("<INPUT TYPE='button' VALUE='<?php $contents.= $lang_bt_close[$idioma]; ?>' " + "onClick='window.close()'>");
	PreView.document.write("<div id='top_bar' style='height:30px;'>");
	PreView.document.write("<div id='top_bar_menu'><a href='javascript:self.close();' title='Cerrar'><img src='"+skinPath+"images/icon_closed.gif' border='0'></a></div>");
	PreView.document.write("<div id='top_bar_slogan'>"+webTitle+"</div>");
	PreView.document.write("</div>");
	PreView.document.write("</BODY></HTML>");
	PreView.document.close();
}


function AddBookmark(theUrl, theText){
	alertText_en = "Please Press Ctrl+D to Bookmark this Page";
	alertText_es = "Por Favor Presione Ctrl+D para Recordar esta Página";
	alertText_de = "Bitte, Drücken Sie auf Ctrl+D, um Diese Seite zu Bewahren";
	alertText_fr = "S'il Vous Plaît, Appuyez sur Ctrl+D Pour Conserver cette Page";
	ver = navigator.appName;
	num = parseInt(navigator.appVersion);
	if (ver == "Microsoft Internet Explorer" && num>=4){
		window.external.AddFavorite(theUrl, theText);
	}else{
		window.alert(alertText_es)
	}
}

fadeMeA = new Object();
fadeMeB = new Object();

function fadeMe(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){
        setTimeout("fadeMe("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(fadeMeB[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        fadeMeA[object.sourceIndex]=object;
        fadeMeA[object.sourceIndex]=setTimeout("fadeMe(fadeMeA["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

function validEmail(email) {
	invalidChars = " /:,;"
	if (email == "") {						
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					
		return false
	}
	if (periodPos+3 > email.length)	{		
		return false
	}
	return true
}


//	set active style shhet




//	style cookie check
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
