//Norbert Laposa, 2005
var ie = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
var ie5 = ( ie && /msie 5|msie 6/i.test(navigator.userAgent) );
var opera = /opera/i.test(navigator.userAgent);
var khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
var ns4=(document.layers)? true:false;

function getObject(obj) {
    if (ie) {
        return document.all[obj];
    } else if (ns4) {
        return document.layers[obj];
    } else {
        return document.getElementById(obj);
    }
}

function nOpenWin(src, width,height) {
	/*
	if (window.showModalDialog) {
		nWin = window.showModalDialog(src, "nWin", "dialogWidth:"+width+"px;dialogHeight:"+height+"px");
	} else {
    	nWin = window.open(src,'nWin','left=50,top=50,width='+width+',height='+height+',toolbar=0,directories=0,menubar=0,status=no,resizable=1,location=0,scrollbars=0,dialog=1,modal=1');
	}*/
	
	nWin = window.open(src,'nWin'+unixtime(),'left=50,top=50,width='+width+',height='+height+',toolbar=0,directories=0,menubar=0,status=no,resizable=1,location=0,scrollbars=1,dialog=0,modal=0');
    nWin.focus();
}

function openImg(src) {
    url = '/index.php?request=xhtml.popimage&src=' + src;
    nOpenWin(url, 400, 300);
}

function getReturnData( data , statusCode , statusMessage) {
	 	//AJFORM failed. Submit form normally.
	 	if( statusCode != AJForm.STATUS['SUCCESS'] ) {
	 	 alert( statusMessage );
		 return true;
	 	}
	 	//AJFORM succeeded.
	 	else {
		 alert( "Data:\n" + data );
		 document.getElementById('module-content').innerHTML = data;
		 //window.releaseEvents('Submit')
		 //AJForm.init;
		 document.getElementById('xxxx').setEventListener( 'submit' , getReturnData);
		 //alert(document.getElementById('module-content').innerHTML);
	
	 	}
}


function unixtime() {
	var ut=new Date();
	var h,m,s,ms;
	today = new Date();
	unixborn = new Date(70,0,1);
	unixborn.setHours(15);
	diff = today.getTime();
	diff /= 1000;
	diff = parseInt(diff);
	return diff;
}

function manage(block) {
	el = getObject(block);
	if (el.style.display == 'none') {
		el.style.display='block';
	} else {
		el.style.display='none';
	}
}