var left800_0=622;
var left800_1=495;			
var left800_2=378;			
var left800_3=214;				
function openIt(x) {				
showBox = eval('document.all.box' + x);				
showBox.style.display= "";								
if (screen.width==800)					
{						
if (x==0)							
showBox.style.left=left800_0;						
if (x==1)							
showBox.style.left=left800_1;						
if (x==2)							
showBox.style.left=left800_2;							
if (x==3)							
showBox.style.left=left800_3;												
}			        				
var items = 4;				
for (i=0; i<items; i++) 				
{					
elOpen=eval('document.all.box' + i);					
if (i != x)					
{ 						
elOpen.style.display = "none";					
}				
}							
}

function ShowDiv1(obj,arrow,right,top,index)
  {
  if (obj==null)
	return
	
   obj.style.right = document.body.clientWidth - arrow.offsetLeft;
   obj.style.top =arrow.offsetTop + arrow.offsetHeight-top ;//- 2;
   obj.style.display='';
   if(obj.clientHeight<5)
	 {
	    obj.style.display='none';
	    return;
	   }
   
   if (right == 1)
    obj.style.right = parseInt(obj.style.right)- arrow.offsetWidth +10;//-10
   else
    obj.style.right = parseInt(obj.style.right) - obj.clientWidth;
    
  }

function HideDiv1(obj,index)    
  {
  if (obj==null)
	return
   obj.style.display='none'; 
   
  }
			
function closeIt() 			
{				
var items = 4;				
for (i=0; i<items; i++) 				
{					
var B=eval('document.all.box' + i);					
B.style.display = "none";
}
}

function ShowToolTip(ID)
{
			var ToolTip = document.getElementById("ToolTipDiv_" + ID);
            if (ToolTip.length)
                ToolTip = ToolTip[0];

			ToolTip.style.display = '';
			ToolTip.style.left = (document.body.parentElement.scrollLeft + window.event.x) - ToolTip.style.pixelWidth;  
			ToolTip.style.top = document.body.parentElement.scrollTop + window.event.y + 5;

}

function CloseToolTip(ID)
{
    var ToolTip = document.getElementById("ToolTipDiv_" + ID);
	if (ToolTip.length)
        ToolTip = ToolTip[0];
	ToolTip.style.display = 'none';
}

function OpenContent(ItemGuid)
		{
			var TR = eval("document.all.TR_" + ItemGuid);
			var TD = eval("document.all.TD_" + ItemGuid);
		//	var IMG = eval("document.all.IMG_" + ItemGuid);
			var LineColor
			var ImgAdd
			
										
			if(TR.style.display=='none')
			{
				TR.style.display = '';
				TD.style.color='#F9A829';
				
			}
			else
			{
				// צריך לסגור
				TR.style.display = 'none';
				TD.style.color='#2E4993';
				
			}
		}

function InitSelectedItems(my_tb){
if(my_tb==null || my_tb==undefined)
{
alert('InitSelectedItems-no textbox');
return;
}
	
			var array=window.dialogArguments
if(array==null || array==undefined || array=='')
return;


			var tb_obj=array[0]

			my_tb.value=tb_obj.value

			MarkItems(my_tb)
			//alert(my_tb.value)
			}
			

			
function MarkItems(my_tb){
if(my_tb==null)
{
alert('MarkItems-no textbox');
return;
}
	var my_keywords=my_tb.value	
				
	var arr = document.getElementsByTagName('INPUT');	//Get All Input In Form
		for(i=0;i<arr.length;i++)
		{
		var str = arr[i].type;		
		var str1 = str.indexOf("checkbox");	//If the Input Type is Radio Then
			if (str1 != -1)
			{						
				if (my_keywords.indexOf(";"+ arr[i].value +";")>=0)
				{
					arr[i].checked=true
				}					
			}
		}
	
}					
			
