﻿// JScript File
function openLink(URI)
    {
        //win = window.open(URI,"secWin","width=600,height=600,left=100,scrollbars=yes,resiz able=yes,location=yes");
        win = window.open(URI,"secWin","scrollbars=yes,resiz able=yes,location=yes");
        win.focus;
    }	

function resizeFrameByName(obj) 
{
    var newHeight;
    var F = document.getElementById(obj);
    if(F.contentDocument) 
        {
 //              alert("in: 1" + "        " + newHeight);
 // newHeight = F.contentDocument.documentElement.scrollHeight+30; //FF 3.0.11, Opera 9.63, and Chrome
         newHeight = F.offsetHeight+30; //FF 3.0.11, Opera 9.63, and Chrome
       } 
    else 
        {
        newHeight = F.offsetHeight+30; //IE6, IE7 and Chrome
   //     alert("in: 1" + "        " + newHeight);
        }
        
    if (newHeight <= 1100)
        {   
            newHeight = 1100;
        }
    F.style.height = newHeight;
        
        return newHeight;
}

function openNewUrl(Pic)
    {
        window.open(Pic,'BigPic','directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,toolbar=no');
    }

//  function document.onreadystatechange()
//	{
//		 if (document.readyState == 'complete')
//	    { 
//	    parent.resizeFrame();
//		//alert("Completed ARTIC");
//		}
//}

    function querySt(ji)
    {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i=0;i<gy.length;i++) 
        {
            ft = gy[i].split("=");
            if (ft[0] == ji) 
            {
                return ft[1];
            }
         return "";
        }
    }
    function resizeFrame() 
    {
        newheight = resizeFrameByName("BodyFrame");
        document.getElementById("SideFrame").height = newheight+"px";
        document.getElementById("DataTable").style.height = newheight+"px";
        document.getElementById("MenuSide").style.height = newheight+"px";
        document.getElementById("Bottom").style.top = (newheight+190)+"px";
    }
    
    function getdays()
    {
        currentDate = new Date();
        DeathDate = new Date(1997,02,04);
        var days = Math.floor((((((currentDate-DeathDate)/1000)/60)/60)/24));
        document.getElementById("Days").innerHTML = "<center><b><font color='white'>"+ days +" ימים בלעדיך </font></b></center>";
    }
    
    function openMenu()
    {

        var parentMenu = querySt("parentMenu");
        if (parentMenu != "")
        {
            $(document.getElementById(parentMenu)).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
            $(document.getElementById(parentMenu)).siblings();
        }
     }
     
     function Nav(URI)
     {
     window.parent.BodyFrame.location.href = URI;
    // document.location.href = "http://asafdahan.com/AboutAsaf.aspx#";
     }

   function resizePic(obj)
    {
 /*       if (obj.width >  obj.height)
        {
            obj.width = 150;
            obj.height = 150*10/15;
        }
        else
        {
            obj.width = 150*10/15;
            obj.height = 150;
        }*/
    }
    
        function Showborder(obj)
    {
    //alert(obj.height);
     obj.style.backgroundColor = "#FFFFFF";
     obj.style.color ="#036a3b";
    /* obj.style.border="1";
    obj.style.borderColor ="#000000";
  
        obj.style.border-bottom black thin solid;";
        obj.style="border-left: black thin solid;";
        obj.style="border-top: black thin solid;";
        obj.style=" border-right: black thin solid;";
    */}

    function disBorder(obj)
    {
    obj.style.backgroundColor = "#036a3b";
     obj.style.color ="#FFFFFF";
   //alert(obj.height);
      /*  obj.style="border-bottom: black thin solid;";
        obj.style="border-left: black thin solid;";
        obj.style="border-top: black thin solid;";
        obj.style=" border-right: black thin solid;";*/
    }
    
    
      function CopyTextToUpdate(strID)
    {
       MsgControl1_NewsBody_rich.document.body.innerHTML = document.getElementById("RichText_"+strID).innerHTML; 
       document.getElementById("TextBox1").innerText = strID; 
       document.getElementById("btn_Upd").style.visibility ="visible"

    }    
    
    function onloadfunc()
    {
       document.getElementById("btn_Upd").style.visibility = "hidden"
    }
    
    function CopyRichInerText()
    {
        document.getElementById("TextBox3").innerText = MsgControl1_NewsBody_rich.document.body.innerHTML
    }
    
    function CopySongDataToUpdate(strID)
    {
       document.getElementById("Title").value = document.getElementById("Title_"+strID).innerText; 
       document.getElementById("WrittenBy").value =  document.getElementById("writtenBy_"+strID).innerText;
    }    
    
    function CopyMemorialDataToUpdate(strID)
    {
    
       if (document.getElementById("Type_"+strID).innerText == 2)
          {
          document.getElementById("TBoxType").value = 2;
          }
       else
          {
          document.getElementById("TBoxType").value = 1;
          }
       
       
       
       document.getElementById("TBoxTitle").value = document.getElementById("Title_"+strID).innerText; 
       document.getElementById("TBoxUN").value = document.getElementById("UploaderName_"+strID).innerText; 
       document.getElementById("TBoxUD").value = document.getElementById("UploadDate_"+strID).innerText; 

    }    
    
    function CopyRichInerTextMemorials()
    {
    //    document.getElementById("TextBox3").innerText = MsgControl1_NewsBody_rich.document.body.innerHTML;
        document.getElementById("HFhead").innerText = (MsgControl1_NewsBody_rich.document.body.innerText).substring(0, 250);
    }


 
