var xmlRequest = new xmlObj(false);
/* ------------------------------------------------------------------------------------------------ */
/* submitLogInForm */
/* ------------------------------------------------------------------------------------------------ */
function clearUserNameValue()
{
	document.getElementById("username").value = "";
}
function submitLoginForm()
{
	var formValidator = new Validator('theForm');
	formValidator.addValidation('username', 'required', 'יש להזין שם משתמש');
	formValidator.addValidation('password', 'required', 'יש להזין סיסמא');
	if (formValidator.validate ())
	{
		return true;
	}

}
/* ------------------------------------------------------------------------------------------------ */
/* check date */
/* ------------------------------------------------------------------------------------------------ */
function isdate()
{
	var day, year, month;
	day=document.getElementById("form2_bday").value;
	month=document.getElementById("form2_bmonth").value;
	year=document.getElementById("form2_byear").value;
	if ((day!=00)&&(month!=00)&&(year!=0000))
	{
		if ((month==04)||(month==06)||(month==09)||(month==11))
		{
			if(day>30)
				{
					alert("בחודש "+month+" יש עד 30 ימים");
					return false;
				}
		}

		if(month==02)
		{
				if(day>28)
				{
					if (year % 4 != 0)
					{
						alert("בחודש "+month+" יש עד 28 ימים");
						return false;	
					}
				}
		}	
		
		if (year % 4 == 0)
		{
				if(month==02)
				{
					if(day>29)
					{
						alert("בחודש "+month+" יש עד 28 ימים");
						return false;	
					}
				}
		}
		document.getElementById("birthDate").value=year+"-"+month+"-"+day;
	}
	return true;
}

/* ------------------------------------------------------------------------------------------------ */
/* check password */
/* ------------------------------------------------------------------------------------------------ */
function checkGamerPassword () 	
{
	
	var password  = document.getElementById("password").value;
	var cNewPassword = document.getElementById("cNewPassword").value;
		if (password.value != cNewPassword.value)
		{
			alert("הסיסמא שהזנת שנית לא נכונה");
			cNewPassword.value = "";
			cNewPassword.focus();
			return false;
		}	
		if (password.value != "" && cNewPassword.value != "" && password.value != cNewPassword.value)
		{
			alert("הסיסמא שהזנת שנית לא נכונה");
			cNewPassword.value = "";
			cNewPassword.focus();
			return false;
		}	
		if ((password.value != "" && cNewPassword.value == "") || (password.value == "" && cNewPassword.value != ""))
		{
			alert("כדי לשנות סיסמא יש להזין סיסמא ולאמת אותה");
			password.value = "";
			cNewPassword.value = "";
			password.focus();
			return false;		
		}
	if (isdate() && isNumber("icq"))
		document.getElementById("formAddUsers").submit();	
	return false;
}
/* ------------------------------------------------------------------------------------------------ */
/* submitSiteRegisterForm */
/* ------------------------------------------------------------------------------------------------ */
function submitMembersForm ()
{
	var formValidator = new Validator('formAddUsers');

	oForm = document.getElementById("formAddUsers");

	var newPlatforms = "";
	var picName = "";
	var theNickname = oForm.nickname.value;
	setFilesNames("formAddUsers");
	formValidator.addValidation('email', 'required', 'יש להזין דואר אלקטרוני');
	formValidator.addValidation('email', 'email', 'יש להזין דואר אלקטרוני חוקי');
	formValidator.addValidation('newUsername', 'required', 'יש להזין שם משתמש');
	formValidator.addValidation('password', 'required', 'יש להזין סיסמא');
	formValidator.addValidation('cNewPassword', 'required', 'יש להזין סיסצא חוזרת');
	if (theNickname == "")
	{
		alert("יש להזין כנוי שיוצג באתר");
		 oForm.nickname.focus();
		return false;
	}
	if (oForm.agree.checked == false)
	{
		alert("חובה לאשר את ההסכמה לתנאי השימוש");
		oForm.agree.focus();
		return false;
	}
	if (formValidator.validate ())
	{
		newPlatforms = creatNewPlatforms ();
		if(newPlatforms == "")
		{
			alert("יש לבחור לפחות פלטפורמה אחת");
			return false;
		}
		document.getElementById("newPlatforms").value=newPlatforms;
		checkGamerPassword ();		 
	}

	return false; 
}

/* ------------------------------------------------------------------------------------------------ */
/* submitPopupMembersForm */
/* ------------------------------------------------------------------------------------------------ */
function submitPopupMembersForm (formName)
{
	oForm = document.getElementById(formName);
	oForm.nickname.value = oForm.username.value;

	var formValidator = new Validator(formName);
	
	formValidator.addValidation("email", 	"required", 	"יש להזין דואר אלקטרוני");
	formValidator.addValidation("email", 	"email", 		"יש להזין דואר אלקטרוני חוקי");
	formValidator.addValidation("username", "required", 	"יש להזין שם משתמש");

	if (formValidator.validate ())
	{
		if (oForm.agree.checked == false)
		{
			alert("חובה לאשר את ההסכמה לתנאי השימוש");
			oForm.agree.focus();
			return false;
		}
		else
		{
			return true;
		}
	}

	return false;
}