function SaveCheckedItems(my_tb){
	if(my_tb==null)
{
alert('SaveCheckedItems-no textbox');
return;
}			
	var keywords_str=";" //Important-Please Don't Touch!! 
	
	var arr = document.getElementsByTagName('INPUT');	//Get All Input In Form
		for(i=0;i<arr.length;i++)
		{
		var str = arr[i].type;		
		var str1 = str.indexOf("checkbox");	//If the Input Type is Radio Then
			if (str1 != -1)
			{						
				if (arr[i].checked==true)
				{
					keywords_str+= arr[i].value +";" //open tag
				}					
			}
		}
		my_tb.value=keywords_str

}	




function ReturnSelectedItems(my_tb){
try
{
SaveCheckedItems(my_tb);

var array=window.dialogArguments;

if(array[0] != null)
{
var tb_obj=array[0];
tb_obj.value=my_tb.value;
//alert(tb_obj.value);
parent.window.returnValue='OK';
}



parent.window.close();
}
catch(e)
{
alert('ReturnSelectedItems-error')
return ';';
}
}


function ShowFullList(PostGuid,is_filtered){

var path='/Religion/console/all_page.aspx';
//alert(path);
Redirect2Page('',path,'','current_posting=' + PostGuid,'type=card','filter='+is_filtered,'');

}

		


function OpenImg(guid){
window.open('/Religion/console/popup.aspx?guid='+guid,'Viewer','width=536,height=550,left=5,top=5');
}

function Redirect2Page(my_lang,post_url,title,parameter1,parameter2,parameter3,back_guid)
 {
		try
		{
            if (post_url==null || post_url == "")
				return;

            var title_param  = ""
            var guid_param  = ""
            var lang_param  = "" //---שפת המסמך שתישלח אל המסמך
            var parameter1_param  = ""
            var parameter2_param  = ""
	    var parameter3_param  = ""

            var back_param  = ""

            if  (title != "") 
            {
               title_param = "&title=" + escape(title)

                if (post_url.indexOf("?") < 0) 
                    title_param = title_param.replace("&", "?")
                
                post_url += title_param
           }

            //--next_guid או prev_guid כאן השוני
            /*if (new_guid != "")
            {
                guid_param = "&guid=" + new_guid

                if (post_url.indexOf("?") < 0) 
                    guid_param = guid_param.replace("&", "?")
                
                post_url += guid_param
            }*/

            //---כתובת העמוד אליו יש לחזור
            if (back_guid != "")
            {
                back_param = "&backguid=" + back_guid

                if (post_url.indexOf("?") < 0)
                    back_param = back_param.replace("&", "?")
                
                post_url += back_param
           }


            //---פרמטר נוסף שיתווסף אל העמוד
            if (parameter1 != "")
            {
                parameter1_param = "&" + parameter1

                if (post_url.indexOf("?") < 0)
                    parameter1_param = parameter1_param.replace("&", "?")
               
                post_url += parameter1_param
           }

            //---פרמטר נוסף שיתווסף אל העמוד
            if (parameter2 != "" )
            {
                parameter2_param = "&" + parameter2

                if (post_url.indexOf("?") < 0 )
                    parameter2_param = parameter2_param.replace("&", "?")
                
                post_url += parameter2_param
            }

//---פרמטר נוסף שיתווסף אל העמוד
            if (parameter3 != "" )
            {
                parameter3_param = "&" + parameter3

                if (post_url.indexOf("?") < 0 )
                    parameter3_param = parameter3_param.replace("&", "?")
                
                post_url += parameter3_param
            }
            //---השפה שתישלח אל העמוד
            if (my_lang != "") 
            {
                lang_param = "&lang=" + my_lang

                if (post_url.indexOf("?") < 0) 
                    lang_param = lang_param.replace("&", "?")
                
                post_url += lang_param
			}

            location.href=post_url;
         }  
        catch(e)
         {
			alert('Redirect2Page:Error!')
         }
   }





