var arTXTControls;
var arTXTText = new Array();
var sActiveTextArea;


// Function CheckTextBoxHTMLContent
// 
// Description: 
// Check all "textarea"-TAGS in the current form, wheter HTML Tags are entered.
// 
// Parameter:
// sPLHName: LabelClientID, where the error messages will be displayed.
// sErrorMessage: Diplayed error message
//
// Return:
// true -> no HTML Tags present
// false -> HTML Tags present
//
function CheckTextBoxHTMLContent(sPLHName, sErrorMessage) 
{
	var sPattern = "^(/w|/W|[^<>{}])+$";
	var i = null;
	var oTextBox = null;
	var matches;
	var bHTMLTags = false;
	var sContent = "";

    
    oTextBox = document.body.getElementsByTagName('TEXTAREA');
    
	if (oTextBox != null) 
	{
		for (i=0;i<oTextBox.length;i++)
		{
			if (oTextBox[i].value != "")
			{
				try
				{
					var matches = ExtractMatches( new RegExp( sPattern, "gi" ), oTextBox[i].value )
					if (matches.length == 0) bHTMLTags = true;
					matches = null;
					
				} 
				catch ( ex )
				{
				}
			}
		}
    }
    
    if (bHTMLTags) 
    {
		if (sPLHName != "" && document.all[sPLHName] != null) {
			document.all[sPLHName].innerHTML = "<b>" + sErrorMessage + "</b>";
			document.all[sPLHName].className = "LabelError"; 
			}
		return false;
    }
    
    if (sPLHName != "" && document.all[sPLHName] != null)	document.all[sPLHName].innerHTML = "";
    return true;
}





// RegEx Helper function
//
function ExtractMatches( re, text )
{
	var results = new Array() ;
	var arr = re.exec(text)
	while(arr != null)
	{ 
		var match = new Match() ;
		match.Text = arr[0] ;
				
		for (var i=1; i<arr.length; i++)
		{
			match.Groups[i-1] = arr[i] ;
		}
		
		results[results.length] = match ;
		arr = re.exec(text) ; 
	}
	return results ;
}


// RegEx Helper function
//
function Match()
{
	this.Text = null ;
	this.Groups = new Array() ;
}


// Function InsertText
// 
// Description: 
// insert a text at the selected range/position
// 
// Parameter:
// text to insert
//
// Return:
// ---
//
function InsertText(Text) 
{ //IE 
	var Control = document.all[sActiveTextArea];
	
	if (Control != undefined){
		Control.focus();
		if (document.selection) { 
			theSelection = window.document.selection.createRange(); 
			theSelection.text = Text; 
		} 
	}
}

function SetFocus( sCntlName )
{
	sActiveTextArea = sCntlName;
}


// focues the specific control
//
function FocusControl( CntlID )
{
	var obj = document.all[CntlID];
	
	if (obj != null)
	{
		obj.focus();
	}
}

// Function windowopen
// 
// Description: 
// open popup window
// 
// Parameter:
// window javascript properties
//
// Return:
// ---
//
function openwin( url, sizex, sizey, name, scroll )
{
	if (scroll == null)
		scroll = true;
		
	if (scroll == true)
	 scroll = "yes";
	else
	 scroll = "no";
	 
	param = 'width=' + sizex + ',height=' + sizey + ',directories=no,hotkeys=no,location=no,menubar=no,scrollbars='+scroll+',toolbar=no,resizable=no';
	
	url = url + "&ou=" + window.location.href;
	window.open(url, name, param);
}

function openwindows( url, sizex, sizey, name, scroll )
{
	if (scroll == null)
		scroll = true;
		
	if (scroll == true)
	 scroll = "yes";
	else
	 scroll = "no";
	 
	param = 'width=' + sizex + ',height=' + sizey + ',directories=no,hotkeys=no,location=no,menubar=no,scrollbars='+scroll+',toolbar=no,resizable=no';
	

	window.open(url, name, param);
}







