var glob_error=false;
var lastKnownFieldValue="";
var issetPopupPos=false;

function get_Obj(obj)
{
	var subm=document.getElementById(obj);
	
	return subm;
}
function AreYouSure(Query)
{
	switch(Query) {
		case 1:
			confirmMsg="Sind sie sicher, dass sie den Datensatz entfernen wollen?";
			break;
		case 2:
			confirmMsg="Sind sie sicher, dass sie alle Datensätze entfernen wollen?";
			break;
		case 3:
			confirmMsg="Sind sie sicher, dass sie das Bild entfernen wollen?";
			break;
		case 4:
			confirmMsg="Sind sie sicher, dass sie diesen Eintrag löschen möchten?";
			break;
		case 6:
			confirmMsg="Sind sie sicher, dass sie diesen Eintrag verschieben möchten?";
			break;
	}
   	return confirm(confirmMsg);
}
function ConfirmMsg(Query, URL)
{
   	if(AreYouSure(Query)) window.location.href = URL;
}
function ConfirmTextMsg(Text, URL, win)
{
	win=win==null ? window : win;
   	if(confirm(Text)) win.location.href = URL;
}

function hidebox(box)
{
	var obj=getObj(box);
	if(obj!=null)
	{
		obj.style.visibility="hidden";
		//obj.style.display="none";
	}
}
function showbox(box)
{
	getObj(box).style.visibility="visible";
	//getObj(box).style.display="inline";
}
function showhidebox(box)
{
	var obj=getObj(box);
	var obj_=getObj(box+'_');
	if(obj!=null)
	{
		loadContentIFnc('/inc/load/box_state.php/box,'+box+'/state,'+(obj.style.display=='none' ? 1 : 0),'showhidebox_');
		if(obj.style.display=='none')
		{
			obj.style.display='block';
			obj_.style.display='none';
		}
		else
		{
			obj.style.display='none';
			obj_.style.display='block';
		}
	}
}
function showhidebox_(xml,ret_text,readyState)
{
	if(readyState==4)
	{
		if(ret_text!='')
		{
			alert(ret_text);
		}
	}
}

function set_value(dest,value)
{
	get_Obj(dest).value=value;
}

function edit_helptext(obj,text,color1,color2,mode)
{
	if(mode=='IN')
	{
		if(obj.value==text)
		{
			obj.value='';
		}
		obj.style.color=color1;
	}
	else if(mode=='OUT')
	{
		if(obj.value=='')
		{
			obj.value=text;
			obj.style.color=color2;
		}
	}
}

function redirection(URL,time) 
{
	window.setTimeout("do_redirection('"+URL+"')", time);
}

function do_redirection(URL) 
{ 
   location.href=URL; 
}

var currPopup=new Array();

function hidePopup(objDiv)
{
	if(objDiv==null)
	{
		if(currPopup!="")
		{
			currPopup.style.display='none';
		}
		//objDiv=currPopup;
	}
	else if(objDiv!="")
	{
		objDiv.style.display='none';	
	}
}

function showDynBox(divId,x_,y_)
{
	var objDiv=getObj(divId);
	if(window.event!=null)
	{
		x_=x_==null ? 0 : x_;
		y_=y_==null ? 0 : y_;
		var maus=mausPos(window.event);
		objDiv.style.position='absolute';
		objDiv.style.display='inline';
		var objWidth=objDiv.offsetWidth;
		var objHeight=objDiv.offsetHeight;
		if(maus[0]+objWidth-document.documentElement.scrollLeft > document.documentElement.clientWidth)
			maus[0]=maus[0]-objWidth-x_-4;
		if(maus[1]+objHeight-document.documentElement.scrollTop > document.documentElement.clientHeight)
			maus[1]=maus[1]-objHeight-y_;
			
		objDiv.style.top=maus[1]+y_+'px';
		objDiv.style.left=maus[0]+x_+'px';
		currPopup=objDiv;
	}
	else
	{
		objDiv.style.display='inline';
	}
}

function showFixBox(divId)
{
	var objDiv=getObj(divId);
	objDiv.style.display='inline';
}

