function openCondition(appDomain) {
	var conditionWin = window.open(appDomain+"/Conditions.asp", "Conditions", "left=10, top=10, width=600, height=500, scrollbars");
	conditionWin.focus();
}

function openConditionHaaretz(appDomain) {
	var conditionWin = window.open(appDomain+"/ConditionsHaaretz.asp", "Conditions", "left=10, top=10, width=600, height=500, scrollbars");
	conditionWin.focus();
}

function openConditionGlobes(appDomain) {
	var conditionWin = window.open(appDomain+"/ConditionsGlobes.asp", "Conditions", "left=10, top=10, width=600, height=500, scrollbars");
	conditionWin.focus();
}

function PatrentRelation() {

	this.parentCollection = new Array();
	this.length = 0;

	this.addParent = function(strKey) {
			this.parentCollection[strKey] = new Array();
			this.length++;
		}
		
	this.addChild = function(strKey, iValue) {
			if (this.parentCollection[strKey] == null)
				this.addParent(strKey);
			this.parentCollection[strKey].length++;
			this.parentCollection[strKey][this.parentCollection[strKey].length-1] = iValue;
		}

	this.getChildList = function(strKey) {
		if (this.parentCollection[strKey] != null)
			return this.parentCollection[strKey];
		else
			return new Array();
	}
}

function filterPorts(iCountryID, strControlID) {

	var objControl = document.all[strControlID].options;
	objControl.length = 0;
	if (iCountryID != 0) {
		var arrPorts = objPortsByCountries.getChildList(iCountryID.toString());
		if (arrPorts.length == 0 ) {
			var objOption = new Option();
			objOption.value = "-1";
			objOption.text = "No ports";
			objControl.length++;
			objControl[objControl.length-1] = objOption;
			var objOption = null;
		}
		else {
			for (i=0; i<arrPorts.length; i++) {
				var objOption = new Option();
				objOption.value = arrPorts[i];
				objOption.text = arrPortsList[arrPorts[i].toString()];
				objControl.length++;
				objControl[objControl.length-1] = objOption;
				var objOption = null;
			}
		}
	} 
	else {
		for (i in arrPortsList) {
			var objOption = new Option();
			objOption.value = i;
			objOption.text = arrPortsList[i];
			objControl.length++;
			objControl[objControl.length-1] = objOption;
			var objOption = null;
		}
	}
	document.all[strControlID+"Txt"].value = "";
}

function autoComlete(objInput, strControlID) {
	var objControl = document.all[strControlID].options;
	var strValue = objInput.value.toLowerCase();
	if (strValue == "") {
		objControl.selectedIndex = 0;
	}
	else {
		for (i=0; i<objControl.length; i++) {
			if (objControl.options[i].text.toLowerCase().indexOf(strValue) == 0) {
				objControl.selectedIndex = i;
				if (event.keyCode != 8) {
					objInput.value = objControl.options[i].text;
					var rNew = objInput.createTextRange();
					rNew.moveStart('character', strValue.length) ;
					rNew.select();
				}
				break;
			}
		}
	}
}

function showCalc(ID) {
	for (i=1; i<5; i++) {
		if (i == ID) {
			document.all["oCalc"+i].style.display = "block";
			document.all["oTab"+i].className = "wtext";
			document.all["oTab"+i].bgColor = "#0950A0";
			document.all["oSeperator"+i].bgColor = "#0950A0";
		}
		else {
			document.all["oCalc"+i].style.display = "none";
			document.all["oTab"+i].className = "tabOff";
			document.all["oTab"+i].bgColor = "#ffffff";
			document.all["oSeperator"+i].bgColor = "#FFFFFF";
		}
	}
}

function showSearch(ID) {
	if (ID == 1) {
		document.all["oSearchTab2"].className = "tabOff";
		document.all["oSearchSeperator2"].bgColor = "#FFFFFF";
		document.all["oSearchTab1"].className = "tabOn";
		document.all["oSearchSeperator1"].bgColor = "#EEF4FA";
		document.all["oSearch2"].style.display = "none";
		document.all["ctlWholeWord"].checked = false;
		document.all["ctlCatSearch"].style.display = "inline";
		document.forms.frmSearch.CategoryID.selectedIndex = 0;
		document.forms.frmSearch.SearchType.value = "";		
		document.all["ctlWholeWord"].checked = false;
	}
	else {
		document.all["oSearchTab1"].className = "tabOff";
		document.all["oSearchSeperator1"].bgColor = "#FFFFFF";
		document.all["oSearchTab2"].className = "tabOn";
		document.all["oSearchSeperator2"].bgColor = "#EEF4FA";
		document.all["oSearch2"].style.display = "block";
		document.all["ctlCatSearch"].style.display = "none";
		document.forms.frmSearch.SearchType.value = "1";		
	}
}

function isValidSearch(oForm) {
	if (oForm["SectionKey"].value == "-1") {
		alert("!בחר נושא")
		oForm["SectionKey"].focus();
		return false;
	}
	else {
		if (oForm["KeyWords"].value.length > 2)
			return true;
		else {
			alert("!מילת החיפוש צריכה להכיל לפחות 3 סימנים");
			oForm["KeyWords"].focus();
			return false;
		}
	}
}

function setData(oForm) {
	oForm.PortFromName.value = oForm.PortFrom[oForm.PortFrom.selectedIndex].text;
	oForm.PortToName.value = oForm.PortTo[oForm.PortTo.selectedIndex].text;
	oForm.AgentName.value = oForm.Agent[oForm.Agent.selectedIndex].text;
	return true;
}