/* gettext achtige functie
werkt niet in IE, zegt dat TIFLang niet defined is
*/
function _(theString) {

        try {
                if(TIFLang[theString]) {
                        return TIFLang[theString];
                } else {
                        return theString;
                }
        } catch(e) {
                return theString;
        }


}


function getObj(objId)
{
	return document.getElementById(objId);
}

function selectByValue(selectObj, Selectedvalue)
{
	var SelectedOptionIndex;
	
	for (var i = 0; i < selectObj.length; i++)
	{
	if(selectObj.options[i].value == Selectedvalue)
		{ 
			SelectedOptionIndex = i;
			break;
		}
	}
	return SelectedOptionIndex;	
}

function getValueFromSelect(selectObj)
{
	return selectObj[selectObj.selectedIndex].text;
}

function alignCenter()
{
	getObj("middleDiv").style.left = (document.body.clientWidth/2)-330 + 'px'
}

function findPos(dir, obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += dir == 'y' ? obj.offsetLeft : obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += dir == 'y' ? obj.x : obj.y;
	return curleft;
}

function linkCheck(obj)
{
	var checkString = obj.value
	var re = /^(mailto|https|http|ftp)\:\/\//
	
	if (!(re.test(checkString)))
	{
		if (mailCheck(checkString))
		{
			obj.value = 'mailto:' + checkString
		}
		else if (checkString.substr(0,4) == 'ftp.') 
		{
			obj.value = 'ftp://' + checkString
		}
		else if (checkString.substr(0,4) == 'www.')
		{
			obj.value = 'http://' + checkString
		}
	}
}

function mailCheck(string)
{
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/	
	return re.test(string)
}

function replaceNonAlpha(searchStr, replaceStr)
{
	return searchStr.replace(/(\D+|-)/g, replaceStr)
}

function emptyUp(obj, defVal)
{
	if (obj.value == defVal)
	{
		obj.value = ''
	}
}

function isValidDate(day, month, year)
{
	var daysInMonth
	
	day   = parseFloat(day)
	month = parseFloat(month)
	year  = parseFloat(year)
	
	daysInMonth = getLastDayMonth(month, year)
	
	if (day >= 1 && day <= daysInMonth)
	{
		return true
	}
	
	return false
}

function getLastDayMonth(month, year)
{
	var daysInMonth
	month = parseFloat(month)
	year  = parseFloat(year)
	
	if (month == 2)
	{
		daysInMonth = (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 )
	}
	else if (month==4 || month==6 || month==9 || month==11)
	{
		daysInMonth = 30
	}
	else
	{
		daysInMonth = 31
	}
	
	return daysInMonth
}

function mktime (tshour, tsminute, tssecond, tsmonth, tsday, tsyear)
{
	tshour 		= parseFloat(tshour)
	tsminute	= parseFloat(tsminute)
	tssecond	= parseFloat(tssecond)
	tsmonth		= parseFloat(tsmonth)
	tsday		= parseFloat(tsday)
	tsyear		= parseFloat(tsyear)
	
	var tmpDate = new Date( tsyear, (tsmonth-1), tsday, tshour, tsminute, 0 )
	/*RAMON 30-01-2006 genereerd problemen met 27 februari
	tmpDate.setHours(tshour)
	tmpDate.setMinutes(tsminute)
	tmpDate.setSeconds(tssecond)
	tmpDate.setMonth(tsmonth-1)
	tmpDate.setDate(tsday)
	tmpDate.setFullYear(tsyear)
	*/
	

	return tmpDate.getTime()
}


function getCookie(NameOfCookie)
{  
	if (document.cookie.length > 0) 
	{
      	begin = document.cookie.indexOf(NameOfCookie+"="); 
      	
	    if (begin != -1)   
	    {
			begin += NameOfCookie.length+1; 
	    	end = document.cookie.indexOf(";", begin);
	      	
	      	if (end == -1) end = document.cookie.length;
	      	{
	      		return unescape(document.cookie.substring(begin, end));       
	      	}
	  	}
	}
  	
	return null; 
}

