function AddtoFavorites(){
window.external.AddFavorite("http://www.jobclick.co.il","JobClick")
}
var arrAreas = new Array(0,0,0,0,0,0,0);
var arrCategories = new Array(0,0,0,0);
var xDomAres = new ActiveXObject("Msxml2.DOMDocument");
xDomAres.async = false;
xDomAres.loadXML("<Areas/>");
var xDomCategories = new ActiveXObject("Msxml2.DOMDocument");
xDomCategories.async = false;
xDomCategories.loadXML("<Categories/>");

function fillHiddBox(ParentID,obj,val,IsIncludeInCounting){
	//alert(ParentID);
	//alert("tatarea - " + obj.name.indexOf("tatarea"));
	if(obj.name.indexOf("tatarea") == 0)
	{
		//alert("AreaCode - " + obj.name.substring(7,obj.name.length));
		//alert("Name - " + obj.name + " Value - " + val);
		//alert("Area - " + val.substring(1,2));
		var i = parseInt(val.substring(1,2)); 
		i--;
		//alert(i);
		if(obj.checked)
		{
			//alert("in ++");
			//alert("before - " + arrAreas[i]);
			arrAreas[i]++;
			var xNodeArea = xDomAres.createElement("Area");
			var attCode = xDomAres.createAttribute("Code");
			attCode.text = obj.name.substring(7,obj.name.length);
			xNodeArea.setAttributeNode(attCode);
			xDomAres.firstChild.appendChild(xNodeArea);
			//alert(xDomAres.xml);
			//xDomAres.appendChild 
			//xNodeArea = xDomAres.selectSingleNode("//Area [@Code='178']");
			//alert("178 - " + xNodeArea.xml);
			//xDomAres.attributes.
			//attCode
		}
		else
		{
			//alert("in --");
			arrAreas[i]--;
			var xNodeArea = xDomAres.selectSingleNode("//Area [@Code='" + obj.name.substring(7,obj.name.length) + "']");
			//alert("Node xml - " + xNodeArea.xml);
			xDomAres.firstChild.removeChild(xNodeArea);
			//alert(xDomAres.xml);
		}
		try
		{
			window.document.forms[0].txtAreaXML.value = xDomAres.xml;
			//Form1.txtAreaXML.value = xDomAres.xml;
			//alert(window.document.forms[0].txtAreaXML.value);
		}
		catch(exception){}
	}
	else
	{
		//alert("Name - " + obj.name + " Value - " + val);
		var i = parseInt(val.substring(1,2)); 
		i--;
		//alert(i);
		if(obj.checked)
		{
			arrCategories[i]++;
			var xNodeCat = xDomCategories.createElement("Category");
			var attParent = xDomCategories.createAttribute("Parent");
			if(IsIncludeInCounting==1)
			{
				attParent.text = ParentID;
			}
			else
			{
				attParent.text = -1;
			}
			xNodeCat.setAttributeNode(attParent);
			var attCode = xDomCategories.createAttribute("Code");
			attCode.text = obj.name.substring(11,obj.name.length);
			xNodeCat.setAttributeNode(attCode);
			var attExpID = xDomCategories.createAttribute("ExpID");
			attExpID.text = 1;
			xNodeCat.setAttributeNode(attExpID);			
			xDomCategories.firstChild.appendChild(xNodeCat);
		}
		else
		{
			arrCategories[i]--;
			var xNodeCat = xDomCategories.selectSingleNode("//Category [@Code='" + obj.name.substring(11,obj.name.length) + "']");
			//alert("Node xml - " + xNodeCat.xml);
			xDomCategories.firstChild.removeChild(xNodeCat);
			//alert(xDomCategories.xml);
		}
		try
		{
			//Form1.txtCategoriesXML.value = xDomCategories.xml;
			window.document.forms[0].txtCategoriesXML.value = xDomCategories.xml;
		}
		catch(exception){}
		//alert(Form1.txtCategoriesXML.value);
		//alert(xDomCategories.xml);
	}
	//alert("After - " + arrAreas[i]); 
	//alert(val.indexOf("7"));
	
	//alert(val);
}