var type; 
function OpenFormOnClickBtn(filenameStr,wi ,he )
{
window.open(filenameStr,'msgframe','top=50,left=250,width='+wi+',height='+he+',scrollbars=yes');
}
function button_over(eButton)
	{
		eButton.style.backgroundColor =	"LightSlateGray";
		eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
	}
function button_out(eButton)
	{
		eButton.style.backgroundColor =	"threedface";
		eButton.style.borderColor =	"threedface";
	}
function button_down(eButton)
	{
		eButton.style.backgroundColor =	"#8494B5";
		eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
	}
function button_up(eButton)
	{
		eButton.style.backgroundColor =	"#B5BDD6";
		eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
		eButton	= null;	
	}
var	isHTMLMode=false
function cmdExec(cmd,opt) 
	{
		if (isHTMLMode)
		{
			alert("Formatting happens only in Normal mode");
			return;
		}
		MsgControl1_NewsBody_rich.focus();
		MsgControl1_NewsBody_rich.document.execCommand(cmd,"",opt);
		MsgControl1_NewsBody_rich.focus();
	} // end cmdExec

function ChangeImage (ImageName,FileName) {
document[ImageName].src = FileName;
}

var intHCount = 0;
var intNCount = 0;

+
function setMode(Nbut, Hbut) 
	{
		var	sTmp;
		isHTMLMode = Hbut;
		isNormalMode = Nbut;

		if(Hbut == 1)
		{
			intHCount++;
			intNCount = 0;
		}

		if(Nbut == 1)
		{
			intNCount++;
			intHCount = 0;
		}	

		if (isHTMLMode && intHCount == 1)
		{
			sTmp=MsgControl1_NewsBody_rich.document.body.innerHTML;MsgControl1_NewsBody_rich.document.body.innerText=sTmp;
			ChangeImage ('HTMLbut','../pic/HTML_on.jpg');
			ChangeImage ('Normalbut','../pic/Normal_off.jpg'); return true;
		}
		if(isNormalMode && intNCount == 1)
		{
			sTmp=MsgControl1_NewsBody_rich.document.body.innerText;MsgControl1_NewsBody_rich.document.body.innerHTML=sTmp;
			ChangeImage ('HTMLbut','../pic/HTML_off.jpg');
			ChangeImage ('Normalbut','../pic/Normal_on.jpg'); return true;
		}
		MsgControl1_NewsBody_rich.focus();
	} // end setMode

//function openLink(URI)
//    {
//        //win = window.open(URI,"secWin","width=600,height=600,left=100,scrollbars=yes,resiz able=yes,location=yes");
//        url = "'" + URI + "'";
//        win = window.open(URI,'_top');
//        win.focus;
//    }	
    
//function doLink()
//    {
//        URI = document.getElementById("ServiceField").value;
//        if (URI == '')
//        {
//            alert("נא הכנס כתובת עמוד אינטרנט");
//        }
//        else
//        {
//         //   url = "javascript:openLink(" + URI + ")";
//            cmdExec("CreateLink",URI); 
//        }
//    }    