/* -------------------------------- */
/* deleteFriend					*/
/* -------------------------------- */
function deleteFriend (friendId)
{
	var del=confirm("האם אתה בטוח");
	if (del==true)
	{
  			xml = "<data>" +
						"<command>private.deleteFriend</command>" +
						"<friendId>"+friendId+"</friendId>"	+
				  "</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterDeleteFriend");
	}
	else
  	{
  		return;
  	}
}

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

	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == 1)
		{		
			alert ('מחיקת החבר הושלמה');
			window.location.reload();
		}
		else if (returnValue == 0)
			alert ('אין אפשרות למחוק חבר זה');
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}

/* -------------------------------- */
/* addFriend					*/
/* -------------------------------- */
function addFriend (friendId)
{
  	xml = "<data>" +
				"<command>private.addFriend</command>" +
				"<friendId>"+friendId+"</friendId>"	+
		 "</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterAddFriend");
}

/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterAddFriend																											*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterAddFriend (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == 1)
		{		
			alert ('החבר התווסף בהצלחה');
			window.location.reload();
		}
		else if (returnValue == 2)
			alert ('חבר זה כבר קיים אצלך ברשימה');
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* submitCompanyForm																											*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/

function submitCompanyForm()
{
	var nameENG = document.getElementById("nameENG").value;
	if (nameENG!="")
	{
		xml = "<data>" +
				"<command>private.checkCompany</command>" +
				"<nameENG>"+nameENG+"</nameENG>"	+
			 "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterAddCompany");
	}
	else
	{
		alert("יש להזין את שם החברה באנגלית");
		document.getElementById("nameENG").focus();
	}
		
	return false;
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* submitCompanyFormContinue																											*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function submitCompanyFormContinue()
{
	tinyMCE.triggerSave();

	var aboutCompany = document.getElementById("aboutCompany").value;
	var newGaners="";
	var newPlatforms = "";		
	if (aboutCompany != "")
	{
		newGaners=creatNewGaner();
		newPlatforms=creatNewPlatforms();
		document.getElementById("newGaners").value=newGaners;
		document.getElementById("newPlatforms").value = newPlatforms;
		if (isEnglish("החברה"))
		{
			setFilesNames("formAddCompany");
			document.getElementById("formAddCompany").submit();	
		}
	}
	else
	{
		alert("יש להזין את אודות החברה");
		document.getElementById("aboutCompany").focus();
	}
	return false;
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterAddCompany																											*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterAddCompany (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue != 0)
		{		
			alert ('חברה זאת כבר קיימת באתר');
			window.location = "/index2.php?id="+returnValue;
		}
		else
		{
			submitCompanyFormContinue();
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* displayPlatforns																											*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function displayPlatforms()
{
	document.getElementById("platformsOptions").style.display="block";
	document.getElementById("selectPlatform").style.display="none";
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	creatNewGaner																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function creatNewGaner()
{
	var newGaners="";
	var chk=document.getElementsByName("ganers");
	for (var i = 0; i < chk.length; i++)
	{
		if (chk[i].checked == true)
		{
			if (newGaners!="")
				newGaners+=",";
			newGaners+=chk[i].value;	
		}
	}
	if (newGaners!="")
	{
		newGaners =","+newGaners+",";
	}
	return newGaners;
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	creatNewPlatforms																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function creatNewPlatforms()
{
	var chk = document.getElementsByName("platforms");
	var newPlatforms="";
	for (i=0; i<chk.length; i++)
		{
			if (chk[i].checked == true)
			{
				if (newPlatforms != "")
					newPlatforms += ",";
				newPlatforms += chk[i].value;
			}
		}
	if (newPlatforms!="")
	{
		newPlatforms =","+newPlatforms+",";
	}
	return newPlatforms;
}
var popupOpenBorderId = null;
var popupOpenFormId = null;
var popupOpenHeight = null;
var popupOpenHeight1 = null;
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	showPopup																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function openPopup(popupBorderId,popupFormId,popHeight,popHeight1)
{	
	if (popupOpenBorderId != null && popupOpenFormId != null)
	{
		document.getElementById(popupOpenBorderId).style.display="none";
		document.getElementById(popupOpenFormId).style.display="none";
	}
	
	popupOpenBorderId = popupBorderId;
	popupOpenFormId = popupFormId;
	popupOpenHeight = popHeight;
	popupOpenHeight1 = popHeight1;

	//--top position
	document.getElementById(popupFormId).style.top = popHeight+"px";
	document.getElementById(popupBorderId).style.top = popHeight1+"px";

	// right position
	if (document.getElementById(popupBorderId).className == "newPopupBorder")	// wide new popup
		popupWidth = 740;
	else
		popupWidth = 408;

	document.getElementById(popupFormId).style.right = (screen.availWidth-popupWidth)/2+"px"; 
	document.getElementById(popupBorderId).style.right = (screen.availWidth-popupWidth-40)/2+"px";
		
	//show popup
	document.getElementById(popupBorderId).style.display="block";
	document.getElementById(popupFormId).style.display="block";	
	
	//insert height to div border;
	divHeight= document.getElementById(popupFormId).offsetHeight;
	document.getElementById(popupBorderId).style.height = (divHeight+40)+"px";

}

var clickForAddNewEssay = false;

/* ----------------------------------------------------------------------------------------------------------------------------	*/
/*  games_openAddEssayForm																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function games_openAddEssayForm (event)
{
	if (document.getElementById("popupFormAddNews") != undefined)
	{
		document.getElementById("addEssayWithPageId").value = "0";
	}

	clickForAddNewEssay = true;

	point_it ("popupBorderAddNews", "popupFormAddNews", "addNews",event);

	clickForAddNewEssay = false;
}

/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	point_it																													*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function point_it(popupBorderId,popupFormId,divId,e)
{
	if (document.getElementById(popupFormId) != undefined)
	{
		oFader = document.getElementById("fader");
		if (oFader != undefined)
		{
			oFader.style.height = document.documentElement.scrollHeight + "px";
			oFader.style.width = "100%";
			oFader.style.display = "";
		}
		var mp = getMousePosition(e);  
		pos_y=mp.y;
		pos_y1 = pos_y-20;	

		if (document.getElementById("addEssayWithPageId") != undefined && !clickForAddNewEssay)	
			document.getElementById("addEssayWithPageId").value = "1";

		openPopup(popupBorderId,popupFormId,pos_y,pos_y1);	
	}
}
function getMousePosition(e) 
{ 
//	return e.pageX ? {'y':e.pageY} : {'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop}; 
	return e.pageX ? {'y': window.pageYOffset + 50} : {'y': document.documentElement.scrollTop + document.body.scrollTop + 50}; 
} 

/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	closeWindow																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function closePopup(popupBorderId,popupFormId,formName)
{
	oFader = document.getElementById("fader");
	if (oFader != undefined)
	{
		oFader.style.display = "none";
	}
	document.getElementById(popupBorderId).style.display="none";
	document.getElementById(popupFormId).style.display="none";
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	addPlatform																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function addPlaform(possible)
{
	var platformName = document.getElementsByName("morePlatforms");
	var subPlatform="";
	if (possible=="0")
	{
		alert("רק משתמשים רשומים יכולים להוסיף פלטפורמה");
		document.getElementById("morePlatforms").style.display="none";
		return;
	}
	for (var i=0; i<platformName.length;i++)
	{
		if (platformName[i].checked==true)
		{		
			subPlatform=platformName[i].value;
			break;
		}
	}

	xml = "<data>" +
				"<command>private.addPlatform</command>"+
				"<subPlatform>"+subPlatform+"</subPlatform>"+
			"</data>";

	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterAddPlatform");	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterAddPlatform																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterAddPlatform (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == 1)
		{		
			window.location.reload();
		}
		else
		{
			alert ('לא');
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* showSubPlatform																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function showSubPlatform (check)
{
	if(check.checked == true)
	{
		document.getElementById("platformsOptions").style.display="block";	
	}
	else
	{
		document.getElementById("platformsOptions").style.display="none";
	}
	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* showSubGaners																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function showSubGaners (check)
{
	
	if(check.checked == true)
	{
		document.getElementById("ganersOptions").style.display="block";	
	}
	else
	{
		document.getElementById("ganersOptions").style.display="none";
	}
	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* submitGameForm																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function submitGameForm()
{
	tinyMCE.triggerSave();

	var formValidator = new Validator('formAddGames');
	var grade;
	var platformId = "";
	var newGaners="";
	var newNumPlayers = "";
	var NumPlayers=document.getElementsByName("numPlayers");
	var platforms=document.getElementsByName("platforms");
	formValidator.addValidation('nameENG', 'required', 'יש להזין את שם המשחק באנגלית');
	formValidator.addValidation('fullDesc', 'required', 'יש להזין את התיאור של המשחק');
	grade=document.getElementById("startGrade").value;
	if (formValidator.validate ())
	{
		if (grade=="selectGrade")
		{
			alert("יש לבחור ציון התחלתי למשחק");
			return false;
		}
		newGaners = creatNewGaner();
		if (newGaners=="")
		{
			alert("יש לבחור לפחות ז'אנר אחד");
			return false;
		}
		for(var i=0;i<platforms.length;i++)
		{
			if(platforms[i].checked == true)
			{
				platformId += platforms[i].value;
				break;
			}formIdOpen
		}
		if (platformId == "")
		{
			alert("יש לבחור פלטפורמה");
			return;
		}
		document.getElementById("newGaners").value=newGaners;
		document.getElementById("platformId").value = platformId;
		for(var i=0;i<NumPlayers.length;i++)
		{
			if(NumPlayers[i].checked == true)
			{
				if(newNumPlayers!="")
				{
					newNumPlayers+=",";
				}
				newNumPlayers += NumPlayers[i].value;
			}
		}
		if (newNumPlayers != "")
		{
			newNumPlayers=","+newNumPlayers+",";
		}
		document.getElementById("newNumPlayers").value=newNumPlayers;
		if (isdate() && isEnglish("המשחק"))
		{
			gameExist(document.getElementById("nameENG").value,platformId);
		}
	}
	return false;
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* isEnglish																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function isEnglish(type)
{
	var nameENG=document.getElementById("nameENG").value;
	var charpos = nameENG.search("[^A-Za-z0-9'\.:\\-& ]"); 
    if(nameENG.length > 0 &&  charpos >= 0) 
    { 
       	alert("שם " + type + " יכול להכיל רק אותיות באנגלית");
		document.getElementById("nameENG").focus();
		return false;
	}	
	return true;
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* isNumber																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function isNumber(type)
{
	var value=document.getElementById(type).value;
	if (value != "")
	{
		var charpos = value.search("[^0-9]"); 
    	if(value.length > 0 &&  charpos >= 0) 
    	{ 
       		alert("שדה "+type+" יכול להכיל רק ספרות");
			document.getElementById(type).focus();
			return false;
		}
	}	
	return true;
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* gameExist																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function gameExist(nameENG,platformId)
{
	xml = "<data>" +
				"<command>private.gameExist</command>"+
				"<nameENG>"+nameENG+"</nameENG>"+
				"<platformId>"+platformId+"</platformId>"+
			"</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterGameExist");	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterGameExist																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterGameExist(i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var pageId = document.getElementById("pageId").value;
		var platformId = document.formAddGames.ganers.value;
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == 0)
		{
			setFilesNames("formAddGames");	
			document.getElementById("formAddGames").submit();
		}
		else if (returnValue == 1)
		{
			setFilesNames("formAddGames");	
			document.getElementById("isExist").value="1";
			document.getElementById("formAddGames").submit();		
		}
		else
		{
			alert("משחק זה כבר קיים באתר");
			window.location = "/index2.php?id="+returnValue+"&lang=HEB";
		}
		
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* showAddToMyGame																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function showAddToMyGame()
{
	document.getElementById("addToMyGame").style.display="block";
}

/* ------------------------------------------------------------------------------------------------ */
/* setFilesNames																					*/
/* ------------------------------------------------------------------------------------------------ */
function setFilesNames (formName)
{
	oForm = document.getElementById(formName);

	filesNamesStr = "";

	if (document.getElementById("picsTbl1") == undefined)
		oTbl = document.getElementById("picsTbl").getElementsByTagName("tbody")[0];
	else
		oTbl = document.getElementById("picsTbl1").getElementsByTagName("tbody")[0];

	numPics = oTbl.rows.length;

	for (r=1; r<numPics; r++)
	{
		row = oTbl.rows[r];

		picName = row.cells[1].childNodes[1].id;

		if (filesNamesStr != "") filesNamesStr += " ";

		filesNamesStr += picName.replace(/\s/g, "_");
	}
	oForm.filesNames.value = filesNamesStr;
}
/* -------------------------------- */
/* addToMyGame					*/
/* -------------------------------- */
function addToMyGame ()
{
	if (document.getElementById("password").value == "")
	{
		alert("ההוספה היא לגולשים רשומים בלבד.");
		closePopup("addToMyGameBorder","addToMyGame","myGame");
		return;
	}
	
	var isFavorite, isForSale, isForBuy, isPlayingNow;
	var pageId = document.getElementById("pageId").value;
	isFavorite = "0";
	isForSale = "0";
	isForBuy = "0";
	isPlayingNow = "0";

	if (document.getElementById("isFavorite").checked==true) isFavorite="1";
	if (document.getElementById("isForSale").checked==true) isForSale="1";
	if (document.getElementById("isForBuy").checked==true) isForBuy="1";
	if (document.getElementById("isPlayingNow").checked==true) isPlayingNow="1";

  	xml = "<data>" +
				"<pageId>"+pageId+"</pageId>"	+
				"<command>private.addToMyGame</command>" +
				"<isFavorite>"+isFavorite+"</isFavorite>"	+
				"<isForSale>"+isForSale+"</isForSale>"	+
				"<isForBuy>"+isForBuy+"</isForBuy>"	+
				"<isPlayingNow>"+isPlayingNow+"</isPlayingNow>"	+
		 "</data>";

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

/* -------------------------------- */
/* addForSale						*/
/* -------------------------------- */
function addForSale (isMemberLogin, pageId, isFavorite, isForBuy, isPlayingNow)
{
	if (isMemberLogin == "0")
	{
		alert("ההוספה היא לגולשים רשומים בלבד.");
		return;
	}
	
  	xml = "<data>" +
				"<pageId>"+pageId+"</pageId>"	+
				"<command>private.addToMyGame</command>" +
				"<isFavorite>"+isFavorite+"</isFavorite>"	+
				"<isForSale>1</isForSale>"	+
				"<isForBuy>"+isForBuy+"</isForBuy>"	+
				"<isPlayingNow>"+isPlayingNow+"</isPlayingNow>"	+
		 "</data>";

	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterAddToMyGame");
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterAddToMyGame																												*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterAddToMyGame (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("done");
		var pageId = xmlRequest.getValue("pageId");
		var forSale = xmlRequest.getValue("forSale");
		var rowNum = xmlRequest.getValue("rowNum");

		if (forSale != 1)
		{		
			window.location.reload();
		}
		else
		{
			window.location = "/index2.php?id=117&page="+pageId+"&item="+rowNum;
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* -------------------------------- */
/* updateGameData		    	*/
/* -------------------------------- */
function updateGameData(tableName,rowId,nameField)
{
	tinyMCE.triggerSave();
	var fieldValue = "";
	var fieldValue1 = "";
	var theChangeType = "";
	switch (nameField)
	{
		case "companyId":
			fieldValue = document.editCompany.companies.value;
		break;
		case "exitDate":
			if (isdate())
			{
				fieldValue = document.getElementById("birthDate").value;
			}
			else
				return;
		break;
		case "ganers":
			var newGaners = "";
			newGaners = creatNewGaner();
			if (newGaners)
			{
				fieldValue = newGaners;
			}
			else
			{
				alert("יש לבחור לפחות ז'אנר אחד");
				return;
			}
		break;
		case "numPlayers":
			var newNumPlayers = "";
			var NumPlayers=document.getElementsByName("numPlayers");

			for(var i=0;i<NumPlayers.length;i++)
			{
				if(NumPlayers[i].checked == true)
				{
					if(newNumPlayers!="")
					{
						newNumPlayers+=",";
					}
					newNumPlayers += NumPlayers[i].value;
				}	
			}
			if (newNumPlayers!="")
			{
				newNumPlayers =","+newNumPlayers+",";
			}
			fieldValue=newNumPlayers;
		break;
		case "videoSource":
			var videoCode = document.getElementById("videoCode").value;
			if (videoCode == "")
			{
				alert("ריק");
				closePopup("popupBorderAddMovie","popupFormAddMovie","popupAddMovie");
				return false;
			}
			if (videoCode.match("param name=\"movie\" value=\"http://www.youtube.com/v") == null)
			{
				alert("הקוד לא זוהה כ-embed של YouTube");
				closePopup("popupBorderAddMovie","popupFormAddMovie","popupAddMovie");
				return false;
			}
			videoCode = videoCode.replace(/width=\"\d+\" height=\"\d+\"/g,"width=\"260\" height=\"210\"");
			fieldValue = videoCode;
		break;
		case "fullDesc":
			fieldValue 		= document.getElementById("fullDesc").value;
			fieldValue1 	= document.getElementById("shortDesc").value;
			theChangeType 	= document.getElementById("changeType").value;
		break;
		case "buildYear":
			fieldValue = document.getElementById("buildYear").value;
		break;
		case "description":
			fieldValue = document.getElementById("fullDescription").value;
		break;
		case "youKnowText":
			fieldValue = document.getElementById("youKnow").value;
		break;
		case "active":
			var statusCompaby = document.getElementsByName("statusCompany");
			for (var i=0; i<statusCompaby.length; i++)
			{
				if (statusCompaby[i].checked == true)
				{
					fieldValue = statusCompaby[i].value;
					break;
				}
			}
			if (fieldValue == "enactive")
			{
				fieldValue += "," + document.getElementById("dismantlingYear").value; 
			}
		break;
		case "platforms":
			fieldValue = creatNewPlatforms();
		break;
		case "LinksTo":
			fieldValue = document.getElementById("LinksTo").value;
		break;
		default:
		window.location.reload();
	}
	
	if (nameField != "picFile")
	{
		xml = "<data>" +
				"<command>private.updateGameData</command>" +
				"<fieldValue><![CDATA["+fieldValue+"]]></fieldValue>" +
				"<fieldValue1><![CDATA["+fieldValue1+"]]></fieldValue1>" +
				"<changeType>"+theChangeType+"</changeType>"+
				"<tableName>"+tableName+"</tableName>" +
				"<rowId>"+rowId+"</rowId>" +
				"<nameField>"+nameField+"</nameField>" +
		 "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterUpdateGameData");
	}
  	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterUpdateGameData																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterUpdateGameData (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == "ok")
		{
			document.getElementById(popupOpenBorderId).style.display="none";
			document.getElementById(popupOpenFormId).style.display="none"; 
			openPopup('popupAfterSend','popupText',popupOpenHeight,popupOpenHeight1);
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* uploadGameData																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function uploadGameData (tableName,rowId,nameField)
{
	var filesNames, dirName;

	setFilesNames("addScreanshot");
	filesNames = document.getElementById("filesNames").value;
	dirName = document.getElementById("filesDir").value;
	picDesc = document.getElementById("picDesc").value;

	if (filesNames == "")
	{
		alert("יש להוסיף תמונה");
		return;
	}
	if (picDesc == "")
	{
		alert("יש להזין תיאור לתמונה");
		document.getElementById("picDesc").focus();
		return;
	}

	xml = "<data>" +
			"<command>private.uploadGameData</command>" +
			"<filesNames>"+filesNames+"</filesNames>" +
			"<tableName>"+tableName+"</tableName>" +
			"<rowId>"+rowId+"</rowId>" +
			"<nameField>"+nameField+"</nameField>" +
			"<dirName>"+dirName+"</dirName>" +
			"<picDesc>"+picDesc+"</picDesc>" +
		 "</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterUploadGameData");

}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterUploadGameData																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterUploadGameData (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == "ok")
		{		
			document.getElementById(popupOpenBorderId).style.display="none";
			document.getElementById(popupOpenFormId).style.display="none"; 
			openPopup('popupAfterSend','popupText',popupOpenHeight,popupOpenHeight1);
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* clearAreaAddMovie																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function clearAreaAddMovie()
{
	
	var videoCode = document.getElementById("videoCode").value;

	if (videoCode == "Enter YouTube Embed code here")
	{
		videoCode = "";
		document.getElementById("videoCode").value = videoCode;
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* openSelectBoxDismantlingYear																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function openSelectBoxDismantlingYear()
{
	document.getElementById("SelectBoxDismantlingYear").style.display="block";
	document.getElementById("contentActive").style.width="116px";
	document.getElementById("contentEnactive").style.width="116px";
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* closeSelectBoxDismantliformIdOpenngYear																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function closeSelectBoxDismantlingYear()
{
	document.getElementById("SelectBoxDismantlingYear").style.display="none";
	document.getElementById("contentActive").style.width="184px";
	document.getElementById("contentEnactive").style.width="184px";
}
var formIdOpen = null;
var toShowIdOpen = null;
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* openContent																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/

function openContent(formId, toShowId)
{
	
	if (formIdOpen != null && toShowIdOpen != null )
	{
		document.getElementById(formIdOpen).style.display="none";
		document.getElementById(toShowIdOpen).innerHTML = "לצפייה בתוכן לחץ<span class='openContentConfirm' onclick=\"openContent('"+formIdOpen+"','"+toShowIdOpen+"')\"> כאן</span>";
	}
	formIdOpen = formId;
	toShowIdOpen = toShowId;

	document.getElementById(formIdOpen).style.display="block";
	document.getElementById(toShowIdOpen).innerHTML = "<div><span class='closeContentConfirm' onclick=\"closeContent('"+formId+"','"+toShowId+"')\">סגור</span></div>";
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* openContent																									                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/

function closeContent(formId,toShowId)
{
	document.getElementById(formIdOpen).style.display="none";
	document.getElementById(toShowId).innerHTML = "לצפייה בתוכן לחץ<span class='openContentConfirm' onclick=\"openContent('"+formId+"','"+toShowId+"')\"> כאן</span> ";
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* addEssays																									                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function addEssays(formId,pageId,formType)
{
	tinyMCE.triggerSave();
	var title, subtitle, txt, grade, gradeXml,filesNames, dirName,newsPicDesc;

	grade = "";
	filesNames=""; 
   	dirName="";
	newsPicDesc = "";

	switch (formType)
	{
		case "news":
			title = document.getElementById("addNewsTitle").value;
			subtitle = document.getElementById("addNewsSubtitle").value;
			txt = document.getElementById("addNewsTxt").value;
			document.getElementById("newsFileName").value = document.getElementById("newsFileName_spn").innerHTML;
			filesNames = document.getElementById("newsFileName").value;
			dirName = document.getElementById("newsFileDir").value;
			newsPicDesc = document.getElementById("newsPicDesc").value;

			if (document.getElementById("addEssayWithPageId") != undefined && document.getElementById("addEssayWithPageId").value == "0")
				pageId = "";

			break;
		case "cheats":
			title = document.getElementById("addCheatTitle").value;
			subtitle = document.getElementById("addCheatSubtitle").value;
			txt = document.getElementById("addCheatTxt").value;
		break;
		case "review":
			title = document.getElementById("addReviewTitle").value;
			subtitle = document.getElementById("addReviewSubtitle").value;
			txt = document.getElementById("addReviewTxt").value;
			grade = document.getElementById("addReviewGrade").value;
		break;
	}

	if (title == "")
	{
		alert("יש להזין כותרת ראשית");
		return;
	}
	if (subtitle == "")
	{
		alert("יש להזין כותרת משנה");
		return;
	}
	if (txt == "")
	{
		alert("יש להזין את התוכן");
		return;
	}
	if (formType == "review" && grade=="grade")
	{
		alert("יש לבחור ציון למשחק");
		return;
	}

	if (essayFileDoUpload)
	{
		alert ("יש להמתין לסיום טעינת התמונה");
	}

	xml = "<data>" +
			"<command>private.addEssays</command>" +
			"<title>"+title+"</title>" +
			"<subtitle>"+subtitle+"</subtitle>" +
			"<txt><![CDATA["+txt+"]]></txt>" +
			"<grade>"+grade+"</grade>" +
			"<pageId>"+pageId+"</pageId>" +
			"<formType>"+formType+"</formType>" +
			"<filesNames>"+filesNames+"</filesNames>" +
			"<dirName>"+dirName+"</dirName>" +
			"<newsPicDesc>"+newsPicDesc+"</newsPicDesc>" +
		 "</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterAddEssays");	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterAddEssays				     																			                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterAddEssays (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == "ok")
		{		
			document.getElementById(popupOpenBorderId).style.display="none";
			document.getElementById(popupOpenFormId).style.display="none"; 
			openPopup('popupAfterSend','popupText',popupOpenHeight,popupOpenHeight1);
		}
	}
	catch (e)
	{
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* sendPM																										                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function sendPM()
{
	var title, txt, memberToId;

	title = document.getElementById("addPMTitle").value;
	txt = document.getElementById("addPMTxt").value;
	memberToId = document.getElementById("memberToId").value;
	if (title == "")
	{
		alert("יש להזין כותרת");
		return;
	}
	xml = "<data>" +
			"<command>private.addPM</command>" +
			"<title>"+title+"</title>" +
			"<txt><![CDATA["+txt+"]]></txt>" +
			"<memberToId>"+memberToId+"</memberToId>" +
		 "</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterSendPM");	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterAddPM					     																			                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterSendPM (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == "ok")
		{		
			document.getElementById(popupOpenBorderId).style.display="none";
			document.getElementById(popupOpenFormId).style.display="none"; 
			openPopup('popupAfterSend','popupText',popupOpenHeight,popupOpenHeight1);
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* insertGrade				     																			                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function insertGrade (grade)
{
	if (grade != "")
	{
		document.getElementById(grade).selected="selected";
	}	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* delStatusGame				     																			                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function delStatusGame (gameId, typeField)
{
	var del=confirm("האם אתה בטוח");

	if (del==true)
	{
  		xml = "<data>" +
				"<command>private.delStatusGame</command>" +
				"<gameId>"+gameId+"</gameId>" +
				"<typeField>"+typeField+"</typeField>" +
			 "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterDelStatusGame");
	}
	else
  	{
  		return;
  	}
	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterDelStatusGame				     																			                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterDelStatusGame (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == "ok")
		{		
			window.location.reload();
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* updateConfirm				     																			                */
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function updateConfirm (action)
{
	try {tinyMCE.triggerSave();} catch(e) {}

	document.getElementById("action").value = action;
	document.getElementById("confirmForm").submit();
}

/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* uploadBoxShot																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function uploadBoxShot (tableName,rowId,nameField)
{
	var filesNames, dirName;
	document.getElementById("filesNames").value = document.getElementById("essayFileName_spn").innerHTML;
	filesNames = document.getElementById("filesNames").value;
	dirName = document.getElementById("filesDir").value;
	
	if (filesNames == "")
	{
			document.getElementById(popupOpenBorderId).style.display="none";
			document.getElementById(popupOpenFormId).style.display="none"; 
	} else {
		xml = "<data>" +
				"<command>private.uploadBoxShot</command>" +
				"<filesNames>"+filesNames+"</filesNames>" +
				"<tableName>"+tableName+"</tableName>" +
				"<rowId>"+rowId+"</rowId>" +
				"<nameField>"+nameField+"</nameField>" +
				"<dirName>"+dirName+"</dirName>" +
			 "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterUploadBoxShot");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* afterUploadGameData																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterUploadBoxShot (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var returnValue = xmlRequest.getValue("success");
		if (returnValue == "ok")
		{		
			document.getElementById(popupOpenBorderId).style.display="none";
			document.getElementById(popupOpenFormId).style.display="none"; 
			openPopup('popupAfterSend','popupText',popupOpenHeight,popupOpenHeight1);
		}
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* sendMail																										*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function sendPass ()
{
	var username;
	userName = document.getElementById("sendUsername").value;
	if (userName == "")
	{
		alert("יש להזין שם משתמש");
		document.getElementById("sendUsername").focus();
		return;
	}
	else
	{	
		document.getElementById("passForm").submit();
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	getResults																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
var advGaner, advPlat, advNumPlayers, advConpany, advYear, isFreeSearch, freeSearchValue;
advGaner = "";
advPlat = "";
advNumPlayers = "";
advConpany = "";
advYear = "";
isFreeSearch = false;
freeSearchValue = "";
function getResults (value, cat)
{
		
	switch (cat)
	{
		case "ganer":
			advGaner = value;
		break;
		case "platform":
			advPlat = value;
		break;
		case "company":
			advConpany = value;
		break;
		case "year":
			advYear = value;
		break;
		case "numPlayers":
			advNumPlayers = value;
		break;
		case "freeSearch":
			isFreeSearch = true;
			freeSearchValue = value;
		break;
	}

	xml = "<data>" +
			"<command>private.getResults</command>" +
			"<ganer>"+advGaner+"</ganer>" +
			"<platform>"+advPlat+"</platform>" +
			"<numPlayers>"+advNumPlayers+"</numPlayers>" +
			"<year>"+advYear+"</year>" +
			"<company>"+advConpany+"</company>" +
			"<advFreeSearch>"+freeSearchValue+"</advFreeSearch>" +
		 "</data>";
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterGetResults");

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

		var path = xmlRequest.getValue("path");
		var result = xmlRequest.getValue("result");
		document.getElementById("advSearch").innerHTML = result;
		document.getElementById("choosePath").innerHTML = path;	
	}
	catch (e)
	{
		//alert ("AJAX Error at afterGetResults: " + e.message );
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	cleanPath																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function cleanPath (cat)
{
	switch (cat)
	{
		case "ganer":
			advGaner = "";
			getResults (advGaner,cat);
		break;
		case "platform":
			advPlat = "";
			getResults (advPlat,cat);
		break;
		case "company":
			advConpany = "";
			getResults (advConpany,cat);
		break;
		case "year":
			advYear = "";
			getResults (advYear,cat);
		break;
		case "numPlayers":
			advNumPlayers = "";
			getResults (advNumPlayers,cat);
		break;	
		case "free":
			isFreeSearch = false;
			freeSearchValue = "";
			document.getElementById("freeSearch").value = "הקלד מילת חיפוש";
			getResults (freeSearchValue,cat);
		break;
	}	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	cleanInput																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function cleanInput()
{
	if (document.getElementById("freeSearch").value == "הקלד מילת חיפוש")
	{
		document.getElementById("freeSearch").value = "";	
	}
	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	advFreeSearch																									*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function advFreeSearch ()
{
	var freeSearchStr = document.getElementById("freeSearch").value;

	if ((freeSearchStr == "הקלד מילת חיפוש") || (freeSearchStr == ""))
	{
		alert ("אנא הכנס ערך לחיפוש");
		cleanInput();
		document.getElementById("freeSearch").focus();
	}
	else
	{
		xml = "<data>" +
				"<command>private.advfreeSearch</command>" +
				"<freeSearchVal>"+freeSearchStr+"</freeSearchVal>" +
			 "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterFreeSearch");
	}

}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	afterFreeSearch																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterFreeSearch (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var result = xmlRequest.getValue("result");
		var path = xmlRequest.getValue("path");
		document.getElementById("advSearch").innerHTML = result;
		document.getElementById("choosePath").innerHTML = path;
		isFreeSearch = true;
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	submitGameSaleForm																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function submitGameSaleForm()
{
	var city = document.getElementById("city").value;
	var price = document.getElementById("price").value;
	var partNumber = document.getElementById("partNumber").value;
	var mediaType = document.getElementById("mediaType").value;
	var flag;

	flag = getFlag("diskStatus");
	if (flag == false)
	{
		alert("יש לסמן את מצב הדיסק");
		return;
	}
	if (mediaType == "0")
	{
		alert("יש לבחור את סוג המדיה של המשחק");
		document.getElementById("price").focus();
		return;
	}
	if (partNumber == "0")
	{
		alert("יש לבחור את מספר החלקים שיש למשחק");
		document.getElementById("price").focus();
		return;
	}
	flag = getFlag("originalBox");
	if (flag == false)
	{
		alert("יש לסמן האם יש קופסה מקורית למשחק");
		return;
	}
	flag = getFlag("opBooklet");
	if (flag == false)
	{
		alert("יש לסמן האם קיימת חוברת הוראות למשחק");
		return;
	}
	if (city == "")
	{
		alert("יש להזין את שם העיר בא נמצא המשחק");
		document.getElementById("city").focus();
		return;
	}
	if (price == "")
	{
		alert("יש להזין את המחיר של המשחק");
		document.getElementById("price").focus();
		return;
	}

	if (isNumber("price"))
		document.getElementById("formGameSale").submit();

	
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	getFlag																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function getFlag(radioName)
{
	var radioField = document.getElementsByName(radioName);
	var flag = false;

	for (var i = 0; i < radioField.length && flag == false ; i++)
	{
		if (radioField[i].checked == true)
		{
			flag = true;
		}
	}
	return 	flag;
}
/* -----------------------------------------------------`-----------------------------------------------------------------------	*/
/* 	addCommunity																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function openCommunity (pageId)
{
	var formValidator = new Validator('addCommunity');
	formValidator.addValidation('addCommunitySubject', 'required', 'יש להזין את נושא');
	formValidator.addValidation('addCommunityContent', 'required', 'יש להזין תוכן');
	if (formValidator.validate ())
	{
		var subject = document.getElementById("addCommunitySubject").value;
		var content = document.getElementById("addCommunityContent").value;
		var forumId = document.getElementById("forumId").value;
		xml = "<data>" +
				"<command>private.openCommunity</command>" +
				"<pageId>"+pageId+"</pageId>" +
				"<content>"+content+"</content>" +
				"<subject>"+subject+"</subject>" +
				"<forumId>"+forumId+"</forumId>" +
			 "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "afterOpenCommunity");
	}
	

}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	afterOpenForum																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function afterOpenCommunity (i)
{
	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
	
	try
	{
		var success = xmlRequest.getValue("success");
		document.getElementById(popupOpenBorderId).style.display="none";
		document.getElementById(popupOpenFormId).style.display="none"; 
		openPopup('popupAfterSend','popupText',popupOpenHeight,popupOpenHeight1);
	}
	catch (e)
	{
		alert ("AJAX Error");
	}
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	clearCode																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function clearCode()
{
	var code = document.getElementById("code").value;
	if (code == "הכנס קוד")
		 document.getElementById("code").value = "";
}
/* ----------------------------------------------------------------------------------------------------------------------------	*/
/* 	switchMoreGames																							            		*/
/* ----------------------------------------------------------------------------------------------------------------------------	*/
function switchMoreGames()
{
	var div1 = document.getElementById("moreGames1");
	var div2 = document.getElementById("moreGames2");
	if (div1.style.display == 'none')
	{
			div2.style.display = 'none';
			div1.style.display = '';
	} else {
			div1.style.display = 'none';
			div2.style.display = '';
	}
}

function addLoadEvent(func)
{   
	var oldonload = window.onload;   
	if (typeof window.onload != 'function') {   
		window.onload = func;   
	} else {   
		window.onload = function() {   
			if (oldonload) {   
				oldonload();   
			}   
			func();   
		}   
	}   
} 
				

function changeEssayPageTabs (on, off)
{
	document.getElementById(off).style.display 		= "none";
	document.getElementById(on).style.display  		= "";

	document.getElementById(off+"Tab").className   	= "tab_bg";
	document.getElementById(on+"Tab").className    	= "selectedTab_bg";
}