function UpdateCategoryExperience(Object,ExpID)
{
	//alert("Name - " + Object.name + " Value - " + ExpID);
	//alert(xDomCategories.xml);
	var xNodeCat = xDomCategories.selectSingleNode("//Category [@Code='" + Object.name.substring(12,Object.name.length) + "']");
	var attExpID = xNodeCat.attributes.getNamedItem("ExpID");
	attExpID.text = ExpID;
	//alert(xDomCategories.xml);
	//Form1.txtCategoriesXML.value = xDomCategories.xml;
	window.document.forms[0].txtCategoriesXML.value = xDomCategories.xml;
	//alert(Form1.txtCategoriesXML.value);
}

function SetAreaCatDetails(obj,val)
{
	//alert("SetAreaCatDetails Name - " + obj.name + " Value - " + val);
	if(obj.name.indexOf("tatarea") == 0)
	{
			var xNodeArea = xDomAres.selectSingleNode("//Area [@Code='" + obj.name.substring(7,obj.name.length) + "']");
			if(xNodeArea != null)
			{
				xDomAres.firstChild.removeChild(xNodeArea);
			}
			else
			{
				xNodeArea = xDomAres.createElement("Area");
				var attCode = xDomAres.createAttribute("Code");
				attCode.text = obj.name.substring(7,obj.name.length);
				xNodeArea.setAttributeNode(attCode);
				var attActionID = xDomAres.createAttribute("ActionID");
				if(obj.checked)
					attActionID.text = 1;
				else
					attActionID.text = 2;
				xNodeArea.setAttributeNode(attActionID);
				xDomAres.firstChild.appendChild(xNodeArea);
			}
			//alert(xDomAres.xml);
			try
			{
				window.document.forms[0].txtAreaXML.value = xDomAres.xml;
			}
			catch(exception){}		
	}
	else
	{
		var xNodeCat = xDomCategories.selectSingleNode("//Category [@Code='" + obj.name.substring(12,(obj.name.length-1)) + "' && @ExpID='" + val + "']");
		if(xNodeCat != null)
		{
			xDomCategories.firstChild.removeChild(xNodeCat);
			var xNodeList = xDomCategories.selectNodes("//Category [@Code='" + obj.name.substring(12,(obj.name.length-1)) + "']");
			var ParentObject = document.getElementById("tatcategory" + obj.name.substring(12,(obj.name.length-1)));
			if(xNodeList.length==0 && ParentObject.checked)
			{
				xNodeCat = xDomCategories.createElement("Category");
				attCode = xDomCategories.createAttribute("Code");
				attCode.text = obj.name.substring(12,(obj.name.length-1));
				xNodeCat.setAttributeNode(attCode);
				attExpID = xDomCategories.createAttribute("ExpID");
				attExpID.text = "*";
				xNodeCat.setAttributeNode(attExpID);			
				xDomCategories.firstChild.appendChild(xNodeCat);
			}
		}
		else
		{
			var xNodeCat = xDomCategories.selectSingleNode("//Category [@Code='" + obj.name.substring(12,(obj.name.length-1)) + "' && @ExpID='*']");
			if(xNodeCat != null)
			{
				xDomCategories.firstChild.removeChild(xNodeCat);
			}
			var xNodeCat = xDomCategories.createElement("Category");
			var attCode = xDomCategories.createAttribute("Code");
			attCode.text = obj.name.substring(12,(obj.name.length-1));
			xNodeCat.setAttributeNode(attCode);
			var attExpID = xDomCategories.createAttribute("ExpID");
			attExpID.text = val;
			xNodeCat.setAttributeNode(attExpID);
			var attActionID = xDomCategories.createAttribute("ActionID");
			if(obj.checked)
				attActionID.text = 1;
			else
				attActionID.text = 2;
			xNodeCat.setAttributeNode(attActionID);
			xDomCategories.firstChild.appendChild(xNodeCat);
		}	
		//alert(xDomCategories.xml);
		try
		{
			window.document.forms[0].txtCategoriesXML.value = xDomCategories.xml;
		}
		catch(exception){}	
	}
}

