/////////////////////////////////////////////////////////////////////////////////////
// freestyle javascript base version 3.23.00 for admin and hierarchy editor modul
//-----------------------------------------------------------------------------
// ! DO NOT REMOVE THIS NOTICE ! 
// ! DO NOT CHANGE THIS NOTICE !
// THIS IS A LICENSED VERSION. 
// IT IS NOT ALLOWED TO REDISTRIBUTE THIS PRPGRAM OR ANY PART OF IT.
//-----------------------------------------------------------------------------
// Copyright (c) 2001-2006 by aClass+aWeaver and Ralph Stuermer. All Rights reserved.
// Developing+Programming by Ralph Stuermer
//-----------------------------------------------------------------------------
// DOM level 1 supported by NN6 and IE5 allows to dynamically create form
// elements and add them to a FORM.
/////////////////////////////////////////////////////////////////////////////////////

function nop() {}

/////////////////////////////////////////////////////////////////////////////////
// findObject
function findObject(n,d) {
  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&&d.forms&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=findObject(n,d.layers[i].document);
  if(!x && d.getElementById)
  	x=d.getElementById(n);
  return x;
}

/////////////////////////////////////////////////////////////////////////////////
// findFrame
function findFrame(frameName,frameStart){
	if(!frameStart) { frameStart=top; }
  var frameObj=0,i;
  var frameList='top/'
  if(frameStart.frames) {
    for(i=0;i<frameStart.frames.length;i++){
      if(frameStart.frames[i].name==frameName){
      	frameObj=frameStart.frames[i];  
      	break
      };
    }
    if(frameObj==0) {
	    for(i=0;i<frameStart.frames.length;i++){
	    	frameObj=findFrame(frameName,frameStart.frames[i]);
	    	if(frameObj!=0) {
	    		break;
	    	}
	    }
    }
  }
  return frameObj;
}

function findFrameOld(frameName){
  obj=top; var frameObj=0,i,j,a,ln;
  for(i=0;i<obj.frames.length;i++){
    if(obj.frames[i].name==frameName){
    	frameObj=obj.frames[i]; 
    	break;
    };
    ln=obj.frames[i].frames.length
    for(j=0;j<ln;j++){
      if(obj.frames[i].frames[j].name==frameName){
      	frameObj=obj.frames[i].frames[j];  
      	break
      };
      ln2=obj.frames[i].frames[j].frames.length
      for(a=0;a<ln2;a++){
      	/*
      	if(i==4&&j==1&&a==0) {
      		inspectObject(obj);
			   	alert('stop for obj');
      		inspectObject(obj.frames[i]);
			   	alert('i='+i);
			   	inspectObject(obj.frames[i].frames[j]);
		     	alert('j='+j);
		     	inspectObject(obj.frames[i].frames[j].frames[a]);
      		alert('a='+a);
      	}
      	*/
        if(obj.frames[i].frames[j].frames[a].name==frameName){
        	frameObj=obj.frames[i].frames[j].frames[a]; 
        	break
        }
      }
    }
  }
  return frameObj;
}

/////////////////////////////////////////////////////////////////////////////////
// getProperties
function getProperties(obj) {
	var properties = '<html><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="margin:0px;padding:0px;"><table cols="2" border="0" style="border:0x solid #000000">';
	properties += '<tr style="text-align:left;background-color:#cccccc;"><th>Property</th><th>Values of '+obj['name']+'</th></tr>';
	var propNames=new Array();
	var i=0;
	for(var propName in obj) {
		propNames[i++]=propName;
	}
	propNames.sort();
	for(i=0; i<propNames.length; i++) {
		properties +='<tr style="text-align:left;"><td style="text-align:left;background-color:#cccccc;">'+propNames[i]+'</td><td style="text-align:left;background-color:#f0f0f0;border:1x solid #999999">'+obj[propNames[i]]+'&nbsp;</td></tr>';
	}
	properties +='</table></body></html>';
	return properties;
}

/////////////////////////////////////////////////////////////////////////////////
// inspectObject
function inspectObject(obj,doc) {
	if(obj&&obj!=null) {
		var newWindow = window.open("","propWindow","height=400,width=350,status=1,resizable=1,scrollbars=1");
		newWindow.document.write(getProperties(obj));
		newWindow.document.close();
		newWindow.focus();
	}
}

/////////////////////////////////////////////////////////////////////////////////
// addzero
function addZero(v,n)	{
	v=String(v);
	while(v.length<n) v='0'+v;
	return v;
}

/////////////////////////////////////////////////////////////////////////////////
// absLeft
function absLeft(el) {
   return (el.offsetParent)? 
   el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}

/////////////////////////////////////////////////////////////////////////////////
// absTop
function absTop(el) {
   return (el.offsetParent)? 
   el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}

/////////////////////////////////////////////////////////////////////////////////
// fileViewer -> used in a formtoolbox form
function fileviewer(link,target,file,update) {
	var fvWidth = 600;
	var fvHeight = 400;
	if(file) {
		if(file.indexOf('#')>0) {
			if(!update||update==null) return;
			file=update;
		}
		if(file=='*'||file=='') return;
	} else
		file='';
	var fvw=window.open(link+file,target,'width='+fvWidth+',height='+fvHeight+',resizable=yes,scrollbars=no,dependent=yes,status=no,toolbar=no,menubar=no');
  if (document.all) { // IE
    fvw.resizeTo(fvWidth,fvHeight);
  } else
  if (document.layers) { // NS
    fvw.outerWidth=fvWidth;
    fvw.outerHeight=fvHeight;
  }
	fvw.moveTo((screen.availWidth-fvWidth)/2,(screen.availHeight-fvHeight)/2);
	fvw.focus();
}

