function echoEMailLink(user,domain,linkText,additionalHTML){
	var email = user + '@' + domain;
	if(!linkText) linkText = email;
	if(!additionalHTML) additionalHTML = '';
	document.write('<a href="mailto:' + email + '" ' + additionalHTML + '>' + linkText + '<\/a>');
}

function echoEMail(user,domain) {
	document.write(user + '@' + domain);
}

function set_return_url(form_name,link) {
	var f = window.document.forms[form_name];
	f.attributes['action'].value = link.attributes['href'].value;
	//alert(f.attributes['action'].value);
	f.submit();
}

function set_form_element(form_name,element_name,element_value) {
  var f = document.forms[form_name];
  f.elements[element_name].value = element_value;
  f.submit();
}

function printPage(){
	var url = window.location.pathname;
	if(window.location.search)
		url += window.location.search + "&";
	else
		url += "?";
	url += "print=1";
	window.open(url,'_blank','width=600,height=600,left=100,top=100,scrollbars = yes,resizable = yes');
}

function urlencode(str) {
	return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}

function sendPage(){
	var url = window.location.href;
	window.open('send.php?page_url=' + urlencode(url),'_blank','width=350,height=400,left=100,top=100,scrollbars = yes,resizable = yes');
}

function captchaDesc() {
	window.open('security-image-explanation.html','_blank','width=320,height=210, scrollbars = yes, resizable = yes ');
	return false;
}

function changePage(page){
	window.location=page;
	return false;
}


function submitSEOForm(formName,link,page,action) {
	var f = document.forms[formName];
	
	if(link.attributes['href'].value && link.attributes['href'].value != '#')
		f.attributes['action'].value = link.attributes['href'].value;
	if(page)
		f.elements['data[page]'].value = page;
	if(action)
		f.elements['action'].value = action;
	f.submit();
	return false;
}

function functionExists(functionName){
	if (typeof functionName == 'string' && eval('typeof ' + functionName) == 'function')
		return true;
	else
		return false;
}

/*
 * Handlers for automated loading
 */ 
 _LOADERS = Array();

function callAllLoaders() {
	var i, loaderFunc;
	for(i=0;i<_LOADERS.length;i++) {
		loaderFunc = _LOADERS[i];
		if(loaderFunc != callAllLoaders) loaderFunc();
	}
}

function appendLoader(loaderFunc) {
	if(window.onload && window.onload != callAllLoaders)
		_LOADERS[_LOADERS.length] = window.onload;

	window.onload = callAllLoaders;

	_LOADERS[_LOADERS.length] = loaderFunc;
}

function incFontSize(){
	changeFontSize(15);	
}

function decFontSize(){
	changeFontSize(-15);	
}

function resetFontSize(){
	setFontSize(100);
}

function changeFontSize(step){
	setFontSize(getFontSize() + step);
}

function setFontSize(value){
	if(value > 200) value = 200;
	if(value < 30) value = 30;
	document.getElementById('content').style.fontSize = value + "%";
	setCookie('ekoFontSize',value,365);
}

function getFontSize(){
	var fontSize = parseInt(document.getElementById('content').style.fontSize);
	if(isNaN(fontSize)) fontSize = 100;	
	return fontSize;
}

function initFontSize(){
	var fontSize = getCookie("ekoFontSize");
	if(isNaN(fontSize) || fontSize <= 0) fontSize = 100;
	setFontSize(fontSize);
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name){
	if (document.cookie.length > 0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function rssOpenBox(){
	document.getElementById('rssBox').style.visibility = 'visible';
}

function rssCloseBox(){
	document.getElementById('rssBox').style.visibility = 'hidden';
}
