/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_changePic																							*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_changePic ()
{
	if (currPic == numPics)
		currPic = 1;
	else
		currPic++;

	hufshonet_showPic (document.getElementById("zimmerPic" + currPic), currPic, false);
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_showPic																							*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_showPic (oImg, i, manual)
{
	var oMovie = document.getElementById("movie");

	if (oMovie != undefined)
	{
		oMovie.innerHTML 	   	= "";
		oMovie.style.display 	= "none";
	}

	document.getElementById("map").style.display 	= "none";

	if (manual)
		clearInterval (changePicInterval);

	var pic = oImg.src.replace(/size3/, "size2");
	document.getElementById("zimmerPic_bigPicImg").src = pic;
	document.getElementById("zimmerPageGallery_picText").innerHTML = document.getElementById("zimmerPicTitle" + i).innerHTML;
}

var alreadyInitMap = false;
/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_showMap																							*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_showMap ()
{
	clearInterval (changePicInterval);

	document.getElementById("zimmerPic_bigPicImg").src = "designFiles/noPic.jpg";
	if (!alreadyInitMap)
	{
		g_waze_map_init();
		alreadyInitMap = true;
	}

	var oMovie = document.getElementById("movie");

	if (oMovie != undefined)
	{
		oMovie.innerHTML 	   = "";
		oMovie.style.display = "none";
	}

	document.getElementById("map").style.display = "";
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_showMovie																							*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_showMovie ()
{
	clearInterval (changePicInterval);

	document.getElementById("zimmerPic_bigPicImg").src = "designFiles/noPic.jpg";

	document.getElementById("map").style.display   = "none";

	document.getElementById("movie").innerHTML 	   = document.getElementById("movieHtml").innerHTML
	document.getElementById("movie").style.display = "";
}

var countUp = 0;

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_goUp																								*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_goUp (maxUp)
{
	oDiv = document.getElementById('ticker');

	if (document.all)
		var currTop = oDiv.style.pixelTop;
	else
		var currTop = oDiv.style.top.substr(0, oDiv.style.top.length-2);

	if (currTop <= 0 && countUp < maxUp)
	{
		countUp++;

		if (document.all)
			oDiv.style.pixelTop -= 67
		else
			oDiv.style.top = currTop - 67 + "px";

		oDiv.innerHTML = scroll_msg 
	}
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_goDown																								*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_goDown ()
{
	oDiv = document.getElementById('ticker');

	if (document.all)
		var currTop = oDiv.style.pixelTop;
	else
		var currTop = oDiv.style.top.substr(0, oDiv.style.top.length-2) * 1;

	if (currTop <0)
	{
		countUp--;

		if (document.all)
			oDiv.style.pixelTop += 67
		else
			oDiv.style.top = currTop + 67 + "px";

		oDiv.innerHTML = scroll_msg 
	}
}

var xmlRequest = new xmlObj(false);

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_onSelectArea																						*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_onSelectArea (formName)
{
	if (formName == undefined)
		formName = "topSearchForm";

	var oForm	= document.getElementById(formName);

	var xml = "<data>" +	
					"<command>private.getSearchEngineOptions</command>"	+
					"<formName>"	+ formName						+ "</formName>"		+
					"<areaId>"		+ oForm.area.value				+ "</areaId>" 		+
					"<cityId></cityId>" 							+
			  "</data>";

	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "hufshonet_onSelectArea_response");
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_onSelectArea_response																				*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_onSelectArea_response (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));

	try
	{
		var returnCode 	= xmlRequest.getValue("returnCode");
		var formName 	= xmlRequest.getValue("formName");
		var cityOptions = xmlRequest.getValue("cityOptions");
		var catOptions  = xmlRequest.getValue("catOptions");

		if (returnCode == "OK")
		{
			document.getElementById(formName + "_cityOptions_spn").innerHTML 	= cityOptions;
			document.getElementById(formName + "_catOptions_spn").innerHTML 	= catOptions;
		}
	}
	catch (e)
	{
	}
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_onSelectCity																						*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_onSelectCity ()
{
	var oForm	= document.getElementById("topSearchForm");

	var xml = "<data>" +	
					"<command>private.getSearchEngineOptions</command>"	+
					"<formName>topSearchForm</formName>"				+
					"<areaId>"		+ oForm.area.value					+ "</areaId>" 		+
					"<cityId>"		+ oForm.city.value					+ "</cityId>" 		+
			  "</data>";

	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "hufshonet_onSelectCity_response");
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_onSelectCity_response																				*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_onSelectCity_response (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));

	try
	{
		var returnCode 	= xmlRequest.getValue("returnCode");
		var catOptions  = xmlRequest.getValue("catOptions");

		if (returnCode == "OK")
		{
			document.getElementById("topSearchForm_catOptions_spn").innerHTML 	= catOptions;
		}
	}
	catch (e)
	{
	}
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_onSelectPrice																						*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_onSelectPrice (searchId)
{
	var oForm	= document.getElementById("inSearchEngineForm");

	var xml = "<data>" +	
					"<command>private.getInSearchEngineOptions</command>"	+
					"<searchId>"	+ searchId								+ "</searchId>" 	+
					"<price>"		+ oForm.price.value						+ "</price>" 		+
					"<priceOf>"		+ oForm.priceOf.value					+ "</priceOf>" 		+
			  "</data>";

	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "hufshonet_onSelectPrice_response");
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_onSelectPrice_response																				*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_onSelectPrice_response (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));

	try
	{
		var returnCode 	= xmlRequest.getValue("returnCode");
		var options  = xmlRequest.getValue("priceOfOptions");

		if (returnCode == "OK")
		{
			document.getElementById("priceOf_div").innerHTML 	= options;
		}
	}
	catch (e)
	{
	}
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_submitGetOffersForm																				*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_submitGetOffersForm ()
{
	var formValidator = new Validator("getOffersForm");

	formValidator.clearAllValidations ();
		
	formValidator.addValidation("area",			"required",		"יש לבחור אזור בארץ");
	formValidator.addValidation("fullname",		"required",		"יש להזין את שמך המלא");
	formValidator.addValidation("phone",		"required",		"יש להזין מספר טלפון");
	formValidator.addValidation("email",		"required",		"יש להזין אימייל");
	formValidator.addValidation("email",		"email",		"יש להזין אימייל חוקי");

	if (formValidator.validate ())
	{
		var oForm = document.getElementById("getOffersForm");

		if (oForm.dateField1.value == "" || oForm.dateField1.value == "מתאריך")
		{
			alert ("יש לבחור תאריך");
			oForm.dateField1.focus ();
			return false;
		}

		if (oForm.dateField2.value == "" || oForm.dateField2.value == "עד")
		{
			alert ("יש לבחור עד תאריך");
			oForm.dateField2.focus ();
			return false;
		}

		return true;
	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_printSelected																						*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_printSelected ()
{
	var i = 1;

	oCheckbox = document.getElementById("checkbox" + i);

	checked = "";
	while (oCheckbox != undefined)
	{
		if (oCheckbox.checked)
		{
			if (checked != "") checked += ",";

			checked += oCheckbox.value;
		}	
		
		i++;

		oCheckbox = document.getElementById("checkbox" + i);
	}

		
	if (checked == "")
	{
		alert ("יש לסמן לפחות צימר אחד")
	}
	else
	{
		window.open ("index2.php?id=315&zimmerIds=" + checked);
	}
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_markStar																							*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_markStar (starNo)
{
	for (i = 1; i <= starNo; i++)
	{
		document.getElementById("star" + i).src = "designFiles/star.png";
	}	
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_unmarkAllStars																						*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_unmarkAllStars ()
{
	for (i = 1; i <= 5; i++)
	{
		document.getElementById("star" + i).src = "designFiles/emptyStar.png";
	}
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_gradeZimmer																						*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_gradeZimmer (grade, zimmerId)
{
	var xml = "<data>" +	
					"<command>private.gradeZimmer</command>"	+
					"<zimmerId>"	+ zimmerId			+ "</zimmerId>"		+
					"<grade>"		+ grade				+ "</grade>" 		+
			  "</data>";

	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "hufshonet_afterGradeZimmer");
}

/* ------------------------------------------------------------------------------------------------------------	*/
/* hufshonet_afterGradeZimmer																					*/
/* ------------------------------------------------------------------------------------------------------------	*/
function hufshonet_afterGradeZimmer (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));

	try
	{
		var returnCode 	= xmlRequest.getValue("returnCode");

		if (returnCode == "OK")
		{
			alert ("תודה על דירוגך");
			window.location.reload ();
		}
	}
	catch (e)
	{
	}
}