function AddNew(txtObject,ID,SectionID)
{
	if(SectionID==1)
	{
		var xNodeArea = xDomAres.selectSingleNode("//NewArea [@Code='" + ID + "']");
		if(xNodeArea != null)
		{
			if(txtObject.value.length == 0)
			{
				xDomAres.firstChild.removeChild(xNodeArea);
			}
			else
			{
				xNodeArea.text = txtObject.value;
			}
		}
		else
		{
			xNodeArea = xDomAres.createElement("NewArea");
			var attCode = xDomAres.createAttribute("Code");
			attCode.text = ID;			
			xNodeArea.setAttributeNode(attCode);
			xNodeArea.text = txtObject.value;
			xDomAres.firstChild.appendChild(xNodeArea);
		}
		//alert(xDomAres.xml);
		try
		{
			window.document.forms[0].txtAreaXML.value = xDomAres.xml;
		}
		catch(exception){}
	}
	else
	{
		var xNodeCat = xDomCategories.selectSingleNode("//NewCategory [@Code='" + ID + "']");
		if(xNodeCat != null)
		{
			if(txtObject.value.length == 0)
			{
				xDomCategories.firstChild.removeChild(xNodeCat);
			}
			else
			{
				xNodeCat.text = txtObject.value;
			}
		}
		else
		{
			var xNodeCat = xDomCategories.createElement("NewCategory");
			var attCode = xDomCategories.createAttribute("Code");
			attCode.text = ID;
			xNodeCat.setAttributeNode(attCode);
			xNodeCat.text = txtObject.value;			
			xDomCategories.firstChild.appendChild(xNodeCat);
		}	
		//alert(xDomCategories.xml);
		try
		{
			window.document.forms[0].txtCategoriesXML.value = xDomCategories.xml;
		}
		catch(exception){}
	}
}

function fillHiddBoxForEmp(obj,val)
{
	//alert("fillHiddBoxForEmp Name - " + obj.name + " Value - " + val);
}

/*
function show(obj){
obj.style.visibility='visible';

}*/
function show(obj,obj2){

if(obj2.checked)
	obj.style.visibility='visible';
else
	obj.style.visibility='hidden';
}
function Hidd(obj){
obj.style.visibility='hidden';

}
function OpenCloseCat(obj,spObj){
var stat=obj.style.display;
var cls=spObj.className;
cls=(cls=="catClose")?"catOpen":"catClose";
stat=(stat=="none")?"":"none";
obj.style.display=stat;
spObj.className=cls;
//alert(tcat2.style.display)
}
function ShowDvPos(dvName){
	dvName.style.visibility='visible';
	dvName.style.display='';
}


//window.showModelessDialog("anaf.asp",window,"dialogHeight: 250px; dialogWidth: 350px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;");

function OpenModeWin(url,H,W){
window.showModelessDialog(url,window,"dialogHeight: " + H + "px; dialogWidth: " + W + "px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;")
}