function showContentBox(divId,DontSetPos)
{
	var objDiv=getObj(divId);
	var objDivFrm=getObj(divId+"_iframe");
	var boxHeight=objDivFrm!=null ? objDivFrm.clientHeight+15+20 : 0;
	objDiv.style.display='inline';
	if(!DontSetPos && !issetPopupPos)
	{
		objDiv.style.top=(document.documentElement.scrollTop>0 ? 50+document.documentElement.scrollTop : 150)+'px';
		objDiv.style.left=(100+document.documentElement.scrollLeft)+'px';
	}
	ob_pos_top=objPosTop(objDiv);
	if(ob_pos_top<document.documentElement.scrollTop && document.documentElement.scrollTop > 0)
	{
		objDiv.style.top=document.documentElement.scrollTop+20;
	}
	else if(ob_pos_top-document.documentElement.scrollTop+boxHeight>document.documentElement.clientHeight)
	{
		objDiv.style.top=document.documentElement.scrollTop+20;		 
	}
	issetPopupPos=true;
}

function hideBox(divId)
{
	var objDiv=getObj(divId);
	objDiv.style.display='none';
}

function divPopup(divId,pid)
{
	pid=pid!=null ? pid : '1';
	var objDiv=getObj(divId);
	if(currPopup!=null && currPopup!=divId)// && pid=='1'
	{
		hidePopup(currPopup);	
	}
	if(pid=='1' && window.event!=null)
	{
		var maus=mausPos(window.event);
		objDiv.style.position='absolute';
		objDiv.style.display='inline';		
		
		var objWidth=objDiv.offsetWidth;
		var objHeight=objDiv.offsetHeight;
		if(maus[0]+objWidth-document.documentElement.scrollLeft > document.documentElement.clientWidth)//document.body.clientWidth
			maus[0]=maus[0]-objWidth;
		if(maus[1]+objHeight-document.documentElement.scrollTop > document.documentElement.clientHeight)//document.body.clientHeight
			maus[1]=maus[1]-objHeight;
			
		objDiv.style.top=maus[1]+'px';
		objDiv.style.left=maus[0]+'px';
			
		currPopup=objDiv;
	}
	else
	{
		objDiv.style.display='inline';
	}
}


function divPopupSubHide(objDiv)
{
	objDiv.style.display='none';
}
function divPopupSub(divId,pid)
{
	var objDiv=getObj(divId);
	objDiv.style.display='inline';
	var objWidth=objDiv.offsetWidth;
	var objHeight=objDiv.offsetHeight;
	
	var p_objDiv=getObj(pid);	
	var p_objWidth=p_objDiv.offsetWidth;
	var p_objHeight=p_objDiv.offsetHeight;
	var objLeft_=p_objWidth-5;
	var objTop_=p_objHeight-30;
	
	if(p_objDiv.offsetLeft+p_objWidth+objWidth-document.documentElement.scrollLeft > document.documentElement.clientWidth)
		objLeft_=5-objWidth;
	if(p_objDiv.offsetTop+p_objHeight+objHeight-document.documentElement.scrollTop > document.documentElement.clientHeight)
		objTop_=-objHeight+p_objHeight;
	
	objDiv.style.left=objLeft_+'px';
	objDiv.style.top=objTop_+'px';
}
			
function strtoint(str)
{

	if(str.indexOf(".")>1 && str.indexOf(",")<1)
	{
		if(str.length-str.indexOf(".")<=3 && str.indexOf(".")==str.lastIndexOf("."))
		{
			str=str.replace(".",",");	
		}
	}	
	str=str.replace(/[.]+/g,'');
	var i=parseFloat(str.replace(',','.'));
	return str=="" || str=="-" ? 0 : i;
}
function inttostr(i)
{			
	var str=i.toString().replace(/[.]+/g,',');
	return str;
}

