function openPage(pForm)
{
	document.getElementById(pForm).submit();	
}

function addElementToForm(pFormName, pName, pValue)
{
	var objText = document.createElement("input");
	objText.name = pName;
	objText.value = pValue;
	objText.type = "hidden";
	document.getElementById(pFormName).appendChild(objText);
}

function sendMsgTo(pId)
{
	addElementToForm("main_form", "to_id", pId);
	
	document.getElementById("main_form").action = "send_messages.php";
	document.getElementById("main_form").submit();
}

function checkAllCheckBoxes(pFormName, pName, pChecked)
{
	var checkBox = eval("document.getElementById(pFormName)." + pName);
	
	if (checkBox.length)
	{
		for (index = 0; index < checkBox.length; index++)
		{
			checkBox[index].checked = pChecked;
		}
	}
	else
	{
		checkBox.checked = pChecked;
	}
}

function checkAll()
{
	checkAllCheckBoxes('list_form', 'deletes_array', true);
}

function unCheckAll()
{
	checkAllCheckBoxes('list_form', 'deletes_array', false);
}

var msgToDelete = "";

function deleteSelected()
{
	if(confirm(msgToDelete))
	{
		openPage('list_form');
	}
}

function deletePic(pId, pName)
{
	var msg = "האם אתה בטוח שברצונך למחוק את התמונה: " + pName;
	if(confirm(msg))
	{
		addElementToForm('main_form', 'deletePicture', pId);
		openPage('main_form');
	}
}

ScrollSpeed = 100;
maxLength = 300;
var temp = "";
var space = "";

function PrintToSpan(str_name)
{
	document.getElementById("marquee1").innerHTML = str_name;
}

function ScrollMarquee()
{
	if (temp.length < msg.length && space.length == 0)
	{
		
		temp = msg.substring(0, temp.length + 1);
		//temp = msg.substring(msg.length - temp.length - 1);
	}
	else if (space.length + temp.length > maxLength)
	{
		temp = temp.substring(1);
		space +=  '&nbsp;&nbsp;';
		
		if(temp.length == 0)
		{
			space = "";
		}
	}
	else
	{
		space +=  '&nbsp;';
	}
	PrintToSpan(space + temp);
	window.setTimeout('ScrollMarquee()',ScrollSpeed);
}

function addToFavorite(pId)
{
	addElementToForm('main_form', 'add_to_favorite', pId);
	document.getElementById('main_form').action = 'my_favorites.php';
	openPage('main_form');
}

function removeFromFavorite(pId)
{
	addElementToForm('main_form', 'remove_from_favorite', pId);
	document.getElementById('main_form').action = 'my_favorites.php';
	openPage('main_form');
}

function addToBlocked(pId)
{
	addElementToForm('main_form', 'add_to_blocked', pId);
	document.getElementById('main_form').action = 'my_blocked.php';
	openPage('main_form');
}

function removeFromBlocked(pId)
{
	addElementToForm('main_form', 'remove_from_blocked', pId);
	document.getElementById('main_form').action = 'my_blocked.php';
	openPage('main_form');
}

function openConditionUse()
{
	myWindow = window.open("condition_use.php", "tinyWindow", 'toolbar=0,width=500,height=500');
	myWindow.document.close();
	
}

function closeConditionUse()
{
	myWindow.close();
	myWindow = null;
	
}

function openProfile(pId)
{
	myWindow = window.open("profile.php?talent=" + pId + "&newPage=true", "tinyWindow", 'toolbar=0,width=550,height=500');
	myWindow.document.close();
}