function setCookie(NameOfCookie, value, expiredays) 
{
	var ExpireDate = new Date();
  	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function format_sel(v, sel_object) {
  sel_object.focus();
  var str = document.selection.createRange().text;  
  var sel = document.selection.createRange();
  sel.text = "[" + v + "]" + str + "[/" + v + "]";
  return;
}

function format_link(sel_object) {
	sel_object.focus()
	var str = document.selection.createRange().text 
	var sel = document.selection.createRange()
	var weblink = prompt('Vul hier uw link in', '')
	
	if (weblink != '' && weblink != null)
		sel.text = '[link=' + weblink + ']' + str + '[/link]'
}

function removeTags() 
{
	var htmlcode 		= document.selection.createRange().text;
	var searchstring 	= Array('[b]', '[/b]', '[i]', '[/i]', '[ul]', '[/ul]');	
	var replacestring 	= Array('', '', '', '', '', '');	
	
	for (var i = 0; i < searchstring.length; i++)
	{
		htmlcode = replaceString(htmlcode, searchstring[i], replacestring[i]);
	}
	
	var sel = document.selection.createRange();
	sel.text = htmlcode;
}

function replaceString(rstring,text2,by) 
{
    var strLength = rstring.length
    var txtLength = text2.length;
    
    if ((strLength == 0) || (txtLength == 0))
    { 
    	return rstring;
   }

    var i = rstring.indexOf(text2);
    
    if ((!i) && (text2 != rstring.substring(0,txtLength)))
    {
    	 return rstring;
    }
    
    if (i == -1)
    {
    	 return rstring;
    }

    var newstr = rstring.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replaceString(rstring.substring(i+txtLength,strLength),text2,by);

    return newstr;
}


/* check function */

function checkDate(obj, emptyAllow)
{	
	if (obj.value == "" && emptyAllow)
		return obj.value
	
	var timeArray, currentStr
	
	currentStr = replaceNonAlpha(obj.value, '-')
	dateArray  = currentStr.split("-")
	var currentDate = new Date()
	
	if (dateArray.length != 3 || dateArray[0] == '' || dateArray[1] == '' || dateArray[2] == '')
	{
		alert("Er is geen geldige datum opgegeven. Uw huidige datum wordt aangenomen.")
		dateArray[0] = currentDate.getDate()
		dateArray[1] = currentDate.getMonth()
		dateArray[2] = currentDate.getFullYear()
	}
	
	if (dateArray[2] > 2030 || dateArray[2] < 1971)
	{
		alert("Het jaar dat u heeft opgegeven is ongeldig en zal worden teruggezet naar uw huidige jaar.")
		dateArray[2] = currentDate.getFullYear()
	}

	if (dateArray[1] > 12 || dateArray[1] < 1)
	{
		alert("De maand die u heeft opgegeven is ongeldig en zal worden teruggezet naar uw huidige maand.")
		dateArray[1] = currentDate.getMonth()+1
	}
	
	if (!isValidDate(dateArray[0], dateArray[1], dateArray[2]))
	{
		alert("De opgegeven datum is ongeldig en zal worden teruggezet naar uw huidige datum.")
		dateArray[0] = currentDate.getDate()
		dateArray[1] = currentDate.getMonth()
		dateArray[2] = currentDate.getFullYear()
	}
	
	obj.value = dateArray[0] + '-' + dateArray[1] + '-' + dateArray[2]
}

function checkTime(obj, emptyAllow)
{
	if (obj.value == "" && emptyAllow)
		return obj.value
		
	var timeArray, currentStr
	
	currentStr = replaceNonAlpha(obj.value, ':')	
	timeArray  = currentStr.split(":")
	
	if (timeArray.length != 2 || timeArray[0] == '' || timeArray[1] == '')
	{
		alert("Er is geen geldige tijd opgegeven. Uw huidige tijd wordt aangenomen.")
		var currentDate = new Date()
		timeArray[0] = currentDate.getHours()
		timeArray[1] = currentDate.getMinutes()
	}
	
	if (timeArray[0] > 23 || timeArray[1] > 59)
	{
		timeArray[0] = (timeArray[0] > 23) ? 23 : timeArray[0]
		timeArray[1] = (timeArray[1] > 59) ? 59 : timeArray[1]
		
		alert("De waarde die u heeft opgegeven is ongeldig en zal worden teruggezet naar een correcte tijd.")
	}
	
	timeArray[0] = timeArray[0] < 10 ? '0' + parseFloat(timeArray[0]) : timeArray[0]
	timeArray[1] = timeArray[1] < 10 ? '0' + parseFloat(timeArray[1]) : timeArray[1]	    
	 
	obj.value = timeArray[0] + ':' + timeArray[1]
}

function tstmpDate(dateString, timeString) 
{
	var ctime = ''
	dateArray = dateString.split('-')
	timeArray = timeString.split(':')
	
	if (dateArray.length == 3 && timeArray.length == 2)
		ctime = Math.floor(mktime(timeArray[0], timeArray[1], 0, dateArray[1], dateArray[0], dateArray[2]) / 1000)
	
	if (isNaN(ctime))
		return ''
	
	return ctime
}

function debugCss(){
	var newSS;
	newSS=document.getElementById('codepoetry-debug-stylesheet');
	// verberg domMenu
	domMenu = document.getElementById('domMenu_main');
	if(newSS){
		newSS.href=null;
		document.documentElement.childNodes[0].removeChild(newSS);
		domMenu.style.display = 'block';
	} else {
		newSS=document.createElement('link');
		newSS.rel='stylesheet';
		newSS.type='text/css';
		newSS.href='/templates/standard/layout/style/css-debug-2.css';
		newSS.id='codepoetry-debug-stylesheet';
		document.documentElement.childNodes[0].appendChild(newSS);
		domMenu.style.display = 'none';
	}

	return false;
}

function clearString(e, str) {
	if(e.value == str) {
		e.value = '';
	}

}

function newsletter_post(newsitem, el, form_el, soort_el){
	var el       = (typeof el == 'undefined') ? 'email' : el;
	var form_el  = (typeof form_el == 'undefined') ? 'newsletter_post' : form_el;
	var soort_el = (typeof soort_el == 'undefined') ? 'soort' : soort_el;

	var email = getObj(el).value;
	if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1 && email!='uw@emailadres.nl'){
		getObj(soort_el).value = newsitem;		
		getObj(form_el).submit();
	}else { 
		alert('emailadres is niet correct');
	}	
}