// 
// Description: 
// Close the upload popup window
// 
// Parameter:
// doreload = reload the opener window
// openerurl = new url for the opener
// clientids = textbox control to fill after the reload
//
// Return:
// ---
//
//
function CloseUploadWindow( doreload , openerurl , clientids)
{
	if (window.opener && doreload)
	{
		// get all client controls
		arTXTControls = clientids.split(";");
		// get old values
		for (var i=0; i<arTXTControls.length; i++)
			arTXTText[i] = window.opener.document.all[arTXTControls[i]].value;
		// load new page on opener
		window.opener.location.href = openerurl;
		// wait for readystate of the opener window
		do
		{}
		while (window.opener.document.readyState != "complete")
		// refill textbox controls and close window
		for (var i=0; i<arTXTControls.length; i++)
			window.opener.document.all[arTXTControls[i]].value = arTXTText[i];
		window.self.close();
	}
}
// 
// Description: 
// Close the upload popup window
// 
// Parameter:
// doreload = reload the opener window
// openerurl = new url for the opener
//
// Return:
// ---
//
//
function CloseWindow( doreload , openerurl )
{
	if (doreload)
	{
		// load new page on opener
		window.opener.location.href = openerurl;
		// wait for readystate of the opener window
		do
		{}
		while (window.opener.document.readyState != "complete")
		window.self.close();
	}
}


// 
// Description: 
// reloads the opener window
// 
// Parameter:
// openerurl = new url for the opener
//
// Return:
// ---
//
//
function ReloadOpener( openerurl)
{
	// load new page on opener
	window.opener.location.href = openerurl;
}


// 
// Description: 
// Update the opener window
// 1. display the new picture
// 2. show the delete hyperlink
// 3. hide the admin hyperlink
// 
// Parameter:
// objImageID		= imageobject ID
// strImageURL		= uploaded image URL
// objAdminLinkID	= Admin hyperlnk ID
// objDeleteLinkID	= Delete hyperlink ID
//
// Return:
// ---
//
//
function UpdateOpenerPicture ( objImageID, strImageURL ,objAdminLinkID, objDeleteLinkID )
{

	var objImage = window.opener.document.all[objImageID];
	var objAdminLink = window.opener.document.all[objAdminLinkID];
	var objDeleteLink = window.opener.document.all[objDeleteLinkID];
	
	if (objImage != null)
		objImage.src = strImageURL;
		
	if (objAdminLink != null)
		objAdminLink.className = 'hidelink';
	
	if (objDeleteLink != null)
		objDeleteLink.className = 'hyperlink';
		
	//window.self.close();
	
}
// 
// Description: 
// Autofill the email control while creating 
// a new contact person
// 
// Parameter:
// txtFirstname		= firstname control
// txtLastname		= lastname control
// txtEmail			= email control
//
// Return:
// ---
//
//
function FillEmail(txtFirstname, txtLastname, txtEmail) {

	var objFName = window.document.all[txtFirstname];
	var objLName = window.document.all[txtLastname];
	var objEMail = window.document.all[txtEmail];
	
	if (objFName != null && objLName != null && objEMail != null)
	{
		if (objEMail.value == '')
			objEMail.value = objFName.value + '.' + objLName.value + '@widmannbewegt.de';
	}
}