var oPopup = window.createPopup();
function popUpMsg(theMsg,H,W){

    // The popup object exposes the document property and all of the document
    // properties.
    if (theMsg != ""){ 
    var oPopBody = oPopup.document.body;
    // Below the HTML that populates the popup is expressed as a string.
    oPopBody.innerHTML ="<div style='direction:rtl ;position:absolute ;background-color:#FFFFFF;border:solid 1px #000000;'>" + theMsg + "</div>";
    /*"  style='direction:rtl;position:absolute; top:0; left:0; " + 
    "width:240px; height:170px; padding:10px; color:white; font-family:tahoma; " +
     "font-size:13pt;filter:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#4CBFD2,endColorStr=#19387B)'> " +
     "על מנת לשלב תמונה לחץ על " + 
     "כפתור ה- Browse בתגובה תפתח לפניך ספריית התמונות שלי " + 
     "במחשב שלך לחץ פעמיים על תמונתך בסיומת jpg ולחץ הוסף.</div>"*/
    // This popup is displayed relative to the body of the document.
    //oPopup.show(200, 200, 240, 170, document.body);
    
	
    var XL=window.event.clientX;
    var YT=window.event.clientY;
    oPopup.show(XL,YT , W,H , document.body);
    }
}
//this function is for employer page for select all chkboxs
function selAll1(objName,stat,ParentID){
//alert(stat + "," + objName + "," + ParentID);
//var obj = new Object;
	var ParentObject = document.getElementById(ParentID);
	if(ParentObject != null)
	{
		ParentObject.checked=stat;
		for (i=1;i<7;i++){
			obj = document.getElementById(objName + i)
			//alert(obj.type)
			if( obj.checked != stat)
			{
				obj.checked=stat;//true
				SetAreaCatDetails(obj,obj.value);
			}
		}
	}
}

//this function is for employer page for select all chkboxs
function SetCheckBox(objName,stat){
//alert(stat)
//var obj = new Object;
	for (i=1;i<7;i++){
		obj = document.getElementById(objName + i)
		//alert(obj.type)	
		if( obj.checked != stat)
		{
			obj.checked=stat;//true
			SetAreaCatDetails(obj,obj.value);
		}
	}

}

function SelectAll(DataList, SectionName, Status)
{
	//alert("SelectAll - " + DataList);
	if(SectionName == "area")
	{
		var arrAreas = DataList.split(';');
		var obj;
		var i;
		//alert(arrAreas.length);
		for(i=0;i<arrAreas.length;i++)
		{
			obj = document.getElementById("tatarea" + parseInt(arrAreas[i]));
			//alert(obj);
			if(obj != null)
			{
				obj.checked = Status;
				//alert(obj.id);
				SetAreaCatDetails(obj,obj.value);
			}
		}
	}
	else
	{
		var arrCategories = DataList.split(';');
		var i;
		for(i=0;i<arrCategories.length;i++)
		{
			//alert("chbxcategory" + arrCategories[i] + "," + Status + ",tatcategory" + parseInt(arrCategories[i]));
			selAll1("chbxcategory" + arrCategories[i],Status,"tatcategory" + parseInt(arrCategories[i]));
		} 
	}
}
function selAll(e,LookUpName,stat)
{
	var elms=e.elements
	var vis;
	if (stat==true){
		vis='visible';
	}
	else{
		vis='hidden';
	}
	//alert(LookUpName)
	for(i=0;i<elms.length;i++){
	if ((elms[i].type=="checkbox") || (elms[i].type=="radio"))
		{
			if ((elms[i].value==LookUpName)||(elms[i].value2==LookUpName)){
				elms[i].checked=stat;
				//alert(elms[i].id);
				//selAll1(elms[i].id,stat)
				}
		}
	else if (elms[i].value3==LookUpName)
		{
		alert('here')
			elms[i].style.visibility=vis;
		}
	}
}

function allOff(stat,MainObjId){
	var obj = document.getElementById(MainObjId);
	if (stat==false){
		obj.checked=stat;
		var objName = document.getElementById("chbx" + MainObjId);
		//SetCheckBox(objName,stat);
		//alert("OK")
	} 
}	