function salepoint_submit(){
	//alert(getObj('postcode').value.length);
	
	if(getObj('postcode').value.length!=4 && !getObj('place')){
		alert("De opgegeven postcode is niet correct");	
		
	}else{
		document.salepoint.submit();
	}
}

function tellafriend_submit(){
	if(!mailCheck(getObj('friend_mail').value)){
		alert("Het opgegeven emailadres is niet correct")	
	}else{
		document.tellfriendForm.submit();
	}
}

function submitPoll(itemForm){
	
	getObj(itemForm).submit();
	
}

function submitForm(itemForm){
	
	if(getObj("formMessage")){
		getObj("formMessage").value = FCKeditorAPI.GetInstance('Message').GetHTML();
	}
	
	if(getObj("formMessage").value ==""){
		alert("Commentaar is een vereist veld, u zult deze in moeten vullen voordat u verder kan gaan.");	
	}else{
		getObj(itemForm).submit();
	}
}

// Rollovers bij de cellen van modules
function tableRollOver(field,type,color) {

        if(type==1){
                var bgcolor = color=='' ? '#666666' : color;
                field.style.backgroundColor= bgcolor;
        }else{
                var bgcolor = color=='' ? '#555555' : color;
                field.style.backgroundColor= bgcolor;
        }
}

function stripTags(text){ 
	var re= /<\S[^>]*>/g; 
	text = text.replace(re,""); 
	return text;
} 

