// initialise plugins - superfish
/*
jQuery(function(){
	jQuery('ul.sf-Menu-level_1').superfish();
});
*/
var isCalendar = null;

function initFancyBox() {
	var args = initFancyBox.arguments;
	$(document).ready(function() {
		$("a#"+args[0]).fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'hideOnContentClick'	: true,
			'showNavArrows'			: false,
			'showCloseButton'		: true,
			'transitionIn'			: 'elastic',
			'transitionOut'			: 'elastic'			
		});
	});
}
function initFancyBox4Images() {
	var args = initFancyBox4Images.arguments;
	var oNode = null;
	switch (args[1].substr(0,4)) {
		case ('file'):			
			if (args[1].lastIndexOf(".pdf") > 0){
				if ((oNode = document.getElementById(args[0])) != null) {
					for(i=0; i < oNode.childNodes.length; i++) {
						if (oNode.childNodes[i].tagName == 'IMG') {
							oNode.childNodes[i].src = 'xSystem/images/icons/pdf.gif';
						}
					}
				}
				openiFrameFancyBox(args[0]);
				break;
			}
			initFancyBox(args[0]);	
			break;
		case ('http'):
			openiFrameFancyBox(args[0]);
			break;
					//xSystem/images/icons/pdf.gif
	}	
}
function openiFrameFancyBox4Frm() {
	var args = openiFrameFancyBox4Frm.arguments;
	if (args[0] != ''){
		$("#"+args[0]).fancybox({
			'width'				: 500,
			'height'			: 600,		
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'showCloseButton'	: true
		});	
	}

}
function openiFrameFancyBox4Video() {
	var args = openiFrameFancyBox4Video.arguments;
	if (args[0] != ''){
		$("#"+args[0]).fancybox({
			'autoScale'			: true,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'showCloseButton'	: true			
		});	
	}
}
function openiFrameFancyBox() {
	var args = openiFrameFancyBox.arguments;
	var iFrameURL = args[0];
	var iFrameWidth = args[1];
	var iFrameHeight = args[2];
		//	
	if (iFrameURL != ''){
		if (iFrameWidth == null) {
			iFrameWidth = 800;
		}
		if (iFrameHeight == null) {
			iFrameHeight = 600;
		}
		$("#"+args[0]).fancybox({
			'width'				: iFrameWidth,
			'height'			: iFrameHeight,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'showCloseButton'	: true			
		});	
	}
}
function openINlineFancyBox() {
	var args = openINlineFancyBox.arguments;
	
	$("#"+args[0]).fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'onStart' : function() { switchDisplayDIV(args[1],'block')},	
		'onClosed' : function() { switchDisplayDIV(args[1],'none')}
	});	
}
function openFullCalendarFancyBox() {
	var args = openFullCalendarFancyBox.arguments;
	var iFrameWidth = args[1];
	var iFrameHeight = args[2];
	
	if (iFrameWidth == null) {
		iFrameWidth = 960;
	}
	if (iFrameHeight == null) {
		iFrameHeight = 600;
	}

	$("#"+args[0]).fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'width'				: iFrameWidth,
		'height'			: iFrameHeight,
		'onStart' : function() { switchDisplayDIV_Calendar(args[1],'block',args[2])},	
		'onClosed' : function() { switchDisplayDIV(args[1],'none')}
	});	
}

function switchDisplayDIV() {
	var args = switchDisplayDIV.arguments;	
	var oNode = null;
	if ((oNode = document.getElementById(args[0])) != null) {	
		oNode.style.display =args[1];
	}
}
function switchDisplayDIV_Calendar() {
	var args = switchDisplayDIV_Calendar.arguments;	
	var oNode = null;
	if ((oNode = document.getElementById(args[0])) != null) {	
		oNode.style.display =args[1];
	}
	if (isCalendar !=true) {
		initCalendar(args[0],args[2]);
		isCalendar = true;
	}
}
function initCalendar() {
	var args = initCalendar.arguments;		
	$(document).ready(function() {
		$('#'+args[0]).fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,basicWeek,basicDay'
			},
			editable: false,
			weekends: true,
			firstDay: 1,
			events: args[1],
			eventRender		: function(event, element) {                                          
									element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());					  
								}		
			
		});
		
	});	
}
function showCalendar() {
	var args = showCalendar.arguments;	
	
	switchDisplayDIV(args[0],'block');
	initCalendar(args[0]);
}
/* ******************** */
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadassets() { //v3.0
  var d=document; if(d.assets){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadassets.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; alert(d.MM_p[j++].src=a[i]);}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function SOF_HideLayers() { //v6.0
  var i,p,v,obj,args= SOF_HideLayers.arguments;

  for (i=0; i<(args.length); i++)
  	MM_showHideLayers(args[i],'','hide');
}
/* --  */
oSitemapWin = null;
oSearchWin = null;
	//
function popup_sitemapWin()
{
	if (oSitemapWin != null)
		oSitemapWin.close();
	oSitemapWin = window.open('{SITEMAP.href}','_editwin',"width=440,height=500,left=320,top=0,resizable=1, scrollbars=1");
	oSitemapWin.focus();
}
function popup_searchWin(oForm)
{
	if (oSearchWin != null)
		oSearchWin.close();
//	oSearchWin = window.open("search.php?cmd=searchmap",'_searchwin',"width=500,height=500,left=320,top=0,resizable=1, scrollbars=1");
	oSearchWin = window.open("",'_searchwin',"width=500,height=500,left=320,top=0,resizable=1, scrollbars=1");
	oSearchWin.focus();
		//
	oForm.target = '_searchwin';
	oForm.submit();
	return false;
}
