/*
wizard variable
default auf 1 setzen
*/
//alert(parseFloat(navigator.appVersion)+"#"+navigator.appVersion);
//var ie6 = (navigator.appName=="Microsoft Internet Explorer" && (navigator.appVersion.search(/MSIE 6/)!=-1))	?	true	: false;
//if (ie6)	alert("test");
var nextWizard=1;

/*
variablen für das Menü
damit entschieden wird welches aufgehen soll ;)
*/
//alert("test")
function onLoadSite()
{
	reloadWindow();
}

function reloadWindow()
{
	//alert(window.opener.document.getElementById("dynamicLeft"));
	//opener.top.frames['dynamicFrame'].location.reload();
}

function setElementPosition(elem)	
{
	var element=elem;
	var x=0;
	var y=0;
	var offsetY=elem.offsetHeight;

	while((typeof(element)=='object') && (typeof(element.tagName)!='undefined'))	
	{
		y+=element.offsetTop;
		x+=element.offsetLeft;
		tagname=element.tagName.toUpperCase();
	
		if (tagname=="BODY")	
		{
			element=0;
		}
		if (typeof(element)=="object")	
		{
			if(typeof(element.offsetParent)=="object")	
			{
				element=element.offsetParent;
			}
		}
	}
	position=new Object();
	position.x=x;
	position.y=(y+offsetY+10);
	return position;
}

function openWindow(url,windowName,position,width,height,parameter)	
{
	//alert("test");
	
	var aProps={};
	
	switch(position)	
	{
		case "center":
			var screenX=screen.availWidth;
			var screenY=screen.availHeight;
			var windowPosX=((screenX/2)-Math.floor(width/2));
			var windowPosY=((screenY/2)-Math.floor(height/2));
			break;
		default:
			var screenX=screen.availWidth;
			var screenY=screen.availHeight;
			var windowPosX=((screenX/2)-Math.floor(width/2));
			var windowPosY=((screenY/2)-Math.floor(height/2));
			break;
	}

	newWindow = window.open
	(
		url,
		windowName,
		parameter+"width="+width+",height="+height+",left="+windowPosX+",top="+windowPosY+",modal=yes"
	);
	newWindow.focus();
	
	return false;
}


function openWindowStandard(url,windowName,position,width,height,parameter)	
{
	
	var aProps={};
	
	switch(position)	
	{
		case "center":
			var screenX=screen.availWidth;
			var screenY=screen.availHeight;
			var windowPosX=((screenX/2)-Math.floor(width/2));
			var windowPosY=((screenY/2)-Math.floor(height/2));
			break;
		default:
			var screenX=screen.availWidth;
			var screenY=screen.availHeight;
			var windowPosX=((screenX/2)-Math.floor(width/2));
			var windowPosY=((screenY/2)-Math.floor(height/2));
			break;
	}
	//alert(url+'\n'+windowName+'\n'+parameter+'\n'+windowPosX+'\n'+windowPosY+'\n'+width+'\n'+height);
	newWindow=window.open(url,windowName,parameter+"width="+width+",height="+height+",left="+windowPosX+",top="+windowPosY+",modal=yes,");
	newWindow.focus();

	return false;
}

function wizardPaging(next)
{
	arrWizard=new Array();
	var count=1;
	var activeCount=0;
	if (strDivWizard.length<1)	strDivWizard="divWizard";
	//irgendwo muss es anfangen und wenns bei 1 nix gibt dann geht dieser wizard einfach net ...
	//alert(strDivWizard);
	if (document.getElementById(strDivWizard+"1"))	
	{

		while (object=document.getElementById(strDivWizard+count))
		{
			//alert(object);
			if (next!=count)
			{
				document.getElementById(strDivWizard+"Helptext"+count).style.display="none";
				document.getElementById(strDivWizard+count).style.display="none";
				//object.style.display="none";
			}
			else
			{
				//alert(document.getElementById("divWizardHelptext"+count).className);
				document.getElementById(strDivWizard+"Helptext"+count).style.display="block";
				document.getElementById(strDivWizard+count).style.display="block";
				//object.style.display="block";
				
				activeCount=count;
			}
			//count1=(count+1);
			
			//alert(document.getElementById("divWizard"+count);
			/*if (!document.getElementById("divWizard"+count1))
			{
				alert("test");
			}*/
			count++;
		}
		
		
		
		if (!document.getElementById(strDivWizard+(activeCount+1)))
		{
				document.getElementById("buttonWizardNext").style.display="none";
				document.getElementById("buttonWizardEnd").style.display="block";
		}
		else
		{
				document.getElementById("buttonWizardNext").style.display="block";
				document.getElementById("buttonWizardEnd").style.display="none";
		}
		
		if (next>=count || next<=1)	
		{
			document.getElementById(strDivWizard+"Helptext1").style.display="block";
			document.getElementById(strDivWizard+"1").style.display="block";
			document.getElementById("buttonWizardBack").disabled="true";
			nextWizard=1;
		}
		if (next<count && next>1)	
		{
			document.getElementById("buttonWizardBack").disabled=false;
		}
		
		//if 
		
	}
	
}