function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
/*******************************************************************
 * soopa-rollovers.js * 7/28/2001 * www.youngpup.net
 *******************************************************************/

function ReadMyCookie(cookieName) {
	var theCookie = "" + document.cookie;
	var ind = theCookie.indexOf(cookieName);
	if (ind == -1 || cookieName == "") return "";
	var ind1 = theCookie.indexOf(';',ind);
	if (ind1 == -1) ind1 = theCookie.length;
	return unescape(theCookie.substring(ind+cookieName.length + 1, ind1));
}

function SetMyCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays == null || nDays == 0) nDays = 1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires="+expire.toGMTString() + '; domain=bruist.test;';
}

function makeArray() {
	for (i = 0; i<makeArray.arguments.length; i++)
		this[i + 1] = makeArray.arguments[i];
}

function getDate()
{
var months = new makeArray('January','February','Maart','April','Mei', 'Juni','July','Augustus','September','October','November','December');
var days = new makeArray('Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag', 'Zaterdag','Zondag');
var date = new Date();
var dayOfWeek = date.getDay();
var day = date.getDate();
var month = date.getMonth() + 1;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

return days[dayOfWeek] + " " + day + " " + months[month] + " " + year;
}

/* extra moet ook onLoad ^^^^^^ */

function soopaSetup() {

	var img, sh, sn, sd
	for (var i = 0; (img = document.images[i]); i++) {
		if (img.getAttribute) {

			sn = img.getAttribute("src");
			sh = img.getAttribute("hsrc");
			sd = img.getAttribute("dsrc");

			if (sn != "" && sn != null) {
				img.n = new Image();
				img.n.src = img.src;
			
				if (sh != "" && sh != null) {
					img.h = new Image();
					img.h.src = sh;
					img.onmouseover = soopaSwapOn
					img.onmouseout  = soopaSwapOff
				}

				if (sd != "" && sd != null) {
					img.d = new Image();
					img.d.src = sd;
					img.onmousedown = soopaSwapDown
				}
			}
		}
	}
}

function soopaSwapOn() {
	this.src = this.h.src;
}

function soopaSwapOff() {
	this.src  = this.n.src;
}

function soopaSwapDown() {
	this.src  = this.d.src;
	this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unknown' ? document.onmouseup : "";
	soopaSwapUp.img = this;
	document.onmouseup = soopaSwapUp;
}

function soopaSwapUp() {
	var ths = soopaSwapUp.img;
	ths.src = ths.n.src;
	if (ths.temp) document.onmouseup = ths.temp;
}



/*****************************************************
 * ypSlideOutMenu
 * 3/04/2001
 * 
 * a nice little script to create exclusive, slide-out
 * menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
 * mac and win32. I've got no linux or unix to test on but 
 * it should(?) work... 
 *
 * --youngpup--
 *****************************************************/

ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 150
ypSlideOutMenu.hideDelay = 500
ypSlideOutMenu.minCPUResolution = 1
ypSlideOutMenu.minMenuWidth = 140
ypSlideOutMenu.pageWidth = 775