function isInt(eingabe)
{
	var num_error = false;
	if(eingabe)
	{
		var eingabe_str = eingabe;
		var num = eingabe_str.match(/[^0-9,\.]/gi);
		var dot = eingabe_str.match(/\./g);
		var com = eingabe_str.match(/,/g);
		if (num!=null)
		{
			num_error = true;
		}
		else if ((dot!=null)&&(dot.length>1))
		{
			num_error = true;
		}
		else if ((com!=null)&&(com.length>1))
		{
			num_error = true;
		}
		else if ((com!=null)&&(dot!=null))
		{
			num_error = true;
		}
	}
	return !num_error;
}			

function int_only(feld)
{
	if(feld.value=="")
	{
		glob_error=true;
		return;
	}
	if(isNaN(feld.value.replace(".","")))
	{
		glob_error=true;
		alert("Bitte nur ganze Zahlen eingaben (kein Komma oder andere Zeichen)!");
		feld.select();
		feld.focus();
		return;
	}
	glob_error=false;
}

function num_only(feld)
{
	if(feld.value == "")
	{
		//glob_error=true;
		return;
	}
	if(glob_error)
	{
		//alert("Sie haben Fehler in den numerischen Feldern!");
		return;	
	}
	var v=feld.value.replace(/[.]+/g,'');
	if(!isInt(v))
	{
		glob_error=true;
		if(v.replace(',', '.').substr(v.length-1,v.length)!='.')
		{
			alert("Bitte nur Zahlen eingeben!");
			feld.value=lastKnownFieldValue;
			glob_error=false;
			feld.select();
			feld.focus();
		}
		return;
	}
	if(v==feld.value)
	{
		lastKnownFieldValue=feld.value;
		glob_error=false;
	}
}

function number_format (number, decimals, dec_point, thousands_sep)
{
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if (thousands_sep != null && thousands_sep != "")
  {
	for (i = integer.length - 3; i > 0; i -= 3)
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}

function formatNumber(obj,KommaStellen)
{
	if(glob_error)
	{
		//alert("Sie haben Fehler in den numerischen Feldern!");
		//obj.select();
		//obj.focus();
		return;
	}
	var value=obj.value;
	if(value!="")
	{
		/*if(value.indexOf(".")<value.length-KommaStellen-1)
		{
			value=value.replace(".","");			
		}*/
		obj.value=number_format(strtoint(value).toFixed(KommaStellen),KommaStellen,',','.');//.toFixed(KommaStellen));
	}
}

function mausPos(e)
{
	var x=e.pageX || window.event.x+document.documentElement.scrollLeft;
	var y=e.pageY || window.event.y+document.documentElement.scrollTop;
	var size=new Array();
	size[0]=x;
	size[1]=y;
	return size;
}

function resizeWindow(x,y)
{
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		window.resizeTo(x+10,y+29);
	}
	else
	{
		if(navigator.appVersion.substring(0,1) < "5")
		{
			window.resizeTo(x,y);
		}
		else
		{
			window.resizeTo(x+8,y+28);
		}
	}
}

function addScreenRule(selector, declarations)
{
	// Kennt der Browser document.styleSheets und existiert bereits eines?
	if (!document.styleSheets || document.styleSheets.length == 0)
	{
		return false;
	}
	var stylesheet = document.styleSheets[0];
	if (stylesheet.insertRule)
	{
		new_rule_number = stylesheet.insertRule(selector + " { " + declarations + " }",
		stylesheet.cssRules.length);
		if (stylesheet.cssRules[new_rule_number].cssText.length > 0) {
			return true;
		}
	}
	else if (stylesheet.addRule)
	{
		// MSIE kennt addRule statt insertRule
		stylesheet.addRule(selector, declarations);
		return true;
	}
	// kein Erfolg
	return false;
}

function objPosTop(obj)
{
	var pos_ =0;
	if(typeof(obj.offsetLeft) != 'undefined')
	{
	   while (obj)
	   {
		   pos_ += obj.offsetTop;
		   obj = obj.offsetParent;
	   }
	}
	else
	{
	   pos_.top = obj.top ;
	}
	return pos_;
}

function objPosLeft(obj)
{
	var pos_ =0;
	if(typeof(obj.offsetLeft) != 'undefined')
	{
	   while (obj)
	   {
		   pos_ += obj.offsetLeft;
		   obj = obj.offsetParent;
	   }
	}
	else
	{
	   pos_.top = obj.left ;
	}
	return pos_;
}