var previous=false;
var previousClassName=false;

function changeClass(obj,className)	{
	if (previous)	previous.className=previousClassName;
	previousClassName=obj.className;
	obj.className=className;
	
	previous=obj;
}

function setSwitchBlockHide(arrObj,ObjActive)
{
	if (arrObj && arrObj.length>0)
	{
		for (i=0;i<arrObj.length;i++)
		{
			if (arrObj[i]==ObjActive)
			{
				
				document.getElementById(arrObj[i]).style.display="block";
			}
			else
			{
				document.getElementById(arrObj[i]).style.display="none";
			}
		}
	}
}

function setObjectDisplay(stringObjects,style)
{
	var myArray=stringObjects.split(",");
	//alert(myArray.length+"\n"+stringObjects);
	if (myArray.length>0)
	{
		for (i=0;i<myArray.length;i++)
		{
			object=document.getElementById(myArray[i]);
			//alert(object);
			if (object && style.length>0 && object.style.display)	object.style.display=style;
		}
	}
	//object.style.display=="none" ? object.style.display="block" : object.style.display="none";
}

function setObjectsVisibility(stringObjects,style)
{
	var myArray=stringObjects.split(",");
	//alert(myArray.length+"\n"+stringObjects);
	if (myArray.length>0)
	{
		for (i=0;i<myArray.length;i++)
		{
			object=document.getElementById(myArray[i]);
			//alert(object);
			if (object && style.length>0)	object.style.visibility=style;
		}
	}
	//object.style.display=="none" ? object.style.display="block" : object.style.display="none";
}

function textswitch(target,action,text)	
{
	if( action == "unset" ) 
	{
		if( target.value == text )
		{  
			target.value = '';
		}

	}
	if( action == "set" ) 
	{
		if( target.value == "" ) 
		{
			target.value = text;
		}
	}
}

function setChkbox(obj,id_db)	
{
	if (obj.checked==true) 
	{
		document.getElementById(id_db).value=1;
	}	
	else	
	{
		document.getElementById(id_db).value=0;
	}
}

function setWindowSize() 
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	windowHeight=myHeight;
	windowWidth=myWidth;
}

function __ContactTagExistingValidation(obj, attributTyp, value)
{
	if (obj.getAttributeNode(attributTyp))
	{
		for (var i = 0; i < obj.attributes.length; i++) 
		{
			var attrName = obj.attributes[i].name.toLowerCase();
			
			if (attrName == attributTyp)
			{
				obj.attributes[i].value = value;
			}
		}
	}
	else
	{
		obj.setAttribute(attributTyp, value);
	}
}

Array.prototype.array_cut = function(n) 
{
	if(n >= 0 && n < this.length) 
	{
		if(n<this.length) 
		{
			var x = -1;
			while((++x)<this.length) 
			{
				if(x>=n) 
				{
					this[x] = this[x+1];
				}
			}
		}
		this.pop();
	}
};

String.prototype.unHtmlEntities = function()
{
	var entities = new Array ('&','<','>');
	
	var chars = new Array ('amp','lt','gt');
	
	newString = this;
	for (var i = 0; i < chars.length; i++)
	{
		myRegExp = new RegExp();
		myRegExp.compile("&"+chars[i]+";",'g')
		//alert(myRegExp);
		newString = newString.replace (myRegExp, entities[i]);
	}
	//alert(newString);
	return newString;
}
