Function.prototype.exec=function(){return this.apply(this,arguments);}
call=function(){var fn=[].shift.call(arguments);fn=(typeof fn=="function")?fn:window[fn];if(typeof fn!="function")return;return fn.apply(null,arguments||[]);}

ajaxPost=function(f,u,c,s,e){$.ajax({cache:false,type:'POST',url:u,data:c+'&'+$(f).serialize(),success:function(r){eval('r='+r);if(r.code==0){(e==null)?ajaxResponseFailure(r.text):e.exec(r);}else{(s==null)?ajaxResponseSuccess(r.text):s.exec(r);}if(typeof r.exec!="undefined"){eval(r.exec)}},error:function(){ajaxResponseFailure('Error during sending data, please try again')}});}
ajaxResponseSuccess=function(s)
{

	$(arguments[1]==undefined?'#ajax-response':'#'+arguments[1]).html('<div class="ajax-ok"><span>'+s+'<\/span><\/div>').fadeIn(300);
}
ajaxResponseFailure=function(s)
{
	$(arguments[1]==undefined?'#ajax-response':'#'+arguments[1]).html('<div class="ajax-err"><span>'+s+'<\/span><\/div>').fadeIn(300);
}

windowOpen=function(u,w,h){var l=(screen.width)?(screen.width-w)/2:0;var t=(screen.height)?(screen.height-h)/2:0;window.open(u,'cms','width='+w+',height='+h+',resizable=no,scrollbars=yes,left='+l+',top='+t);}
charToCode=function(c){return c==0?'@':String.fromCharCode(c);}
languageChange=function(l){document.location.href="/"+l+"/";}
externalLinks=function(){if(!document.getElementsByTagName)return;var anchors=document.getElementsByTagName("a");for(var i=0;i<anchors.length;i++){var anchor=anchors[i];if(anchor.getAttribute("href")&&anchor.getAttribute("rel")=="external")anchor.target="_blank";}}

// old function for compatibility
charcode=function(c){return charToCode(c)}
changeLanguage=function(l){languageChange(l)}
openWindow=function(u,w,h){windowOpen(u,w,h)}
