function HideFormsSelect(hide)
{
	is_ie6 = navigator.userAgent.indexOf("MSIE 6.");
	is_ie5 = navigator.userAgent.indexOf("MSIE 5.");
	if ((is_ie6 < 50 && is_ie6 > 0) || (is_ie5 < 50 && is_ie5 > 0))
	{
		var sels = document.getElementsByTagName("select");
		for (i=0; i<sels.length; i++)
		{
			if (sels[i].parentNode.style.display != 'none')
			{
				sels[i].style.visibility = (hide == true) ? 'hidden' : 'visible';
			}
		}
	}
}
function clearErorrs()
{
	HideFormsSelect(false);
	document.getElementById('shop_shadow_box').style.display = 'none';
	document.getElementById('contact_error_box').style.display = 'none';
	for(key in fieldErrors)
	{
		var errorField = key + "_error_msg";
		displayMsg(errorField, '', 'error');
	}
}

function displayMsg(errContainer, errMsg, mode)
{
	var container = document.getElementById(errContainer);

	if (errMsg != "")
	{
		errMsg = "- "+errMsg;
	}
	container.innerHTML = errMsg;

	if (mode == 'error')
	{
		container.className = 'club_error_container';
	}
	else if (mode == 'warning')
	{
		container.className = 'club_warning_container';
	}
	else if (mode == 'ok')
	{
		container.className = 'club_checked_container';
	}
}

function setSelectListValue(selectId, val) {
	with(document.getElementById(selectId)) {
		selectList = document.getElementById(selectId);
		var i;
		//set by text
		for(i = 0; i < selectList.length; i++) {
			if(selectList.options[i].text == val) {
				selectList.selectedIndex = i;
			}
		}
		//set by value
		for(i = 0; i < selectList.length; i++) {
			if(selectList.options[i].value == val) {
				selectList.selectedIndex = i;
			}
		}
	}
}
function setTipHeight()
{
	is_ie = navigator.userAgent.indexOf("MSIE 6.");
	is_ie = navigator.userAgent.indexOf("MSIE 5.");
	if ((is_ie6 < 50 && is_ie6 > 0) || (is_ie5 < 50 && is_ie5 > 0))
	{
		actions_cont = document.getElementById("contact_us_actions_container");
		tip_container = document.getElementById("contact_tip_container");
		tip_container.style.height = (actions_cont.offsetHeight-18)+"px";
	}
}
function HandleActionClick(clicked_link)
{
	clearErorrs()
	action = clicked_link.id;
	clicked_link.style.color = "#F9BD2C";
	actions = clicked_link.parentNode.getElementsByTagName("span");
	document.getElementById("contact_form_container").style.display = 'none';
	tip_container = document.getElementById("contact_tip_container");
	for (i=0; i<actions.length; i++)
	{
		if (actions[i] != clicked_link)
		{
			actions[i].style.color = "#FFFFFF";
			if (actions[i].id != 'other')
			{
				document.getElementById(actions[i].id+"_tip_text").style.display = 'none';
			}
		}
	}
	if (action == 'other')
	{
		ShowContactForm(action);
	}
	else
	{
		setTipHeight();
		document.getElementById(action+"_tip_text").style.display = 'block';
		tip_container.style.display = 'block';
	}
	return false;
}
function ShowContactForm(action)
{
	document.getElementById("contact_tip_container").style.display = 'none';
	form_container = document.getElementById("contact_form_container");
	document.forms[0].cboQuestionHidden.value = "";
	document.forms[0].cboQuestion.parentNode.style.display = 'none';
	switch(action)
	{
		case 'other':
			document.forms[0].cboQuestionHidden.value = "";
			document.forms[0].cboQuestion.value = "0";
			document.forms[0].cboQuestion.parentNode.style.display = 'inline';
			break;
		case 'customercare':
			document.forms[0].cboQuestionHidden.value = "Customer care information";
			break;
		case 'purchase':
			document.forms[0].cboQuestionHidden.value = "Where and how can I purchase a RAYMOND WEIL watch";
			break;
		case 'braceletstrap':
			document.forms[0].cboQuestionHidden.value = "Bracelet, strap and links inquiry";
			break;
			
	}
	checkIfShowCityList();
	form_container.style.display = 'block';
}

function checkIfShowCityList()
{
	document.getElementById("contact_us_select_city").style.display = "none";
	removeChildsOfElement(document.getElementById("cboCity"));
	if(document.forms[0].cboQuestionHidden.value == "Customer care information" || document.forms[0].cboCountry.value == 'SA') {
		var selectedCountry = document.getElementById("cboCountry").options[document.getElementById("cboCountry").selectedIndex].value;
		for(country in SAVCountryCities) {
			if(country == selectedCountry) {
				createSelectItem(document.getElementById("cboCity"), 0, cmsPleaseSelectLabel, 1);
				for(record in SAVCountryCities[country]) {
					createSelectItem(document.getElementById("cboCity"), SAVCountryCities[country][record]['id'], SAVCountryCities[country][record]['city'], 0);
				}
				document.getElementById("contact_us_select_city").style.display = "block";
				break;
			}
		}
	}
}

function removeChildsOfElement(parent) {
	while(parent.childNodes.length>0) {
		parent.removeChild(parent.lastChild);
	}
}

function createSelectItem(parent, value, text, selected) {
	var option = document.createElement("option");
	option.setAttribute("value", value);
	var optionText = document.createTextNode(text);
	option.appendChild(optionText);
	if(selected) {
		option.setAttribute("selected", selected);
	}
	parent.appendChild(option);
}