function createLink()
    {
        URI = document.getElementById("ServiceField").value;
         if(URI != null)
             {
             kk  =   MsgControl1_NewsBody_rich.document.selection.createRange();  
             tt  =   MsgControl1_NewsBody_rich.document.selection.createRange().text ;      
             url =  "<a href=' " +URI+ " ' target='_blank' >" +   tt + "</a>";
             kk.pasteHTML(url);
             }
        else{
            alert("נא הכנס כתובת עמוד אינטרנט");
              }
   }
   
       
//function add_url()
//	{
//	
//		if (isHTMLMode){alert("Please uncheck 'Edit	HTML'");return;}
//        URI = document.getElementById("ServiceField").value;
//        if (URI == '')
//        {
//            alert("נא הכנס כתובת עמוד אינטרנט");
//        }
//        else
//        {
//            var myname = "x"
//            url = "javascript:openLink("+URI+")"
//		    cmdExec("CreateLink",url);
//	    } 
//	} // end createLink

function OutlookAddr(t)
	{
	
	    var xLeft = 490;
	    var yTop =  document.getElementById(t.id).style.top;
	    
		var	arr	= showModalDialog("../../MessageCenter/General/OutlookAddr.aspx?AddrVal="+document.getElementById(t.id+"Txt").value ,"","font-family:Verdana;	font-size:12; dialogWidth:18;	dialogHeight:18 ; dialogLeft:"+xLeft+" ; dialogTop:"+yTop+"" );
		if (arr != null)
		{
		document.getElementById(t.id+"Txt").value =arr ; 
	}
		if (arr	!= null) {}	
	} 
function OnMessageTypeChange(theSelect)
{
   var theSelectValue = theSelect.options[theSelect.selectedIndex].value
   if (theSelectValue == "0")
   {
   Form1.MessageTypeImg.style.visibility = "Hidden";
   }
   else 
   {
       if (theSelectValue == "1")
       {
       Form1.MessageTypeImg.style.visibility =  "visible";
       Form1.MessageTypeImg.src = "../pic/Warning.jpg"; 
       }
       else
       {
           if (theSelectValue == "2")
            {
                Form1.MessageTypeImg.style.visibility =  "visible";
                Form1.MessageTypeImg.src = "../pic/Warning.jpg";
            }
       }
   }
}	
function foreColor()
	{
		var	arr	= showModalDialog("ColorPalette.htm","","font-family:Verdana;	font-size:12; dialogWidth:18;	dialogHeight:18" );
		if (arr	!= null) cmdExec("ForeColor",arr);	
	} // end foreColor

function setImage()	
{ 
	var	imgSrc = " ";
	var	flag = 0;	
	while(imgSrc ==	" ")
	{
	    //window.open('UploadPic.aspx')
		//imgSrc = prompt('Enter image location with image name ', ''); 
		imgSrc = document.getElementById("ServiceField").value; 
		imgPath = "http://asafdahan.com/new/UploadPics/";
	//	imgPath = "../UploadPics/";
		if (imgSrc == "	") alert("Please enter the required	URL");
		if(imgSrc != "")
		{
			cmdExec('insertimage', imgPath+imgSrc);	
		}
	} // end while
} // end setImage
function ShowCM(t,headerText)
	{
	MsgControl1_NewsBody_rich.document.designMode='On';
	if (divContent.style.display=="block")
		{
			divContent.style.display="none";
		}
	else
		{
			divContent.style.display="block";
		}
	type=t;
	spnHeader.innerText=headerText;
	if(document.getElementById(type).value != '')
		{
		MsgControl1_NewsBody_rich.document.body.innerHTML=document.getElementById(type).value;
		}
	}
function fillTxt()
		{
		var State = new Object()
		var aa;
		
    var tabscollect= MsgControl1_tbody_links.getElementsByTagName("tr"); 
		for (i=0;i<tabscollect.length;i++)
		{
	
		
         var td  =   tabscollect[i].getElementsByTagName("td"); 
         tabscollect[i].removeChild(td[1]);

           }
		document.getElementById("MsgControl1_hdnmsg").innerText=MsgControl1_NewsBody_rich.document.body.innerHTML +"<br>"+ MsgControl1_tdToSend.innerHTML; 
		//document.getElementById("MsgControl1_hdnmsg").innerText=MsgControl1_iframe_links.document.body.innerHTML; 
	
		
		//alert (document.getElementById("MsgControl1_hdnmsg").innerText);
		}
				
