
function check_heb(str) {
	var heb_exp = /[א-ת]/i;
	return heb_exp.test(str);
}

function change_dir() {
	var obj = window.event.srcElement;
		
	if (obj.isContentEditable) {
		if (check_heb(obj.value)) {
			obj.style.direction = "rtl";
		} else {
			obj.style.direction = "ltr";
		}
	}
}

function change_input_dir() {
	
	var i;

	for(i = 0; i < document.all.length; i++){
		if (document.all(i).tagName == "INPUT") {
		
			var obj = document.all(i);
		
			if (obj.isContentEditable) {
				if (check_heb(obj.value)) {
					obj.style.direction = "rtl";
				} else {
					obj.style.direction = "ltr";
				}
			
			}
		}
	}
}

function validate_input() {

	var v_exp = /['=]/i;
	var obj = window.event.srcElement;

		if ((obj.tagName == "INPUT") || (obj.tagName == "TEXTAREA")) {
			if (v_exp.test(obj.value)) {
				alert("התווים (') ו- (=) אינם חוקיים");
				obj.select();
			}
		}
		
}

function highlight_edit() {
	//var obj = window.event.srcElement;
	var obj = window.event ? window.event.srcElement : null;
     if (!obj) {
          return;
     }

	if ((obj.isContentEditable) || (obj.tagName == "SELECT")) {
		//obj.onfocus = function (){
			//obj.style.backgroundColor = "#f6f4ea"; 
			//};
			if (obj.onblur == null) {
				obj.onblur = validate_input;
			}
		
		//obj.attachEvent ('onblur', validate_input);

	}
}

function change_css(css){
	
	var obj;
	if ((window.event.srcElement.tagName == "TD") || (window.event.srcElement.tagName == "INPUT") || (window.event.srcElement.tagName == "SELECT")) {
		obj = window.event.srcElement;
	} else {
		//alert(window.event.srcElement.parentElement.tagName);
		obj = window.event.srcElement.parentElement;
	}
	obj.className = css;
}
			
function roll_off(css){
	var obj;
	if (window.event.srcElement.tagName == "TD") {
		obj = window.event.srcElement;
	} else {
		obj = window.event.srcElement.parentElement;
	}
	window.event.srcElement.className = css;
}

function go_to(url){
	document.location = url;
}

var hint_layer;
var iIntervalID;
var hint_msg;
var caller_obj;
var hint_x,hint_y;

function display_hint(msg){
	
	hint_msg = "<div align=right>" + msg + "</div>";
	hint_x = window.event.x + document.body.scrollLeft + 15;
	hint_y = window.event.y + document.body.scrollTop + 20;
	
	window.event.srcElement.onmousemove = span_move;
	
	if (hint_layer == null) {
		iIntervalID = window.setInterval("draw_span()",300);
	} else {
		if (hint_layer.style.visibility == "hidden") {
			iIntervalID = window.setInterval(function () {hint_layer.style.visibility = "visible";},300);
		}
	}
}

function draw_span(){
	
	if (hint_layer == null) {
		
		hint_layer = document.createElement("SPAN");
		hint_layer.innerHTML = hint_msg;
		hint_layer.style.position = "absolute";
		hint_layer.style.backgroundColor = "#F1EEE0"
		hint_layer.style.padding = 3;
		hint_layer.style.borderBottom = "2px solid #666666"
		hint_layer.style.borderTop = "1px solid #666666"
		hint_layer.style.borderRight = "2px solid #666666"
		hint_layer.style.borderLeft = "1px solid #666666"
		hint_layer.style.zIndex = 100;
		hint_layer.style.left = hint_x;
		hint_layer.style.top = hint_y;
		
		document.body.appendChild(hint_layer);

	}
	
}

function span_move(){
	if (hint_layer != null) {
		hint_layer.innerHTML = hint_msg;
		hint_layer.style.left = window.event.x + document.body.scrollLeft + 15;
		hint_layer.style.top = window.event.y + document.body.scrollTop + 20;
	}
}

function remove_hint(){

	window.clearInterval(iIntervalID);
	iIntervalID="";
	
	if (hint_layer != null) {
		hint_layer.style.visibility = "hidden";
	}

}

function open_popup(theURL,w,h,window_name) {
	features="product_browser.aspx','toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h;
	window.open(theURL,window_name,features);
}