// constructor
function ypSlideOutMenu(id, dir, left, top, width, height, parentMenu)
{	
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	
	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0
		this.left = left
		this.parentMenu	 = parentMenu

		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this

		var d = document

                var strCSS = '<style type="text/css">';
                strCSS += '#' + this.id + 'Container { visibility:hidden; '
				strCSS += 'left:' + left + 'px; '
				strCSS += 'top:' + top + 'px; '
				strCSS += 'overflow:hidden; z-index:10000; } '
				strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
				strCSS += '}'
                strCSS += '</style>';

                //d.write('<textarea>' + strCSS + '</textarea>')
                d.write(strCSS)
                
		this.load()
	}

}

ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp
	
	//gives menu's a min width of ypSlideOutMenu.minMenuWidth
	
	obj1.style.left = 0 + 'px'
	
	width = obj2.offsetWidth
	height = obj2.offsetHeight
	
	if (width < ypSlideOutMenu.minMenuWidth) {
		obj1.style.width = ypSlideOutMenu.minMenuWidth + 2 + 'px'
		obj2.style.width = ypSlideOutMenu.minMenuWidth + 'px'
	} else {
		obj1.style.width = width + 2 + 'px'
		obj2.style.width = width + 'px'
	}
	
	//takes the new width from the elements
	width = obj2.offsetWidth
	height = obj2.offsetHeight
	
	obj1.style.left = this.left + 'px'
	
	obj1.style.height = height + 'px'	
	this.dim = this.orientation == "h" ? width : height
	
	//places the element inside the page
	if (this.dir == 'down') {
		if (obj1.offsetLeft + width > ypSlideOutMenu.pageWidth) {
			obj1.style.left = ypSlideOutMenu.pageWidth - width + 'px'
		}
	}
	
	if (this.dir == 'right') {
		if (obj1.offsetLeft + width > ypSlideOutMenu.pageWidth) {
			obj1.style.left = obj1.offsetLeft - (getObj(this.parentMenu + 'Container').offsetWidth + obj1.offsetWidth - 10) + 'px'
			this.dir = 'left'
			this.orientation = "h"
			this.dirType = "+"
			this.dim = width
		}
	}
	
	
	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		//this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')");
		//this.menu.onmouseout = new Function("ypSlideOutMenu.hideAll()");

		//set initial state
		this.endSlide()
	}
}
	
ypSlideOutMenu.showMenu = function(id)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	
	if (obj != null) {
		
		if (obj.container) {
			obj.over = true
			
			// close other menus. -- comment out to disable closing other menu's
			for (menu in reg) {
				if (menu != id) {
					ypSlideOutMenu.hide(menu)
				}
			}
			
			// if this menu is scheduled to close, cancel it.
			if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
	
			// if this menu is closed, open it.
			if (!obj.open && !obj.aniTimer) {
				reg[id].startSlide(true)
			}
		}
		
	}
}

ypSlideOutMenu.showMenus = function(menus) 
{
	var menuArray = menus.split(":")
	for (var i = 0; i < menuArray.length; i++) {
		id = menuArray[i]
		
		var reg = ypSlideOutMenu.Registry
		var obj = ypSlideOutMenu.Registry[id]		
		
		if (obj != null) {
			
			if (obj.container) {
				obj.over = true
				
				// close other menus.
				for (menu in reg) {
					if (!valueInArray(menu, menuArray)) {
						ypSlideOutMenu.hide(menu)
					}
				}
				
				// if this menu is scheduled to close, cancel it.
				if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
		
				// if this menu is closed, open it.
				if (!obj.open && !obj.aniTimer) {
					reg[id].startSlide(true)
				}
			}	
		}
		
				
	}
}

ypSlideOutMenu.hideMenu = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = ypSlideOutMenu.Registry[id]
	
	if (obj != null) {
	
		if (obj.container) {
			if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
			obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
		}
		
	}
}

ypSlideOutMenu.hideMenus = function(menus)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var menuArray = menus.split(":")
	for (var i = 0; i < menuArray.length; i++) {
		id = menuArray[i]
		var obj = ypSlideOutMenu.Registry[id]
		
		if (obj != null) {
		
			if (obj.container) {
				if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
				obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
			}
			
		}
		
	}
}

ypSlideOutMenu.hideAll = function()
{
	var reg = ypSlideOutMenu.Registry
	for (menu in reg) {
		ypSlideOutMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}

ypSlideOutMenu.hide = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()	
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}

ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

function valueInArray(cvalue, carray) {
	for (var i = 0; i < carray.length; i++) {
		if (carray[i] == cvalue) {
			return true
		}
	}	
	return false
}

function findPosX(obj) {
    var cl = 0;
    if (obj.offsetParent)
    	cl = obj.offsetLeft + findPosX(obj.offsetParent)
    else if
    	(obj.x) cl += obj.x;
    
    return cl;
}