function SetCheckBoxOffSubCategory(stat,MainObjId,objName,objAllName){
	var obj = document.getElementById(MainObjId);
	if (stat==false){
		obj.checked=stat;
		var objAll = document.getElementById(objAllName);
		objAll.checked=stat;
		SetCheckBox(objName,stat);
		//alert("OK")
	}
	else
	{
		var xNodeCat = xDomCategories.createElement("Category");
		var attCode = xDomCategories.createAttribute("Code");
		attCode.text = objAllName.substring(6,objAllName.length);
		xNodeCat.setAttributeNode(attCode);
		var attExpID = xDomCategories.createAttribute("ExpID");
		attExpID.text = "*";
		xNodeCat.setAttributeNode(attExpID);			
		xDomCategories.firstChild.appendChild(xNodeCat);
		//alert(xDomCategories.xml);
		try
		{
			window.document.forms[0].txtCategoriesXML.value = xDomCategories.xml;
		}
		catch(exception){}
	} 
}

function allOff2(stat,MainObjId,ParentObjId){
	var obj = document.getElementById(MainObjId);
	var objParent = document.getElementById(ParentObjId);
	if (stat==false){
		obj.checked=stat;
		objParent.checked=stat;
		//alert("OK")
	} 
}

function CatOn(objId){
	var obj = document.getElementById(objId);
		obj.checked=true;
}

function SetCatOn(objParentID,Object){
	//alert("SetCatOn");
	var obj = document.getElementById(objParentID);
	obj.checked=true;
	SetAreaCatDetails(Object,Object.value);	
}	
/*
function chkForCatSelect(e){
var elms=e.elements;
var name = new String;
var AreaFlag = false;
var CatFlag = false;
var msgText;// = "";

	for(i=0;i<elms.length;i++){
		if ((elms[i].type=="checkbox") || (elms[i].type=="radio"))
			{
				//alert("id is" + elms[i].id);
				//alert("value is:" + elms[i].checked);
				if ((elms[i].checked==true)){
					//elms[i].checked=stat;
					name = elms[i].id;
						if (name.indexOf("tatarea") > 0 ){
							AreaFlag=true;	
						}
						else if (name.indexOf("tatcategory") > 0 ){
							CatFlag=true;	
						}
					//alert("val is on=" + elms[i].id);
					//selAll1(elms[i].id,stat)
					}
			}
	}
	
if (AreaFlag ) {
	//alert("lalal")
	}
else{
	msgText = "jhjh"
	}
	
if (CatFlag ) {
	//alert("lalal")
	}
else{
	msgText += "iuiuiu"
	}
alert(msgText);	
/*	if (!(AreaFlag)){
		msgText = "לא נבחרו אזורים"
	}
	if (CatFlag){
		msgText += "לא נבחרו קטגוריות"
	}
	alert(msgText);
		
}*/
//************פונקציות לווידוי ספרות או אותיות *******************************
function heb(obj1,msg){
if (!chkHebFileds(obj1))
	{
	obj1.focus;
	obj1.select;
	obj1.value =cleanLastChar(obj1) ;
	alert(msg);
	//alert("שם משתמש וסיסמא  באותיות או מספרים בלבד")
	//alert(cleanLastChar(obj1))
	return false
	}
}

function chkHebFileds(obj){
var txt = new String;
var flag=true;
txt = obj.value;
//txt.charAt
for(i=0;i<txt.length;i++){
	if (((txt.charCodeAt(i) >= 65) && (txt.charCodeAt(i) <= 90)) || ((txt.charCodeAt(i) >= 97) && (txt.charCodeAt(i) <= 122))
	||((txt.charCodeAt(i) >= 48) && (txt.charCodeAt(i) <= 57)) || ((txt.charCodeAt(i) >= 1488) && (txt.charCodeAt(i) <= 1514)))
	{
	//flag = true;
	}
	else
	{
	//alert("false")
	
	flag = false;
	break;
	}
}
return flag
}

function cleanLastChar(obj){
var cr;
var obj1 = new String;
obj1 = obj.value;
//obj1.length
return obj1.slice(0,(obj1.length-1)) 

}
//*****************************************************************************