﻿// JScript File

function customWindowOpen(strUrl, strWindow, strParams, iWidth, iHeight)
{
	try
	{
		var iLeft, iTop;
		iLeft = (window.screen.width - iWidth) / 2;
		iTop = (window.screen.height - iHeight) / 2;
		strParams = strParams + ",width=" + iWidth.toString() + ",height=" + iHeight.toString() + ",left=" + iLeft.toString() + ",top=" + iTop.toString();
		window.open(strUrl, strWindow, strParams);
	}
	catch (e) 
	{ 
		
	} 
}

function createSearchEvent(e)
{
   
    // In Case Of Pressing Enter Perform Search		
    if(e.keyCode == 13)
    {	
        __doPostBack('_ctl0$HeaderUC1$ButtonSearch$LinkButton2','')
        return false;
    }		
}
function radFunction(exec)
{
   if(exec==true)
   {
      var oSpans = document.getElementsByTagName('span');
      for (i=0; i<oSpans.length; i++)
      {
        if ((oSpans[i].id.indexOf('phcText') > -1) &&
            (oSpans[i].id.indexOf('Editor') == -1) &&
                (oSpans[i].id.indexOf('Spell') == -1))
        {
            if(oSpans[i].innerHTML!='')
            {
                oSpans[i].style.display = '';
                }
        }
      }
    }
}
var oWindow;
function PrintContent(Direction,width,height,title,printArea,headerArea,titleArea)
{
   
    var headerObj=document.getElementById(headerArea);
    var titleObj=document.getElementById(titleArea);
   
    oWindow = window.open('',null,"height="+height+",width="+width+",status=yes,toolbar=no,menubar=no,location=no,top=100,left=300,scrollbars=yes");
    oWindow.document.open();
    oWindow.document.writeln('<html><head><link href="/Moia/Styles/main.css" type="text/css" rel="stylesheet" /></head><title>'+title);
    oWindow.document.writeln('</title><body onLoad="opener.OnLoadEvent()" dir='+Direction+'>');
    oWindow.document.writeln('<table>');
    oWindow.document.writeln(headerObj.innerHTML);
    oWindow.document.writeln('<br>');
   // oWindow.document.writeln(titleObj.innerHTML);
    
    //printArea.innerHTML=printArea.innerHTML.replace(buttonObj.innerHTML,'');
    oWindow.document.writeln(printArea.innerHTML);
    oWindow.document.writeln('</table>');
    oWindow.document.writeln("</body></html>");
    
   
   
    oWindow.document.close();
   
} 

//this function is written for Printing the Local Offices tables (OfficesMap) 
//It handles all the elemenets that could be handeled before the  objects are transfared to the "PrintContent" function due to IE and Firefox differences 
function OnLoadEvent(){
    var elements,elm,i;
    elements=oWindow.document.getElementsByName("Moia");
    for( i=0, elm; elm=elements.item(i++); )
    {
        elm.className='TableBorderForPrint';
    }
    
	elements = oWindow.document.getElementsByName('cornerTD');
		
    for( i=0, elm; elm=elements.item(i++); )
	{		
		elm.className='tdSide';		   
	}
    oWindow.document.getElementById("HomeIconTD").style.display='none';
    oWindow.print();
}

 
function OpenCalendarDiv(objTarget,e)
{
       var obj  =document.getElementById(objTarget);
       var IE = document.all?true:false;
       if(!IE)
        {//for firefox
            
            mouseX = e.pageX;
            mouseY = e.pageY;
          
        }
        else
        {
                    
            mouseX = e.clientX + document.body.scrollLeft;
            mouseY = e.clientY + document.body.scrollTop;
            
        } 
        
        mouseX = mouseX -310;
       var div=document.getElementById("popupFroCalendar");
       div.style.top=mouseY+"px";
       div.style.left=mouseX+"px";
       div.style.visibility="visible";

}
function openCalendar(objTarget,e)
{


       var IE = document.all?true:false;
       if(!IE)
        {//for firefox
            
            mouseX = e.pageX;
            mouseY = e.pageY;
          
        }
        else
        {
                    
            mouseX = e.clientX + document.body.scrollLeft;
            mouseY = e.clientY + document.body.scrollTop;
            
        }  
  
   
   
   
   
   
     var obj  =document.getElementById(objTarget);
     var date=obj.value;

   

	 var ret=window.showModalDialog("/Moia/Templates/Utils/Dialog.aspx?dialog=calendar&date=" + date ,"","dialogWidth:230px;dialogHeight:250px;scroll:no;status:yes;DialogTop:"+(mouseY+250)+"px;DialogLeft:"+(mouseX-250)+"px;"); 
	//var ret=window.showModalDialog("../Utils/Calendar.aspx?date=" + date ,"","dialogWidth:300px;dialogHeight:300px;scroll:no;status:yes;") 
	
	
	//user closed dialog without activation		
	if (ret==null )
		return;
		
  if(ret=="00/00/0000"	)
   ret="";

   obj.value=ret;
		
}        