function CEU() {alert('Coming Soon.'); return false;}
function CEUes() {alert('Viene Pronto.'); return false;}

function inNewWindow(anchor) {window.open(anchor.href,'popUpWin');return false;}
function popUpWindow(URLStr, left, top, width, height) {
  popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top);
  return popUpWin;
}

function Popup(url, windowName, openOptions, blockedFunction, delay) {
	openOptions = {
		 'toolbar' : openOptions['toolbar'] || 'no'
		,'location' : openOptions['location'] || 'no'
		,'directories' : openOptions['directories'] || 'no'
		,'status' : openOptions['status'] || 'no'
		,'menubar' : openOptions['menubar'] || 'no'
		,'scrollbars' : openOptions['scrollbars'] || 'yes'
		,'resizable' : openOptions['resizable'] || 'yes'
		,'width' : openOptions['width'] || '600'
		,'height' : openOptions['height'] || '500'
		,'left' : openOptions['left'] || '15'
		,'top' : openOptions['top'] || '15'
		,'screenX' : openOptions['left'] || '15'
		,'screenY' : openOptions['top'] || '15'
	};
	var optionArray = [];
	for (var i in openOptions) {
		optionArray[optionArray.length] = (i + '=' + openOptions[i]);
	}
	delay = delay || 200;
	this.wasBlocked = false;
	this.blockedFunction = blockedFunction || null;
	if (this.blockedFunction == 'redirect') {
		this.blockedFunction = function() {
			window.location = url;
		}
	}
	this.windowRef = window.open(url, windowName, optionArray.join(','));
	if (this.windowRef == null) {
		this.wasBlocked = true;
		if (this.blockedFunction) this.blockedFunction();
	} else {
		var thisObj = this;
		setTimeout(function(){
			if (thisObj.windowRef == null 
				|| typeof thisObj.windowRef.parent == 'undefined') {
				thisObj.wasBlocked = true;
				if (thisObj.blockedFunction) thisObj.blockedFunction();
			}
		}, delay);
	}
}

function scs(new_css) {
	var d = new Date();
	d.setFullYear(d.getFullYear()+1);
	setCookie('currentStyle',new_css,d,'/',null,0);
	window.location.reload();
	return false;
}

// Cookie API  v1.0.1
// documentation: http://www.dithered.com/javascript/cookies/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code (mostly) by Chris Nott (chris[at]dithered[dot]com)

// Write a cookie value
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;
}

// Retrieve a named cookie value
function getCookie(name) {
   var dc = document.cookie;
  
   // find beginning of cookie value in document.cookie
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);
   if (begin == -1) {
      begin = dc.indexOf(prefix);
      if (begin != 0) return null;
   }
   else begin += 2;
   // find end of cookie value
   var end = document.cookie.indexOf(";", begin);
   if (end == -1) end = dc.length;
   // return cookie value
   return unescape(dc.substring(begin + prefix.length, end));
}
// Delete a named cookie value
function deleteCookie(name, path, domain) {
   var value = getCookie(name);
   if (value != null) document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
   return value;
}
// Fix Netscape 2.x Date bug
function fixDate(date) {
   var workingDate = date;
   var base = new Date(0);
   var skew = base.getTime();
   if (skew > 0) workingDate.setTime(workingDate.getTime() - skew);
   return workingDate;
}
// Test for cookie support
function supportsCookies(rootPath) {
   setCookie('checking_for_cookie_support', 'testing123', '', (rootPath != null ? rootPath : ''));
   if (getCookie('checking_for_cookie_support')) return true;
   else return false;
}

function print_msg() {
	document.write('<div id="pRN"><img src="/images/publication/printer.png" alt="">All pages at AlzOnline are print-friendly.<br><a href="javascript:do_print()">Print this page!</a></div>');
}
function print_msg_es() {
	document.write('<div id="pRN"><img src="/images/publication/printer.png" alt="">Todas las p&aacute;ginas en AlzOnline est&aacute;n listas para imprimir.<br><a href="javascript:do_print()">Imprimir la p&aacute;gina!</a></div>');
}
function do_print() {
	if (window.print) window.print();
}
// handle classNames
function addClassName(el,word) {
	el.className = (el.className)? (el.className + ' ' + word) : word;
}
function removeClassName(el, word) {
	if (!el.className) return;
	var myclass = ' '+el.className+' ';
	myclass = myclass.replace(/\s+/gi,' ');
	el.className = myclass.replace(word,'');
}
function hasClassName(el,word) {
	if (!el.className) return false;
	var myclass = ' '+el.className+' ';
	myclass = myclass.replace(/\s+/gi,' ');
	return (myclass.indexOf(" "+word+" ")>-1);
}

function addLoadEvent(func) {
	$(document).ready(func); // jQuery version ;)
}

function getPosition(o) {
	oTop = o.offsetTop;
	oLeft = o.offsetLeft;
	while (o.offsetParent!=null) {
		oParent = o.offsetParent;
		oTop += oParent.offsetTop;
		oLeft += oParent.offsetLeft;
		o = oParent;
	}
	return {top:oTop, left:oLeft};
}

$(document).ready(function(){ // remove topJump if short content
	$('#topJump').each(function(){
		var pos = getPosition(this);
		if (pos && pos.top && pos.top > 900) {
				this.style.visibility = 'visible';
		}							
	});
});