﻿// JScript File
function confirmDelete(){
    return confirm("? האם אתה בטוח");
}
function EnableControl(checkBoxId,controlId,useNextSibling)
{
    if(useNextSibling === undefined)
        useNextSibling = false;

    //get the checkbox by ID or by Object 
    if (typeof(checkBoxId)!='string'){ //got checkBox objex and not it's ID
        checkBoxId = checkBoxId.id;
    }
    checkBox= document.getElementById(checkBoxId);
    
    //get control to enable by ID or by HTML Structure(next sibling)
    if(useNextSibling == false)
    {	        
        var control=document.getElementById(controlId);
	}
	else
	{
	    //the control is in next next TD from Checkbox
	    var control= checkBox.parentNode.nextSibling.nextSibling.children[0]
	}
	//toggle enable\disable
	if (control!=null && checkBox!=null)
	{
        control.disabled=!checkBox.checked;
        if(!control.disabled)
            control.focus();
    }	  

}

function HideDateImg(chkObj,imgItem,txtItem)
	{	
	//debugger
		if (chkObj)
		{
			if (chkObj.checked) 
			{
			    document.getElementById(imgItem).style.visibility="visible";
				document.getElementById(txtItem).disabled = false;	
				document.getElementById(txtItem).focus();		
				}
			else
			{
				document.getElementById(imgItem).style.visibility="hidden";
				var changer = document.getElementById(txtItem);
				changer.value = "";
				document.getElementById(txtItem).disabled = true;
			}
		}
	}
function EnableTxt(chkObj,txtItem){
				if (chkObj)
				{
					if (chkObj.checked) 
					{
						document.getElementById(txtItem).disabled=false;
						document.getElementById(txtItem).focus();
					}	
					else
					{
					    var changer = document.getElementById(txtItem);
					    changer.value = "";
						document.getElementById(txtItem).disabled = true;
					}
				}	
		}	
function hideButton(btn)
			{
				if (document.getElementById(btn))
				 document.getElementById(btn).style.visibility="hidden";
			}	
			
/*-------- Javascript for MasterPage Show/Hide more menues --------*/			
   
function fitMenus()
{	
	var divs = menu.getElementsByTagName("div");
	var maxMenuHeight=Math.max(content.scrollHeight,(screen.availHeight-170-180));

	for ( i=divs.length -1;i>0 && menu.offsetHeight>maxMenuHeight ;i--){
        hideDiv(divs[i]);
    }

	if(i < divs.length -1){
	    showMenuButtons(menu);
	    i++;
	}
}

function showMenuButtons(obj)
{
	var buttons = "";
	buttons = '<div class="nav" id="morelink"><a href="javascript:toggleMenus();" class="more" id="toggleMenusLink">'+more+'</a></div>';			
	obj.innerHTML += buttons;
}
function hideDiv(div)
{
    div.style.display = 'none';
}
function showDiv(div)
{
    div.style.display = 'Block';
}

function toggleMenus()
{		
	var divs = menu.getElementsByTagName("div");
	var cntHeight = content.scrollHeight;
    var maxMenuHeight=Math.max(content.scrollHeight,(screen.availHeight-170-180));
							
	if(document.getElementById("toggleMenusLink").innerHTML == more)
	{
	   
		while(i < divs.length -1 )
		{
		    showDiv(divs[i]);
		    i++;
		}
		document.getElementById("toggleMenusLink").innerHTML = less;
	}
	else
	{
		while (menu.offsetHeight > maxMenuHeight && i > 0)
	    {
        
            hideDiv(divs[i]);		    	
	    	i--;
	    }
		document.getElementById("toggleMenusLink").innerHTML = more;
		document.getElementById("morelink").style.display='block';
	}
}			


function go2next(myCell, serial, req) {				
	if ( event.keyCode == 0 || event.keyCode == 9 || event.keyCode == 13 ) return true;
	if ( ( event.keyCode > 0 && event.keyCode < 9 ) || event.keyCode == 12 || ( event.keyCode > 15 && event.keyCode < 21 ) || ( event.keyCode > 32 && event.keyCode < 48 ) || ( event.keyCode > 105 && event.keyCode < 128 )) return false;
	if ( event.keyCode < 48 || (event.keyCode > 57 && event.keyCode < 96 ) || event.keyCode > 105 ) 
		{
			window.alert( "התו שהוקלד אינו חוקי" );
			return false;
		}
	var inpColl = myCell.all.tags("INPUT");
	if ( inpColl(serial).value.length == 1 && inpColl(serial).value > 0) return true;
	if (( serial == 0 && inpColl(serial).value > 31 ) || ( serial == 1 && inpColl(serial).value > 12 ) || (inpColl(serial).value == "00"))
		{
			alert("תאריך לא חוקי");
			return false;
		}
	if ( serial == 2 && inpColl(serial).value.length == 4 && ( inpColl(serial).value > 2050 || inpColl(serial).value < 1950 ))
		{
			alert("שנה לא חוקית");
			return false;
		}
	if ( serial < 2 && inpColl(serial).value.length == 2 && inpColl(serial).value > 0 ) inpColl(serial+1).focus();
}

function dontGo(myTCell,serial,must) {
	var inpColl = myTCell.all.tags("INPUT");
	if (( serial == 0 && inpColl(serial).value.length==0 && must==1) || (serial > 0 && inpColl(serial).value.length==0 && inpColl(serial-1).value.length>0 && inpColl(serial-1).value > 0)) 
		{
		window.alert(" שדה זה חובה ");
		inpColl(serial).focus()
		return false;
	}
	if ( serial == 2 && ( inpColl(serial).value.length == 1 || inpColl(serial).value.length == 3 ))
		{
			alert("שנה לא חוקית");
			inpColl(serial).focus()
			return false;
		}
	if ( inpColl(serial).value == "0" || inpColl(serial).value == "00" )
		{
			alert("תאריך לא חוקי");
			inpColl(serial).focus()
			return false;
		}
}
function FlashLinksScript(controlClientID)
{
    		/*
		Flashing Link Script-© Dynamic Drive (www.dynamicdrive.com)
		For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use, 
		Visit http://dynamicdrive.com
		*/
		var flashlinks = document.getElementById(controlClientID);
		
		if (document.all && flashlinks){
			
			if (flashlinks.length==null)
				flashlinks[0]=flashlinks

			
			if (flashlinks.length==null){
				var flashengine='setInterval("changecolor(0,'+flashlinks[0].flashtype+',\''+flashlinks[0].flashcolor+'\')",'+'1000)';
					eval(flashengine);
				}
			else
				for (i=0;i<flashlinks.length;i++){
					var flashengine='setInterval("changecolor('+i+','+flashlinks[i].flashtype+',\''+flashlinks[i].flashcolor+'\')",'+'1000)';
					eval(flashengine);
			}	
		}
}
function changecolor(which,type,color){
				if (type==0){
					if (flashlinks[which].style.color!=color)
						flashlinks[which].style.color=color;
					else
						flashlinks[which].style.color='#4275be';
					}
				else if (type==1){
					if (flashlinks[which].style.backgroundColor!=color)
						flashlinks[which].style.backgroundColor=color;
					else
						flashlinks[which].style.backgroundColor='';
				}
			}