/* [TABLE] */

function table_trIndexByObj(trObj)
{
	var table=trObj.parentNode.parentNode.id;
	objTable=document.getElementById(table);
	for(i=0;i<objTable.rows.length;i++)
	{
		if(objTable.rows[i].id==trObj.id)
		{
			return i;
		}
	}
	return -1;
}
function table_trIndexById(table,trId)
{
	objTable=document.getElementById(table);
	for(i=0;i<objTable.rows.length;i++)
	{
		if(objTable.rows[i].id==trId)
		{
			return i;
		}
	}
	return -1;
}
function table_delTrByObj(trObj)
{
	var table=trObj.parentNode.parentNode;
	var trIndex=table_trIndexByObj(trObj);
	table.deleteRow(trIndex);
}
function table_delTrById(table,trIndex)
{
	var table=getObj(table);
	table.deleteRow(trIndex);
}
function table_addTr(tableId,trIndex,trObj)
{
	var table=getObj(tableId);
	//table.insertRow(trIndex);
	table.appendChild(trObj);
	for(i=0;i<trObj.cells.length;i++)
	{
		//table.rows[trIndex].insertCell(i);
		//table.rows[trIndex].cells[i].innerHTML=tr.cells[i].innerHTML;
		table.rows[trIndex].appendChild(trObj.cells[i]);
	}
}
function table_addTrByArr(tableId,trIndex,ArrTr)
{
	var table=getObj(tableId);
	table.insertRow(trIndex);
	for(i=0;i<ArrTr.length;i++)
	{
		table.rows[trIndex].insertCell(i);			
		table.rows[trIndex].cells[i].innerHTML=ArrTr[i];
	}
}

/* [/TABLE] */

function showDivPopup(id,url,DontSetPos)
{
	getObj(id+"_pleaseWait").style.display="inline";
	getObj(id+"_frm").style.display="none";
	showContentBox(id,DontSetPos);
	eval(id+"_iframe").location.href=url;
}


function selectIndexByValue(objSel,value)
{
	for(i=0;i<objSel.options.length;i++)
	{
		if(objSel.options[i].value==value)
		{
			objSel.selectedIndex=i;
			return i;
		}
	}
	return -1;
}


function setRowState(obj,clsId)
{
	var classes=new Array();
	classes[0]="itemList";
	classes[1]="itemList_active";
	classes[2]="itemList_active2";
	classes[3]="itemList_inactive";
	obj.className=clsId!=null ? classes[clsId] : (obj.className==classes[0] ? classes[1] : classes[0]);
}

function deleteDiv(id,group)
{
	getObj(group).removeChild(getObj(id));
}

function sprintf() {
 if( sprintf.arguments.length < 2 ) {
  return;
 }
 
 var data = sprintf.arguments[ 0 ];
 
 for( var k=1; k<sprintf.arguments.length; ++k ) {
 
  switch( typeof( sprintf.arguments[ k ] ) )
  {
   case 'string':
    data = data.replace( /%s/, sprintf.arguments[ k ] );
    break;
   case 'number':
    data = data.replace( /%d/, sprintf.arguments[ k ] );
    break;
   case 'boolean':
    data = data.replace( /%b/, sprintf.arguments[ k ] ? 'true' : 'false' );
    break;
   default:
    /// function | object | undefined
    break;
  }
 }
 return( data );
}

var msg_classname_='';