/////////////////////////////////////////////////////////////////////////////////
// templateviewer -> used in a formtoolbox form
function templateviewer(link,target,file,update,width,height) {
	var fvWidth = 800;
	if(width&&width>0) fvWidth = width;
	var fvHeight = 600;
	if(height&&height>0) fvHeight = height;
	if(file&&file!=null) {
		if(file.indexOf('#')>=0) {
			if(!update||update==null) return;
			file=update;
		}
		if(file.indexOf('*')>=0) {
			return;
		}
		if(file=='')  {
			return;
		}
	} else {
		file='';
	}
	var fvw=window.open(link+file,target,'width='+fvWidth+',height='+fvHeight+',resizable=yes,scrollbars=no,dependent=yes,status=no,toolbar=no,menubar=no');
  if (document.all) { // IE
    fvw.resizeTo(fvWidth,fvHeight);
  } else
  if (document.layers) { // NS
    fvw.outerWidth=fvWidth;
    fvw.outerHeight=fvHeight;
  }
	fvw.moveTo((screen.availWidth-fvWidth)/2,(screen.availHeight-fvHeight)/2);
	fvw.focus();
}
/////////////////////////////////////////////////////////////////////////////////
// replaceSubstring -> used in a formtoolbox form
function replaceSubstring(inputString, fromString, toString) {
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { 
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { 
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      }
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   }
   return temp; 
} 

/////////////////////////////////////////////////////////////////////////////////
// class urlSplitter
function urlSplitter(url) {
	this.url=url;
	this.protocol='';
  if(this.url.search(/\/\//g) != -1){
  	var temp=this.url.split("//");
  	this.protocol=temp[0];
  	this.url=temp[1];
  }
  this.domain=this.url;
  this.path='';
  this.file='';
  this.extension='';
  this.para=new Array();

  if(url.search(/\//g)!=-1) {
		var temp=this.url.split("/");	
		this.domain=temp[0];
		this.file=temp[temp.length-1];
		if(temp.length>2) {
			for(var i=1; i<(temp.length-1); i++) {
				this.path+=temp[i];
			}
		}
	  if(this.file.search(/\?/g)!=-1) {
	    var temp=this.file.split("?");
	    /*
		  if(temp[1].search(/\&/g)!=-1) {
		  	var temp2=temp[1].split("&");
		  	for(var j=0; j<temp2.length; j++) {
			  	alert('##'+temp2[j]);
		  		if(temp2[j].search(/\=/g)!=-1) {
		  			// alert('aaaaaaaaaaa');
		  			var temp1=temp2[j].split("=");
		  			var p='';
						for(var i=1; i<temp1.length; i++) {
							p+=temp1[i];
						}
		  			this.para[temp1[0]]=p;
		  		} else {
		  			// alert('bbbbbbbbbbbb');
		  			this.para[temp2[j]]='';
		  		}
		  	}
		  } else {
	  		if(temp[0].search(/\=/g)!=-1) {
	  			var temp1=temp[0].split("=");
	  			var p='';
					for(var i=1; i<temp1.length; i++) {
						p+=temp1[i];
					}
	  			this.para[temp1[0]]=p;
	  		} else {
	  			this.para[temp[0]]='';
	  		}
		  }
		  */
		  this.para=temp[1];
	    this.file=temp[0];
		}	
		if(this.file.search(/\./g)!=-1) {
			var temp=this.file.split(".");
			this.extension=temp[temp.length-1];
		}
		
	}

}


// find out if ie runs in quirks mode
var docEl = ( typeof document.compatMode != "undefined" && document.compatMode != "BackCompat" )? "documentElement" : "body";
// register event capture it for nc 4x
var tooltip=false; 
function initToolTip() {
	clearToolTip();
  if(document.layers) document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove =	mousehandleToolTip;
}
// handle onmousemove event
//
function mousehandleToolTip(e) {
  // position where mousemove fired
  var xPos = e? e.pageX : window.event.x;
  var yPos = e? e.pageY : window.event.y;
  // for ie add scroll position
  if (document.all && !document.captureEvents) {
    xPos += document[docEl].scrollLeft;
    yPos += document[docEl].scrollTop;
  }
  // display position
  // document.feld.ausg.value = "Left = " +xPos +" : Top = " +yPos;
  // for the dino pass event
	var o=findObject("ToolTip",document);
	if(o&&o!=null) {
		(o.style?o.style:o).left= xPos+8;
		(o.style?o.style:o).top=yPos+17;
	}
 
  if (document.layers) routeEvent(e);
}
function setToolTip(content) {
	var o=findObject("ToolTip",document);
	if(o&&o!=null) {
		tooltip=true; 
		o.innerHTML='<table class="tooltip" border="0" cellspacing="0" cellpadding="0"><tr class="tooltip"><td class="tooltip">'+content+'</td></tr></table>';
		(o.style?o.style:o).visibility='visible'; 
	}
}
function clearToolTip() {
	tooltip=false; 
	var o=findObject("ToolTip",document);
	if(o&&o!=null)
		(o.style?o.style:o).visibility='hidden'; 
}
