//open window 
function oWin(url,wid,hei,top,me,to,lo,di,st,sc,re){
	wLeft = (screen.width - wid) / 2;
	nWin = window.open(url,'','width='+wid+',height='+hei+',top='+top+',left='+wLeft+',menubar='+me+',toolbar='+to+',location='+lo+',directories='+di+',status='+st+',scrollbars='+sc+',resizable='+re);
	nWin.focus();
}

function showHideElement(sElement,sAction){
	if(document.getElementById(sElement)==null){
		return false;}
	
	if(sAction==''){
		if(document.getElementById(sElement).style.display=='none'){
			sAction='';}
		else{
			sAction='none';}
		}
	document.getElementById(sElement).style.display = sAction;
	}
	


function oContentWin(URLAdd){
	wid=900;
	url='/osCMS/index.php?obj=content'+URLAdd;
	wLeft = (screen.width - wid) / 2;
	nWin = window.open(url,'','width='+wid+',height=700,top=5,left='+wLeft+',menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1');
	nWin.focus();
}

function oContentWin2(URLAdd){
	wid=750;
	url='/osCMS/index.php?obj=content'+URLAdd;wLeft = (screen.width - wid) / 2;
	nWin = window.open(url,'','width='+wid+',height=600,top=5,left='+wLeft+',menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1');
	nWin.focus();
}

function cWin2(){
	try{
		opener.focus();
		}
	catch (e){}
	self.close();

}

//search for span elements with class osProtectedMail and decrypt the encrypted emailaddress
jQuery(function()
{
	$("span.osProtectedMail").each (
		function()
		{
		sVal = $(this).html();
		sEncrEmail = sVal.substring(7,sVal.length-1);
		sDecrEmail = decryptVal(sEncrEmail);
		$(this).html(sDecrEmail);
		}
	);
});

//decrypt a encrypted value
function decryptVal(sVal)
{
	var iShift=3;
	var sDecrVal="";
	var j=0;
	
	for(i=0;i<sVal.length;i++)
	{
		iUC = sVal.charCodeAt(i)-iShift-j;
		sDecrVal += String.fromCharCode(iUC);
		j++;
		if(j==iShift)
		{
			j=0;
		}
	}
	return sDecrVal;
}

//decrypt a encrypted emailaddress and open the mailwindow (mailto:)
function openDecrMail(sEncryptedVal)
{
	document.location.href=decryptVal(sEncryptedVal);
}