function msg(text,title,btnOk,classname)
{
	if(classname!=undefined)
	{
		msg_classname_=classname;	
	}
	else
	{
		classname=msg_classname_;
	}
	if(title!='')
	{
		text='<h1 style="text-align:center">'+title+'</h1>'+text;
	}
	if(classname!='undefined')
	{
		getObj("modDivAlert").className=classname;
	}
	//text='<div style="float:right;width:73px;"><a href="javascript:hidemsg();"><img src="/img/buttons/ico_close.png" alt="Fenster schließen" style="margin-right:1px;" /></a></div>'+text;
	getObj("modDivAlert_msg").innerHTML=text;
	//getObj("modDivAlert").style.marginTop='-'+getObj("modDivAlert").style.height;
	if(btnOk!='' && btnOk!=undefined)
	{
		getObj("modDivAlert_btn").innerHTML=(btnOk!='hide' ? '<input type="button" value="'+(btnOk=='close' ? 'schlie&szlig;en' : 'ok')+'" class="'+(btnOk=='ok' ? 'btn_ok' : 'button1')+'" id="btn_ok" onclick="'+(btnOk!='' && btnOk!='close' ? btnOk+';' : 'hidemsg();')+'" />' : '');
	}
	else
	{
		getObj("modDivAlert_btn").innerHTML='';	
	}
	showbox("pageDarkener");
	showbox("modDivAlert");
}
function hidemsg()
{
	getObj("modDivAlert_msg").innerHTML='';
	hidebox("pageDarkener");
	hidebox("modDivAlert");
}

function getAnker()
{	
	var url=document.URL;
	return url.indexOf("#")>0 ? url.substring(url.indexOf("#")+1) : "";
}

function getOS()
{
	var browser = navigator.userAgent;
	if (browser.indexOf("Win98") != -1 || browser.indexOf("Windows 98") != -1)
		os = "Microsoft Windows 98";
	else if (browser.indexOf("Win95") != -1 || browser.indexOf("Windows 95") != -1)
		os = "Microsoft Windows 95";
	else if (browser.indexOf("Win 9x 4.90") != -1)
		os = "Microsoft Windows ME";
	else if (browser.indexOf("WinNT 5.0") != -1 || browser.indexOf("Windows NT 5.0") != -1)
		os = "Microsoft Windows 2000";
	else if (browser.indexOf("WinNT 5.1") != -1 || browser.indexOf("Windows NT 5.1") != -1)
		os = "Microsoft Windows XP";
	else if (browser.indexOf("WinNT 5.2") != -1 || browser.indexOf("Windows NT 5.2") != -1)
		os = "Microsoft Windows Server 2003";
	else if (browser.indexOf("WinNT 6.0") != -1 || browser.indexOf("Windows NT 6.0") != -1)
		os = "Microsoft Windows Vista";
	else if (browser.indexOf("Linux") != -1)
	{
		if (browser.indexOf("Debian") != -1)
			os = "Linux Debian";
		else if (browser.indexOf("Ubuntu") != -1)
			os = "Linux Ubuntu";
		else if (browser.indexOf("Mandriva") != -1)
			os = "Linux Mandriva";
		else if (browser.indexOf("SUSE") != -1)
			os = "Linux SUSE";
		else
			os = "Linux";
	}
	else if (browser.indexOf("Unix") != -1)
		os = "Unix";
	else if (browser.indexOf("OS X") != -1)
		os = "Mac OS X";
	else if (browser.indexOf("OS/2") != -1)
		os = "OS/2";
	else if (browser.indexOf("SymbianOS") != -1)
		os = "Symbian OS";
	else if (browser.indexOf("FreeBSD") != -1)
		os = "FreeBSD";
	if (browser.indexOf("Media Center ") != -1)
		os = os + " (Media Center PC)";	
	return os;
}

function getBrowsername()
{
	var navName = navigator.appName ;
	var brVer = navigator.userAgent;
	var brNum;
	var reg = new RegExp('/');
	
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		brNum = brVer.substr(brVer.indexOf('MSIE'),8);
		brNum = brNum.substr(brNum.indexOf(' ')+1);
	}
	else
	{
	   var brVerId = brVer.search(reg);
	   brNum = brVer.substring(brVerId+1);
	}
	return navName+" "+brNum;
}

function reloadSite(parent)
{
	if(parent!='undefined' && parent!=null)
	{
		parent.window.location.href=parent.window.location.href;
	}
	else
	{
		window.location.href=window.location.href;
	}
}