function ClearIFrame()
	{
	MsgControl1_NewsBody_rich.document.body.innerHTML ='';
	divContent.style.display="none";
	}
function DisableSave(bool)
	{
		document.Form1.btnSaveHead.style.display="none";
		if(bool=='show')
		{	
			if(document.Form1.btnSaveHead.style.display=="none")
			{
				document.Form1.btnSaveHead.style.display="block";
			}
			else
			{
				document.Form1.btnSaveHead.style.display="none";
			}
		}
	}


function InsertMsg()
{
 //alert(MsgControl1_NewsBody_rich.document.body.innerHTML);
 
  


       CreateXmlHttp();
     
       if(XmlHttp != null)
       {
          //alert("test");
               
                 
                 
                    var requestUrl = "Default_ajax.aspx?msg_txt="+MsgControl1_NewsBody_rich.document.body.innerHTML;
                      
                    XmlHttp.onreadystatechange = function ()
                    {
              alert(XmlHttp.responseText);
          
                        if(XmlHttp.readyState == 4 && XmlHttp.status == 200)
                        {  
                        
                         //  PopulateModel(XmlHttp.responseText, sub_c);
                            
                        }
                           
                    };
                   
                    XmlHttp.open("GET", requestUrl, true);	
     		        XmlHttp.send(null); 
     		     
          
       }
       
    }
 
   
    function CreateXmlHttp()
    {	
    try	
        {		
            XmlHttp = new ActiveXObject("Msxml2.XmlHttp");	
        }	
        catch(e)	
        {		
            try		
            {			
            XmlHttp = new ActiveXObject("Microsoft.XmlHttp");		
            } 		
            catch(oc)		
            {			
            XmlHttp = null;		
            }	
         }
         if(!XmlHttp && typeof XmlHttpRequest != "undefined") 	
         {		
         XmlHttp = new XmlHttpRequest();	
         }
         
    } 
function XXX()
{
    var tabscollect= MsgControl1_tbody_links.getElementsByTagName("tr");
		for (i=0;i<tabscollect.length;i++)
		{


         var td  =   tabscollect[i].getElementsByTagName("td");
         tabscollect[i].removeChild(td[1]);

           }
//		  document.getElementById("MsgControl_hdnmsg").innerText=MsgControl_NewsBody_rich.document.body.innerHTML +"<br>"+ MsgControl_tdToSend.innerHTML;
//		alert(NewsBody_rich.document.body.innerHTML);
//		document.getElementById("hdnmsg").innerText= NewsBody_rich.document.body.innerHTML +"<br>"+ tdToSend.innerHTML;

//document.getElementById("NewsBody_rich").document.designMode="On";
//document.getElementById("NewsBody_rich").document.body.innerHtml ='<P align=center>11332132131<STRONG><U><FONT color=#666699>נמהמנהמנה</FONT></U></STRONG>456465489794564</P>'
MsgControl1_NewsBody_rich.document.body.innerHTML =MsgControl1_NewsBody_rich.document.body.innerHTML + "<P align=center>11332132131<STRONG><U><FONT color=#666699>נמהמנהמנה</FONT></U></STRONG>456465489794564</P>";
//.document.body.innerHTML = MsgControl1_NewsBody_rich.document.body.innerHTML + "<P align=center>11332132131<STRONG><U><FONT color=#666699>נמהמנהמנה</FONT></U></STRONG>456465489794564</P>";
//alert(MsgControl1_NewsBody_rich.document.body.innerHTML);
//alert(document.getElementById("NewsBody_rich").document.body.innerHtml)
}

    
    function setCookie(c_name,value,expiredays)
        {
        var exdate=new Date();
        exdate.setDate(exdate.getDate()+expiredays);
        document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toUTCString());
        }
        
    function check_sel()
        {
	    password=document.selection.Password.value;
	   // ID_Ma=document.selection.ID_Ma.value;
	   // new_pass=document.selection.new_pass.value;
	   // verify=document.selection.verify.value;

	   
		 //   if (ID_Ma=="")
    	//	    {
        //	    		alert ("לא הוכנס שם משתמש");
        //		    	return false
        //		        }	
        //			else 
         if (password=="")
			    {
				alert ("לא הוכנסה סיסמא");
				return false
			    }	
			    else
			        {
			            //    setCookie('name',ID_Ma,1);
                            setCookie('pass',password,1);
			        }
        }		