// eventhandling for mouse event "onmousedown"
// capture mouse position x,y
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousedown = captureMousePosition;
} else if (document.getElementById) { // Internet Explorer
    document.onmousedown = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousedown = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

// Function captureMousePosition
// 
// Description: 
// caputure current mouse position
// 
// Parameter:
// e: mouse event
//
// Set global variables
//
function captureMousePosition(e) {
    if (document.layers) { //NS
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) { //IE
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.all) { //NS
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}




// Function ControlDivTag
// 
// Description: 
// Enable and disable a specified div.
// 
// Parameter:
// sClientID: div tags client ID
// sFunction: "show" or "hide" control
// sDirection: left, right or default
//
// Return:
// ---
//
function ControlDivTag(sClientID, sFunction, sHorizDirection, sVertDirection){
    var oDiv = document.all[sClientID];
    var iPosLeft= 0;
    var iPosTop = 0;
    
    if (oDiv != null)
    {
	
		switch(sFunction)
		{
			case "show":
				
				switch(sHorizDirection)
				{
					case "left":
						iPosLeft =-230;
					break;
					
					case "right":
						iPosLeft = 10;
					break;
					
					default:
						iPosLeft = 10;
					break;
				}
				
				switch(sVertDirection)
				{
					case "top":
						iPosTop = -60;
					break;
					
					case "bottom":
						iPosTop = 10;
					break;
					
					default:
						iPosTop = 10;
					break;
				}			
				
				oDiv.style.left = xMousePos + iPosLeft;
				oDiv.style.top  = yMousePos + iPosTop;
				
				MM_showHideLayers(sClientID,'','show');
	        
				//oDiv.style.display = "";
				break;
			case "hide":
				
				MM_showHideLayers(sClientID,'','hide')
				//oDiv.style.display = "none";
				break;
		}
		oDiv = null;
	}
}


// Function HideDivTag
// 
// Description: 
// hides a specified div.
// 
// Parameter:
// sClientID: div tag to hide
//
// Return:
// ---
//
function HideDivTag(sClientID){
	setTimeout('ControlDivTag("'+ sClientID + '", "hide")',500);
	}



// Function ShowDivTag
// 
// Description: 
// shows a specified div.
// 
// Parameter:
// sClientID: div tag to make visible
//
// Return:
// ---
//
function ShowDivTag(sClientID,sHorizDirection, sVertDirection){
	ControlDivTag(sClientID, 'show',sHorizDirection, sVertDirection);
	}


var m_sIDHeadlineCtl;
var m_sIDTextCtl;
var m_sIDDateCtl;
var m_sIDTextBoxControl;

// Function ChangeInputCI
// 
// Description: 
// get selected language and write to member variable
// 
// Parameter:
//
// Return:
// ---
//
function ChangeInputCI() {

	var Control =  document.all.tags("SELECT")[0];
	var m_sTemp, m_sTemp2;
	var cntImage = document.getElementById("imgFlag");
	var objhidText, objhidHead, objhidDate;


	if (Control != null){
		if (Control.length > 0) {
			// get selected item
			m_sTemp = Control.options[Control.selectedIndex].value;
			
			if (m_sTemp != ''){
				// set hidden controls depends on the culture ID (de, us...)
				m_sIDHeadlineCtl = 'hidHeadline_' + m_sTemp;
				m_sIDTextCtl = 'hidText_' + m_sTemp;
				m_sIDDateCtl = 'hidDate_' + m_sTemp;
				
				objhidHead = document.getElementById(m_sIDHeadlineCtl);
				objhidText = document.getElementById(m_sIDTextCtl);
				objhidDate = document.getElementById(m_sIDDateCtl);
				
				
				// enable input controls
				document.getElementById("txtHeadline").disabled = false;
				//document.getElementById["txtText").disabled = false;
				if (document.getElementById("txtDateText") != null)
					document.getElementById("txtDateText").disabled = false;
				
				// fill or clear input fields
				if (objhidHead.value != '')
					document.getElementById("txtHeadline").value = objhidHead.value;
				else
					document.getElementById("txtHeadline").value = '';
					
				if (objhidText.value != ''){
//					document.getElementById["txtText").value = objhidText.value;
					document.getElementById("txtEditorText").value = objhidText.value;
					}	
				else {
					//document.getElementById["txtText").value = '';	
					document.getElementById("txtEditorText").value = objhidText.value;					
				}
				
				if (document.getElementById("txtDateText") != null) {
					if (objhidDate.value != '')
						document.getElementById("txtDateText").value = objhidDate.value;	
					else
						document.getElementById("txtDateText").value = '';					
				}
				
				// change culture flag
				if (cntImage != null){
					if (m_sTemp == 'en')
						m_sTemp2 = 'us';
					else
						m_sTemp2 = m_sTemp;
						
					cntImage.src = '../res/Images/Cultures/'+m_sTemp+'-'+m_sTemp2+'.gif';
				}
			}
			if (Control.options[0].value == '')
				Control.options.remove(0);
		}
	}
}

// Function ResizeContectListWindow
// 
// Description: 
// resize the content popup window based 
// on the maintable of the window named "tblMain"
// 
// Parameter:
// ---
//
// Return:
// ---
//
function ResizeContectListWindow() {

	var objMainTable = document.all["tblMain"];
	
	if (objMainTable != null) {
		var m_iHeight = objMainTable.scrollHeight + 50;
		var m_iWidth = parseInt(objMainTable.width,10);
		
		m_iWidth += 25;
		
		window.resizeTo(m_iWidth, m_iHeight);
	}

}

// Function CheckOnPostBack
// 
// Description: 
// sets the control properties of the contentlist admin popup window
// if the window loads the first time then disable all input controls.
// if a language selected then enable the input controls
// 
// Parameter:
// ---
//
// Return:
// ---
//
function CheckOnPostBack() {
	
	// get status
	if (document.all["hidFilled"].value == "true") {
		EnableDocSaveButton();
	}
	// disable input controls	
	document.all["txtHeadline"].disabled = true;
	
	if (document.all["txtDateText"] != null)
		document.all["txtDateText"].disabled = true;
}

// Function WriteToHidControl
// 
// Description: 
// get selected language and write to member variable
// 
// Parameter:
// section: headline (head) or datetext (date)
//
// Return:
// ---
//
function WriteToHidControl(section) {

	var objHeadline;
	var objText;
	var objDateText;
	var objTarget;
	
	var sTemp;

	switch (section) {

		case 'head':
		objHeadline = document.all["txtHeadline"];
		if (objHeadline.value != '') {
			objTarget = document.all[m_sIDHeadlineCtl];
			objTarget.value = objHeadline.value;
			EnableDocSaveButton();
		}
		break;
	
/*
Wurde durch das RichText Control ersetzt!		
		case 'text':
		objText = document.getElementById["txtText"];
		if (objText.value != '') {
			
			sTemp = FilterText(objText.value);
			
			if (sTemp.length > 4000)
				alert('Der Text wird auf 4000 Zeichen begrenzt.');
				
			sTemp = sTemp.substr(0,4000);
			
			objTarget = document.getElementById[m_sIDTextCtl];
			objTarget.value = sTemp;
			EnableDocSaveButton();
		}
		break;
*/		
		case 'date':
		objDateText = document.all["txtDateText"]; 
		if (objDateText != '') {
			objTarget = document.all[m_sIDDateCtl];
			objTarget.value = objDateText.value;
			EnableDocSaveButton();
		}
		break;
	}
}

// Function EnableDocSaveButton
// 
// Description: 
// enables the submit button
// 
// Parameter:
//
// Return:
// ---
//
function EnableDocSaveButton() {
	// get all controls
	var Controls =  document.all.tags("INPUT");
	// filter submit button and enable the control
	for (i=0; i<(Controls.length); i++)
		if (Controls[i].type == "submit")
			Controls[i].disabled = false;
	// set status
	document.all["hidFilled"].value = "True";
}


// Function CloseWindow
// 
// Description: 
// close current window and reload opener
// 
// Parameter:
// doreload  : reload opener
// openerurl : reload opener with specified url
//
// Return:
// ---
//
function CloseWindow( doreload , openerurl )
{
	if (window.opener && doreload)
	{
		// load new page on opener
		window.opener.location.href = openerurl;
		// close himself
		window.self.close();
	}
}


// Function ConfirmDelete
// 
// Description: 
// delete really?
// 
// Parameter:
// strMessage  : output message to messagebox
//
// Return: true/false
// ---
//
function ConfirmDelete(strMessage){
	
	var doyou = confirm(strMessage);
	
	return doyou;
}

// Function LoadBigPic
// 
// Description: 
// load a picture to a image control
// 
// Parameter:
// PicSource  : picture path
// DestCtl	  : image control client ID
//
// Return: true/false
// ---
//
function LoadBigPic(PicSource,DestCtl) {

	var objBigPic = document.all[DestCtl];
	
	if (objBigPic != null) {
		objBigPic.src = PicSource.replace('~/','');
	}
}


// Function CheckKeyCode
// 
// Description: 
// check the code from the key and fired the 
// click event if the key was ENTER
// 
// Parameter:
// CntrlID  : control ID from the imagebutton
//
//
function CheckKeyCode ( CntrlID )
{
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) 
	{
		//alert('return pressed');
		document.all[CntrlID].click();
	} 
}

// Function SetPageOfOpener
// 
// Description: 
// will called from the onclick event of a sitemap hyperlink.
// sets the URL of the opener window
// 
// Parameter:
// OpenerURL  : the new URL of the opener page
//
//
function SetPageOfOpener ( OpenerURL, OpenWin )
{
	if (OpenWin)
	{
		openwin(OpenerURL,500,600,'Widmann',true);
		window.self.close();
	}
	else
	{
		if (window.opener != null)
		{
			window.opener.location.href=OpenerURL;
			window.self.close();
		}
		else
			window.self.close();
	}
}
// Function SetFocus
// 
// Description: 
// set the focus to himself
// 
//
//
function SetFocus()
{
    self.focus();
    window.setTimeout("SetFocus()",3000);
}

// Function DisableSelecColor
// 
// Description: 
// hide the color select dropdownlist
// 
//
//
function DisableFarbton(Source,btn1,btn2,btn3)
{
	if (Source.options[Source.selectedIndex].value > -1)
	{
		if (btn1 != null)
			btn1.disabled = true;
		if (btn2 != null)
			btn2.disabled = true;
		if (btn3 != null)
			btn3.disabled = true;
	}
	else
	{
		if (btn1 != null)
			btn1.disabled = false;
		if (btn2 != null)
			btn2.disabled = false;
		if (btn3 != null)
			btn3.disabled = false;
	}		
/*
	var objSel = document.all["trSelectColor"];
	var objSpacer = document.all["trSelectColorSpacer"];
	
	if (Source.options[Source.selectedIndex].value > -1)
	{
		if (objSel != null)
			objSel.style.display = "none";
		if (objSpacer != null)
			objSpacer.style.display = "none";
	}
	else
	{
		if (objSel != null)
			objSel.style.display = "";
		if (objSpacer != null)
			objSpacer.style.display = "";
	}
	
	*/

}



// open the client email with the specified address
function sendEmail(encodedEmail)
{
  // do the mailto: link
  location.href = "mailto:" + decodeEmail(encodedEmail);
}

// return the decoded email address
function decodeEmail(encodedEmail)
{
  // holds the decoded email address
  var email = "";

  // go through and decode the email address
  for (i=0; i < encodedEmail.length;)
  {
    // holds each letter (2 digits)
    var letter = "";
    letter = encodedEmail.charAt(i) + encodedEmail.charAt(i+1)

    // build the real email address
    email += String.fromCharCode(parseInt(letter,16));
    i += 2;
  }
  
  return email;
}







//
//  select the assistant picture for the location
//
//
function SelectAssistantPicID( url, sizex, sizey, imagecntlID, hiddencntlID )
{
	// call modal dialog and get return value
	var returnvalue = window.showModalDialog(url,"","status:false;dialogWidth:"+sizex+"px;dialogHeight:"+sizey+"px");
	if (returnvalue != null)
	{
		// split into array
		var values = returnvalue.split(";");
		// assistantID
		var objHidField = document.getElementById(hiddencntlID);
			objHidField.value = values[0];
		// new image URL
		var objImgField = document.getElementById(imagecntlID);
		// set new image		
		if (objImgField != null)
			objImgField.src = values[1];
	}
}

//
// return value from the modal dialog
//
function ReturnPictureID()
{
	var rdButton = document.Form1.MABilder;
	var _iPictureID = getSelectedRadioValue(rdButton);
	var _sReturnValue = _iPictureID;
	// get url from image
	var objImage = document.getElementById("pic_" + _iPictureID);
	// update return value
	if (objImage != null)
		_sReturnValue += ";" + objImage.src;
	// set return value
	returnValue = _sReturnValue;
	// close window
	window.close();
}


//
// return value from the modal dialog
//
function ReturnURL()
{
	var rdButton = document.Form1.InternalFiles;
	returnValue = getSelectedRadioValue(rdButton);
	// close window
	window.close();
}



//
//
//
function DeleteAssistantPicID( imagecntlID, hiddencntlID )
{
	var objHidField = document.getElementById(hiddencntlID);
	objHidField.value = "-1";
	
	// new image URL
	var objImgField = document.getElementById(imagecntlID);
	// set new image		
	if (objImgField != null)
	{
		objImgField.src = "";
		objImgField.style.visibility = "hidden";
	}
}





function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function


//
// show layer with assistant picture in the
// car detail view
//
function ShowAssistantPic ( ImgURL )
{
	return overlib(ImgURL, WIDTH, 83, BORDER, 2, BGCOLOR, '#EEEEEE');
}


//
// Kontrolliert, damit nur ein Item in der Selectbox
// ausgewählt wurde.
//
function CheckItemSelection( CntlName )
{
	var CtnlSelect = document.getElementById(CntlName);
	if (CtnlSelect != null)	{
		var _iSelected = 0;
		for (i=0;i<CtnlSelect.options.length;i++)
			if (CtnlSelect.options(i).selected == true)	_iSelected ++;
		if (_iSelected>1){
			alert('Nur ein Element fuer die Sortierung auswaehlen!');return false;}
		else {return true}
    }
}


//
// Macromedia Functions
//
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

// show/hide control
function MM_showHideLayers() { //v6.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_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_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];}
}

// Bild erstellen
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// Bildwechsel
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
// Bilder vorausladen
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		mercedes_over = newImage("res/images/mercedes-over3.gif");
		Chrysler_over = newImage("res/images/Chrysler-over3.gif");
		solid_over = newImage("res/images/solid-over3.gif");
		smart_over = newImage("res/images/smart-over3.gif");
		vw_over = newImage("res/images/vw-over3.gif");
		preloadFlag = true;
	}
}

// Geführte Suche ein und ausblenden
function toggleMenu(e) {
	e = $(e);
	if (e.style.display == 'none') {
	Effect.Appear(e);
	} else {
		Effect.Fade(e);
	}   
}
//-->



//
// set internal links to the parent window 
// while opening news popups
//
function ChangeParentURL(obj)
{
	var _sLink = obj.href;
	obj.href = "#";
	if (window.opener != null)
		window.opener.location.href = _sLink;
	window.close();
}


//
//
//
function CheckSelectedItems( cntlID, infotext )
{
	var CtnlSelect = document.getElementById(cntlID);
	if (CtnlSelect != null)	{
		var _iSelected = 0;
		for (i=0;i<CtnlSelect.options.length;i++)
			if (CtnlSelect.options(i).selected == true)	_iSelected ++;
		if (_iSelected==0){
			alert(infotext);return false;}
		else {return true}
    }
}


