$(document).ready(function(){
	// init cellcom
	$("a[id^=showhide_menu_]").click(function(){
		$("div[id^=showhide_menu_][id!=" + this.id + "_div]").hide();
		$("#" + this.id + "_div").toggle($.hide, $.show);
		return false;
	});
	
	//first page only
	if ($('#number')[0]){
		var mynum_text = 'המספר שלי';
		$('#number').focus();
		
		// click
		$('#number').click(function(){
			if ($('#number').val() == mynum_text) {
				$('#number').val('');
			}
		});
		
		// blur
		$('#number').blur(function(){
			if ($('#number').val() == '') {
				$('#number').val(mynum_text);
			}
		});
		
		// keypress
		$('#number').keypress(function(e){
			if(e.which == 8 && $('#number').val() == mynum_text){ // if backspace and the text is המספר שלי
				$('#number').val('');
				return false
			}

			var key_pressed = String.fromCharCode(e.which);
			
			//allow chars a-z act
			if(/^[a-zA-Zא-ת0-9ا-ن]$/.test(key_pressed) && $(document.activeElement).attr('id') == 'number' && $('#number').val() == mynum_text){ // if chars a-z act AND focused on #number element AND the value is "my number" text
				$('#number').val(key_pressed);
				return false
			}
		});
	} 
});




function openCenteredWindow(url){
	var myWin;
    var width = 710;
    var height = 500;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ", height=" + height + ", left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top + "status=no, resizable=no, scrollbars=yes";
    myWin = window.open(url, "_blank", windowFeatures);
	myWin.focus();
}