function OpenTypesInWindow(page_name,table,my_tb,my_lang,first_lbl,second_lbl,width,height){
if(my_tb==null)
		return;
		
		var array=new Array()
		array[0]=my_tb
		array[1]=first_lbl
		array[2]=second_lbl

	var path =page_name+'&lang='+my_lang  +'&table='+table
	var retVal=window.showModalDialog('/Religion/Dialog_Matefet.aspx?path='+ path,array,'dialogHeight:'+height+'px; dialogWidth:'+width+'px;  edge: Raised; center: yes; help: No; resizable: No; status: No;')
	
	/*if(retVal !=undefined)
	txt_obj.value=retVal*/	
	//alert(my_tb.value)
}



function MailingList(){
window.showModalDialog('/Raanana/Dialog_Matefet.aspx?path=console/mail_temporary.aspx','','dialogHeight: 570px; dialogWidth:570px;  edge: Raised; center: yes; help: No; resizable: No; status: No;');
}

function UKtoISO8601(St) //dd/mm/yyyy
 { return St.split('/').reverse().join('') }

  function UStoISO8601(St) //mm/dd/yyyy
 { return St.replace(/(\d+)\/(\d+)\/(\d+)/, '$3-$1-$2') }


function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function isHour(s) {
    if (!(/^\d{2,2}:\d{2,2}$/.test(s))) { return false; }
    var a = s.split(":");
    a[0] = Number(a[0]);
    a[1] = Number(a[1]);
    return a[0] >= 0 && a[0] <= 23 &&
        a[1] >= 0 && a[1] <= 59;
}

var dtCh= '/';
var minYear=1900;
var maxYear=2100;

function UKtoISO8601(St) //dd/mm/yyyy
	{ return St.split('/').reverse().join('') }

function UStoISO8601(St) //mm/dd/yyyy
	{ return St.replace(/(\d+)\/(\d+)\/(\d+)/, '$3-$1-$2') }

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++){
	var c = s.charAt(i);
	if (((c < '0') || (c > '9'))) return false;
	}
	return true;
}

function stripCharsInBag(s, bag){
	var i;
	var returnString = '';
	for (i = 0; i < s.length; i++){
	var c = s.charAt(i);
	if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year){
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
	this[i] = 31
	if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
	if (i==2) {this[i] = 29}
	}
	return this
}

function isDate(dtStr){
    if (dtStr=='')
    return true
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strDay=dtStr.substring(0,pos1)
    var strMonth=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=='0' && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=='0' && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
    if (strYr.charAt(0)=='0' && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1){
    alert('dd/mm/yyyy :התאריך צריך להיות בפורמט')
    return false
    }
    if (strMonth.length<1 || month<1 || month>12){
    alert('נא להקליד חודש חוקי')
    return false
    }
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
    alert('נא להקליד יום חוקי')
    return false
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
    alert('נא להקליד שנה חוקית בת 4 ספרות בין '+minYear+' ל- '+maxYear )
    return false
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
    alert('נא להקליד תאריך חוקי')
    return false
    }
    return true
    }

function IsNumeric(sText)
{
    var ValidChars = '0123456789';
    var IsNumber=true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++)
    {
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1)
    {
    IsNumber = false;
    }
    }
    return IsNumber;
}

function FormatYear(obj)
{
    var array=obj.value.split('/')
    if(array.length != 3)
    return false
    if( ! IsNumeric(array[0]) |  ! IsNumeric(array[1]) | ! IsNumeric(array[2]))
    return false
    var j,temp
    temp=''
    for (j = 0; j < 2; j++)
    {
    if (array[j].length ==1  )
    temp += '0'+ array[j] +'/'
    else if (array[j].length ==2  )
    temp += array[j] +'/'
    else
    return false
    }
    if (array[2].length == 2)
    temp += '20'+ array[j]
    else if (array[2].length ==4  )
    temp += array[j]
    else
    return false
    obj.value=temp
}