function evalScript(scripts)
{
	try
	{
		if(scripts != '') 
		{
			var script = "";
			scripts = scripts.replace(/<!--/gi,'');
			scripts = scripts.replace(/-->/gi,'');
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
									   if (scripts !== null) script += arguments[1] + '\n';
										return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{
		//alert(e+'\n\nFehler in folgendem Script: '+scripts);
		error_msg(e+'\n\nFehler in folgendem Script: '+scripts);
	}
}

function error_msg(txt)
{
	msg('<h1>Ooops...</h1>'+(txt!='undefined' ? txt : 'Bei deiner Anfrage ist ein Fehler aufgetreten.<br /><br />Bitte versuche es in ein paar Minuten noch einmal'),'');
	//msg("Es ist ein Fehler aufgetreten.<br /><br />Bitte versuche es erneut.","Fehler","close");	
}


var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};




/* [TABS] */
var tab_groups=new Array();
var tabs=new Array();
var tab_indices=new Array();
var tab_urls=new Array();

function addTab(group,ind)
{
	if(tabs[group]==undefined)
	{
		tabs[group]=new Array();
		tab_groups[tab_groups.length]=group;
		tab_indices[group]=new Array();
	}
	ind=ind==undefined ? tabs[group].length : ind;
	tab_indices[group][tab_indices[group].length]=ind;
	tabs[group][ind]=ind;
}
function addDynTab(group,ind,url)
{
	if(tabs[group]==undefined)
	{
		tabs[group]=new Array();
		tab_groups[tab_groups.length]=group;
		tab_indices[group]=new Array();
		tab_urls[group]=new Array();
	}
	ind=ind==undefined ? tabs[group].length : ind;
	tab_indices[group][tab_indices[group].length]=ind;
	tabs[group][ind]=ind;
	tab_urls[group][ind]=url;
}

function showTab(id,group)
{
	if(group==undefined)
	{
		group=tab_groups[0];
	}
	var tabList=tabs[group];
	for(i=0;i<tab_indices[group].length;i++)
	{
		getObj(group+"_"+tab_indices[group][i]).className="";
		getObj(group+"_"+tab_indices[group][i]+"_content").className="tab_content";
	}
	getObj(group+"_"+id).className="active";
	getObj(group+"_"+id+"_content").className="tab_content_show";
}

function showDynTab(id,group)
{
	if(group==undefined)
	{
		group=tab_groups[0];
	}
	var tabList=tabs[group];
	for(i=0;i<tab_indices[group].length;i++)
	{
		getObj(group+"_"+tab_indices[group][i]+"_a").className="button";
	}
	getObj(group+"_"+id+"_a").className="button active";
	//alert(group+"_"+id+"_a");
	//alert($(group+"_"+id).length);
	loadContentIC(addCloader_url(tab_urls[group][id]),getObj(group+"_content"),false,false);
	/*
	var url=tab_urls[group][id];
	if(url.substr(0,11)=='javascript:')
	{
		alert(url.substr(11));
		eval(url.substr(11));
	}
	else
	{
		loadContentIC(addCloader_url(url),getObj(group+"_content"),false,false);
	}*/
}

function _loadDefaultTabs()
{
	if(tab_groups.length>0)
	{
		for(i=0;i<tab_groups.length;i++)
		{
			getObj(tab_groups[i]+"_"+tab_indices[tab_groups[i]][0]).className="active";
			for(j=0;j<tab_indices[tab_groups[i]].length;j++)
			{
				if(getObj(tab_groups[i]+"_"+tab_indices[tab_groups[i]][j]+"_content").className!="tab_content_show")
				{
					getObj(tab_groups[i]+"_"+tab_indices[tab_groups[i]][j]+"_content").className="tab_content";
				}
			}
			//getObj(tab_groups[i]+"_"+tab_indices[tab_groups[i]][0]+"_content").className="tab_content_show";
		}
	}
}

var _loadDefaultDynTab=false;
function _loadDefaultDynTabs()
{
	_loadDefaultDynTab=_loadDefaultDynTab ? _loadDefaultDynTab : tab_indices[group][0];
	if(tab_groups.length>0)
	{
		showDynTab(tabs[tab_groups[0]][_loadDefaultDynTab],tab_groups[_loadDefaultDynTab]);
	}
}

/* [/TABS] */


