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 flvFPW1(){//v1.44
// Copyright 2002-2004, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;v11=new Array("width,left,"+v4,"height,top,"+v5);for (i=0;i<v11.length;i++){v12=v11[i].split(",");l_iTarget=parseInt(v12[2]);if (l_iTarget>1||v1[2].indexOf("%")>-1){v13=eval("screen."+v12[0]);for (v6=0;v6<v2.length;v6++){v10=v2[v6].split("=");if (v10[0]==v12[0]){v14=parseInt(v10[1]);if (v10[1].indexOf("%")>-1){v14=(v14/100)*v13;v2[v6]=v12[0]+"="+v14;}}if (v10[0]==v12[1]){v16=parseInt(v10[1]);v15=v6;}}if (l_iTarget==2){v7=(v13-v14)/2;v15=v2.length;}else if (l_iTarget==3){v7=v13-v14-v16;}v2[v15]=v12[1]+"="+v7;}}v8=v2.join(",");v9=window.open(v1[0],v1[1],v8);if (v3){v9.focus();}document.MM_returnValue=false;return v9;}

function validarComentario(){
	var rgEmail = new RegExp("^[a-z\d\.\-_]+@[a-z\d\.\-_]{2,}\.[a-z]{2,10}$");
	if (MM_findObj('comentario_Autor').value == ''){
		alert("Introduce tu nombre\.");
		MM_findObj('comentario_Autor').focus();
		return false;
	}
	if (!rgEmail.test(MM_findObj('comentario_Autor_Email').value)){
		alert("Introduce tu email\.");
		MM_findObj('comentario_Autor_Email').focus();
		return false;
	}
	if (MM_findObj('comentario_Comentario').value == '' || MM_findObj('comentario_Comentario').value.length <= 10){
		alert("Introduce un comentario\.");
		MM_findObj('comentario_Comentario').focus();
		return false;
	}
	
	else {
		if (MM_findObj('recordar1').checked) {
			rememberMe();
		}
		MM_findObj('formcomentario').submit();
	}
}

function validarContactar(){
	var rgEmail = new RegExp("^[a-z\d\.\-_]+@[a-z\d\.\-_]{2,}\.[a-z]{2,10}$");
	if (MM_findObj('Nombre').value == ''){
		alert("Introduce tu nombre\.");
		MM_findObj('Nombre').focus();
		return false;
	}
	if (!rgEmail.test(MM_findObj('Email').value)){
		alert("Introduce tu email\.");
		MM_findObj('Email').focus();
		return false;
	}
	if (MM_findObj('Asunto').value == ''){
		alert("Introduce el asunto\.");
		MM_findObj('Asunto').focus();
		return false;
	}
	if (MM_findObj('Comentario').value == '' || MM_findObj('Comentario').value.length <= 10){
		alert("Introduce un comentario\.");
		MM_findObj('Comentario').focus();
		return false;
	}
	
	else MM_findObj('formcontactar').submit();
}

function marcaOpcion(checkbox){
	var checkbox = document.getElementById(checkbox);
	var boton = document.getElementById('botlistcorr');
	if(document.getElementById){
		if(checkbox.checked){
			if(checkbox.value=='apuntarse'){
				boton.value = "Apuntarse";
			}
			else {
				boton.value= "Borrarse";
			}
		}
	}
}
function toggleDiv(divName) {
    var thisDiv = document.getElementById(divName);
	if(document.getElementById){
    if (thisDiv) thisDiv.style.display = !thisDiv.offsetWidth ? "block" :"none";
    else alert("Error: Could not locate div with id: " + divName);
	}
}
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);
var HOST = 'www.sabuko.com';
var now = new Date();

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "/") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "/") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe () {
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie('comNomb', MM_findObj('comentario_Autor').value, now, '/', HOST, '');
    setCookie('comMail', MM_findObj('comentario_Autor_Email').value, now, '/', HOST, '');
    setCookie('comWeb', MM_findObj('comentario_Autor_Web').value, now, '/', HOST, '');
}

function forgetMe () {
    deleteCookie('comNomb', '/', HOST);
    deleteCookie('comMail', '/', HOST);
    deleteCookie('comWeb', '/', HOST);
    MM_findObj('comentario_Autor').value = '';
    MM_findObj('comentario_Autor_Email').value = '';
    MM_findObj('comentario_Autor_Web').value = '';
}

function targetEnlaces() {
if(document.targetform){
		if (document.getElementById('targetnew').checked) { 
			target = "_blank";
			fixDate(now);
			now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
			setCookie('enlaTarg', 'checked', now, '/', HOST, '');
		}
		else { 
			target = "_self";
			deleteCookie('enlaTarg', '/', HOST);
		}
		var valida = /www.sabuko.com|sabuko.net/gi;
		for(var n=0;n<document.links.length;n++)
		{
			var testear  = new String ( document.links[n]) ;
			if (testear.match(valida)==null ) {
							document.links[n].target = target;
			}
		}
}
} 
window.onload = targetEnlaces;