function findPosY(obj) {
    var cl = 0;
    if (obj.offsetParent)
    	cl = obj.offsetTop + findPosY(obj.offsetParent)
    else if
    	(obj.y) cl += obj.y;
    
    return cl;
}

function getObj(objName) {
	return document.getElementById(objName);	
}


/* custom */

function highlightMenuItems(parentParentMenuItem, parentMenuItem) {
	getObj(parentParentMenuItem).style.color = '#4B1D75'
	if (parentMenuItem != null) {
		getObj(parentMenuItem).style.backgroundColor = '#80579D'
	}
}

function unhighlightMenuItems(parentParentMenuItem, parentMenuItem) {
	getObj(parentParentMenuItem).style.color = ''
	if (parentMenuItem != null) {
		getObj(parentMenuItem).style.backgroundColor = ''
	}
}

menus = new Array
function createmenu(id, level, parentItem, parentMenu) {
	if (level == 'level2') {		
		var leftpos = findPosX(getObj("act" + id)) - findPosX(getObj("content")) + 5;
		var toppos  = findPosY(getObj("act" + id)) + getObj("menubar").offsetHeight - findPosY(getObj("content"))-2
		menus[menus.length] = new ypSlideOutMenu("menu" + id, 'down', leftpos, toppos, null, null);
	} else if (level == 'level3') {		
		var leftpos = findPosX(getObj(parentItem)) - findPosX(getObj("content")) + getObj(parentMenu + 'Container').offsetWidth-5
		var toppos 	= findPosY(getObj(parentItem)) + getObj(parentMenu + "Content").offsetHeight-6
		menus[menus.length] = new ypSlideOutMenu("menu" + id, 'right', leftpos, toppos, null, null, parentMenu);	
	}
}

// events
ypSlideOutMenu.prototype.onactivate		= function() { }
ypSlideOutMenu.prototype.ondeactivate	= function() { }

/** sleight **/
/* ROB 2010: weg, moet optioneel voor IE6 geladen worden, wordt ook al zo gedaan op de meeste pagina's
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent && !window.opera) {
	//document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			var src = img.src;
			img.style.width = img.width + "px";
			img.style.height = img.height + "px";
			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
			img.src = "/templates/standard/common/image/x.gif";
		}
		img.style.visibility = "visible";
	}

}
*/


function submitAboutMe(){
	if(txt = getObj('aboutme')){ txt.value = FCKeditorAPI.GetInstance('Aboutme').GetHTML();}
}

function printfire(){
	
	printfire.args = arguments; 
	//window.console.log(printfire.args);
	
	var doc = (parent) ? parent.document : document; 
	try { 
		/*
		if (typeof doc.createEvent == "function" && typeof dispatchEvent == "function"){*/
			if(arguments.length == 2) {
				arguments[0] = arguments[0] + ": " + arguments[1];
			}
			
			printfire.args = arguments;
			
			window.console.log(printfire.args);
			/*var ev = doc.createEvent("Events");
			if (ev)	{
				
				eval(new Array(
							'  ev.initEvent("printfire", false, true);',
							'  dispatchEvent(ev);'
					      ).join(""));
			} else {
			}
		}*/
	} catch (noConsole) { 
		//alert(arguments[0]); 
	} 
}

function abuse(id) {
	var pars = {action: 'abuse', id: id};
	var ajax = new Ajax.Request('/weblog_Entry', { method: 'post', parameters: pars, onException: this.exception, onComplete: abuseResult });
}

function abuseResult(xhr) {
	if(xhr.responseTEXT == 'OK') {
		Dialog.alert(_('Bericht is gemarkeerd als ongewenst'), {width:300, className: "alphacube"});
	} else {
		Dialog.alert(_('Markeren als ongewenst is mislukt'), {width:300, className: "alphacube"});
	}
}

function debug(str) {
	if(typeof console != 'undefined') {
		console.log(str);
	}
}

var isMobile = function() {
 return (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i));
};

