/**
 *  common.js
 *  Elegance Framework - KOC.Web
 *
 *  (c) 2005 - 2008 2G B.V. All rights reserved.
 *  The computer program(s) is the proprietary information of the original authors. 
 *  and provided under the relevant License Agreement containing restrictions 
 *  on use and disclosure. Use is subject to the License Agreement.
 *
 *  No part of this package may be reproduced and/or published by print, 
 *  photoprint, microfilm, audiotape, electronically, mechanically or any other means, 
 *  or stored in an information retrieval system, without prior permission from 2G B.V. www.2g-it.nl.
 * 
 *  @original authors: jwvdiermen
 */

function CategoryMouseOver(oElement)
{
	oElement.style.backgroundColor = '#717070';
}

function CategoryMouseOut(oElement)
{
	oElement.style.backgroundColor = '#616060';
}

function menuHeaderOnMouseOver(oMenuItem)
{
	oMenuItem.className = 'menu-item-container menu-item-container-active';
}//menuHeaderOnMouseOver

function menuHeaderOnMouseOut(oMenuItem)
{
	oMenuItem.className = 'menu-item-container';
}//menuHeaderOnMouseOver
 
function sendForm ()
{
	if (__ID("txtContactPerson").value == "")
	{
		alert("Contactpersoon is verplicht.");
		__ID("txtContactPerson").focus();
	}
	else if ((__ID("txtEmail").value == "") && (__ID("txtPhone").value == ""))
	{
		alert("E-mailadres en/of telefoon is verplicht.");
		if (__ID("txtEmail").value == "")
		{
			__ID("txtEmail").focus();
		}
		else
		{
			__ID("txtPhone").focus();
		}
	}
	else if (__ID("txtQuestion").value == "")
	{
		alert("Vraag en/of opmerking is verplicht.");
		__ID("txtQuestion").focus();
	}
	else
	{
		//Enough form data, submit it.
		document.CONTACT_FORM.submit();
	}
}//sendForm

function __ID (sID)
{
	return document.getElementById(sID);
}//__ID


function selectText(oSourceObject)
{
	if (oSourceObject.value == "zoek een product")
	{
		oSourceObject.value = "";
	}
	oSourceObject.createTextRange().select();
	
	try
	{
		oSourceObject.focus();
	}
	catch (eFailedToSetFocus) { /* IGNORE */ }
}//selectText

function keydown_performSearch(oEvent)
{
	var eKey = -1;
	if (typeof(oEvent) == "undefined")
	{
		//IE
		eKey = event.keyCode;
	}
	else
	{
		//Firefox...
		eKey = oEvent.keyCode;
	}
	//var eKey = event.keyCode;
	if (eKey == 13)
	{
		performSearch();
	}
}//keydown_performSearch

String.prototype.replaceAll = function (sOriginal, sDestination) 
{
	var sReturn = this;
	
	//couldn't find a replaceAll function in the js API, so here it goes:
	while (sReturn.indexOf(sOriginal) >= 0) 
	{
    	sReturn = sReturn.replace(sOriginal, sDestination);
	}
	
	return sReturn;
}//replaceAll