function SetSearchEngineTypes()
{

	//Conteiner for Types
	var divSearchEngineTypesConteiner;
	var checkbox;
	var Table;
	var TBody;
	var tr;
	var td;
	
	divSearchEngineTypesConteiner = document.createElement('div'); 
	divSearchEngineTypesConteiner.setAttribute('id','divSearchEngineTypesConteiner');
	Table = document.createElement('table');
	Table.setAttribute('id','tblSearchEngineTypes');
	Table.cellPadding = "0px";
	Table.cellSpacing = "0px";
	Table.setAttribute('width','100%');
	TBody = document.createElement('tbody'); 
	document.getElementById(TypeID).innerHTML = '';
	
	//Checkbox select all regions
	tr = document.createElement('tr');
	td = document.createElement('td');
	checkbox = document.createElement('input'); 
	checkbox.type = "checkbox";
	checkbox.setAttribute('id','chkJobTypes_-1'); 
	checkbox.onclick = function(){SetJobsTypeMarkedRow(this.id);};
	checkbox.setAttribute('value','-1');
	td.appendChild(checkbox);
	$(checkbox).attr('checked',true);
	tr.setAttribute("id","trJobTypes_-1");
	tr.onclick = function(){SetJobsTypeMarkedRow(this.id);};
	tr.appendChild(td);
	td = document.createElement('td'); 
	td.setAttribute("class","tdJobTypesName");
	td.appendChild(document.createTextNode('הכל'));
	$(tr).attr('class','RowTypesMarked')
	tr.appendChild(td);
	TBody.appendChild(tr);
	
	for(i=0;i<arrTypes.length;i+=2)
	{
		tr = document.createElement('tr'); 
		tr.setAttribute("id","trJobTypes_" + arrTypes[i]);
		tr.onclick = function(){SetJobsTypeMarkedRow(this.id);};
		//tr.setAttribute("class","dirRTLScroll");
		//Set checkbox
		td = document.createElement('td'); 
		td.setAttribute("id", "tdJobTypesChk_" + arrTypes[i]);
		checkbox = document.createElement('input'); 
		checkbox.type = "checkbox";
		checkbox.setAttribute('id','chkJobTypes_' + arrTypes[i]);
		checkbox.onclick = function(){SetJobsTypeMarkedRow(this.id);};
		checkbox.setAttribute('value',arrTypes[i]);
		td.appendChild(checkbox);
		tr.appendChild(td);
		
		//Set TypeName
		td = document.createElement('td'); 
		td.setAttribute("id", "tdJobTypesName_" + arrTypes[i]);
		td.setAttribute("class","tdJobTypesName");
		td.appendChild(document.createTextNode(arrTypes[i+1]));
		tr.appendChild(td);
		TBody.appendChild(tr);
	}
	Table.appendChild(TBody);
	divSearchEngineTypesConteiner.appendChild(Table);
	document.getElementById(TypeID).appendChild(divSearchEngineTypesConteiner);
	document.getElementById(TypeID).className = 'ComboViewTypes';
}

//Marked or Unmarked Row
function SetJobsTypeMarkedRow(CatID)
{
	CatID = CatID.split('_')[1];
									
	//Check if checkbox checked
	if($('#chkJobTypes_'+CatID).attr('checked'))
		$('#chkJobTypes_'+CatID).attr('checked',false);
	else
		$('#chkJobTypes_'+CatID).attr('checked',true);
	//Unchecked others checkboxs exept CatID == '-1'
	if(CatID == '-1' && $('#chkJobTypes_'+CatID).attr('checked'))
		$('#tblSearchEngineTypes tr input[@type="checkbox"][@checked]').each(
			function()
			{
				if(this.id.split('_')[1] != -1)
					$(this).attr('checked',false);
			}
		);
	//Uncheked checkbox with CatID == '-1'
	if(CatID != -1 && $('#chkJobTypes_'+CatID).attr('checked'))
		$('#chkJobTypes_-1').attr('checked',false);
		
	//Unmarked all rows	
	$('#tblSearchEngineTypes tr input[@type="checkbox"]').parent().parent().attr('class', 'RowTypesUnMarked');
	
	//Marked rows where checkbox is cheked
	$('#tblSearchEngineTypes tr input[@type="checkbox"][@checked]').parent().parent().attr('class', 'RowTypesMarked');
}

//Return values to Main JS file
function GetSearchResultsJobsType()
{
	var typeIDs = '';
	
	//JobsType
	$('#' + TypeID +' input[@type="checkbox"][@checked]').each(
			function()
			{
				//Create types string IDs
				if(this.value != '-1')
					typeIDs += this.value + ',';
			}
	);
	
	//Remove last ','
	if(typeIDs != '')
		typeIDs = typeIDs.substring(0, typeIDs.length - 1);

	return typeIDs;
}
//Get JobType Name
function GetSearchEngineJobTypeName()
{
	var typeNames = "";
	
	//JobsType
	$('#' + TypeID +' input[@type="checkbox"][@checked]').each(
			function()
			{
				//Create types string IDs
				if(this.value != '-1')
					typeNames += $('#tdJobTypesName_' + this.value).html() + '<br/>';
				
			}
	);
	
	
	if(typeNames == '')
		return 'הכל';
		
	return typeNames;	
}
//Set JobTypes values
function SetSearchEngineJobTypeValues(typeIDs)
{
	var i; 
	var arrTypeIDs = new Array();
		 	
	if(typeIDs != '')
	{	
		if(typeIDs.indexOf(',') == -1)
			arrTypeIDs[0] = typeIDs;
		else
			arrTypeIDs = typeIDs.split(',');
			
		for(i=0;i<arrTypeIDs.length;i++)
		{
			$('#' + TypeID +' input[@type="checkbox"]').each(
					function()
					{
						if(this.value == arrTypeIDs[i])
							$(this).attr('checked',true);
						
					}
			);
		}	
		$('#tblSearchEngineTypes tr input[@type="checkbox"][@checked]').parent().parent().attr('class', 'RowTypesMarked');
		$('#chkJobTypes_-1').parent().parent().attr('class', 'RowTypesUnMarked');
		$('#chkJobTypes_-1').attr('checked',false);
	}
	else
		SetSearchEngineTypes();
}