// _________________________________________________________________
//
// File	:   	javascript.js
// Project	:   03U6 e-Commerce Shop
// Copyright:   (c) 2004 Comgate Solutions AG, Bern
// Author 	:   Tom Faller, Rene Leupold
// Created	:   15.09.1999
// System	:   JavaScript1.0-Capable Browser
// Shop	:   	Global (all)
// Comment :	Comgate specific functions
// Modification  :   14.11.2001 / V 2.00.00 / tf / details see version.txt
//		   30.05.2006 / V 2.00.01 / rl / add onLoad-Event
//_________________________________________________________________

//-----------------------------------------------------------------
// Name          :	pageLoaded()
// Returns       :
// Description   :	Format functions when a page is loaded
// Created       :	22.10.1999
// Modification  :   14.11.2001 / V 2.00.00 / tf / details see version.txt
//-----------------------------------------------------------------

function pageLoaded()
{
	if(document.getElementById("menu").clientHeight < document.getElementById("content").clientHeight)
	{
		document.getElementById("menu").style.height = document.getElementById("content").clientHeight + "px";
	}
	else if(document.getElementById("menu").clientHeight < document.getElementById("content").clientHeight)
	{
		document.getElementById("content").style.height = document.getElementById("menu").clientHeight + "px";
	}
}
function ValidateQuickSearch()
{
   if( document.forms[0].elements["searchField"].value == '' || 
   	document.forms[0].elements["searchField"].value == 'Suchbegriff')
   {
         alert("Bitte geben Sie einen Suchbegriff ein!");
          document.forms[0].elements[0].focus();
         return false;
    }
    return true;
}
var ActiveBackgroundPicture = "/fileadmin/images/background_field.gif";
function SetFocus(obj,bActive)
{


	if( bActive )
	{
		//obj.style.backgroundColor = ActiveCellColor;
		obj.style.backgroundImage = 'url(' + ActiveBackgroundPicture + ')';
		
	}
	else //remove style
	{
		obj.removeAttribute("style");
	}
	
}
function attachEvents()
{
	addFieldEvents("searchField");
	addFieldEvents("searchFor");
	addFieldEvents("formMatch");
	addFieldEvents("searchDEFOP");
	addFieldEvents("searchIn");
	addFieldEvents("searchSection");
	addFieldEvents("ataTime");
	addFieldEvents("formStyle");
	addFieldEvents("searchExt");
	
	if (document.forms["frmContact"])
	{
		var check;
      		for( var i = 0; i < document.forms["frmContact"].length; i++ )
      		{
         			var el = document.forms["frmContact"].elements[i];

         			if (!el.type) i++;

         			if ( el.type == "text" || el.type == "password" || el.type == "textarea" || el.type.indexOf("select") > -1 )
         			{
            			el.onfocus = function() { SetFocus(this, true); as.showAssistant(this); }
            			if (isTextField(el.id))
            			{
               				el.onblur = function() { SetFocus(this, false); this.value=convertString(this.value,2);as.hideAssistant(); }
            			}
            			else // assign only stlyle function
               				el.onblur = function() { SetFocus(this, false); as.hideAssistant(); }
      
        			 }
      		}
      	}
	
}
function addFieldEvents(id)
{
	if (document.getElementById(id))
	{

		if (id == "searchField")
		{
			document.getElementById(id).onfocus = function() { SetFocus(this, true);if (this.value=='Suchbegriff') {this.value="";} }
		}
		else
		{
			document.getElementById(id).onfocus = function() { SetFocus(this, true); }
			document.getElementById(id).onblur = function() { SetFocus(this, false); }
		}
	}
}
function OnLoadContainer()
{
	pageLoaded();
	attachEvents();
}
window.onload = OnLoadContainer;

