﻿//	written	by Srikant Sharma on 09 June 2008
    var xmlHttp;
	var status=true;
	var cname;
	var idcomp;
	var idrow;
	_dom = 0;
	var	fixedX = -1 // x position (-1 if to appear below control)
	var	fixedY = -1 // y position (-1 if to appear below control)
	var startAt = 0 // 0 - sunday ; 1 - monday
	var showWeekNumber = 1	// 0 - don't show; 1 - show
	var showToday = 1		// 0 - don't show; 1 - show
	var imgDir = "js/"	// directory for images ... e.g. var imgDir="/img/"

	var gotoString = "Go To Current Month"
	var todayString = "Today is"
	var weekString = "Wk"
	var crossobj_new,crossMonthObj_new,crossYearObj_new
	var	monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear
    
	var	bPageLoaded=false
	var	ie=document.all
	var	dom1=document.getElementById

	var	ns4=document.layers
	var	today =	new	Date()
	var	dateNow	 = today.getDate()
	var	monthNow = today.getMonth()
	var	yearNow	 = today.getYear()
	var	imgsrc = new Array("drop1.gif","drop2.gif","left1.gif","left2.gif","right1.gif","right2.gif")
	var	img	= new Array()
	var next_prev=0
	var oFunctions = ""

	var bShow = false;

    /* hides <select> and <applet> objects (for IE only) */
    function hideElement2( elmID, overDiv )
    {
      if( ie )
      {
        for( i = 0; i < document.all.tags( elmID ).length; i++ )
        {
          obj = document.all.tags( elmID )[i];
          if( !obj || !obj.offsetParent )
          {
            continue;
          }
      
          // Find the element's offsetTop and offsetLeft relative to the BODY tag.
          objLeft   = obj.offsetLeft;
          objTop    = obj.offsetTop;
          objParent = obj.offsetParent;
          
          while( objParent.tagName.toUpperCase() != "BODY" )
          {
            objLeft  += objParent.offsetLeft;
            objTop   += objParent.offsetTop;
            objParent = objParent.offsetParent;
          }
      
          objHeight = obj.offsetHeight;
          objWidth = obj.offsetWidth;

          if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
          else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
          else if( overDiv.offsetTop >= ( objTop + objHeight ));
          else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
          else
          {
            obj.style.visibility = "hidden";
          }
        }
      }
    }
     
    /*
    * unhides <select> and <applet> objects (for IE only)
    */
    function showElement2( elmID )
    {
      if( ie )
      {
        for( i = 0; i < document.all.tags( elmID ).length; i++ )
        {
          obj = document.all.tags( elmID )[i];
          
          if( !obj || !obj.offsetParent )
          {
            continue;
          }
        
          obj.style.visibility = "";
        }
      }
    }

	function HolidayRec (d, m, y, desc)
	{
		this.d = d
		this.m = m
		this.y = y
		this.desc = desc
	}

	var HolidaysCounter = 0
	var Holidays = new Array()
	if (dom1)
	{
		for	(i=0;i<imgsrc.length;i++)
		{
			img[i] = new Image
			img[i].src= img + imgsrc[i]  
		}
		//document.write ("<div onclick='bShow=true' id='message' class='div-style'><table width="+((showWeekNumber==1)?450:80)+" class='table-style'><tr class='title-background-style' ><td><table width='"+((showWeekNumber==1)?450:80)+"'><tr><td class='title-style'><B><span id='caption'></span></B></td><td align=right><a href='javascript:hideGraph_new()'><IMG SRC='App_Themes/images/close.gif' WIDTH='15' HEIGHT='15' BORDER='0' ALT='Close'></a></td></tr></table></td></tr><tr><td class='body-style'><span id='content_new'></span></td></tr>")
			
		//document.write ("<div onclick='bShow=true' id='message' class='div-style'><table width="+((showWeekNumber==1)?450:80)+" class='table-style'><tr class='title-background-style' ><td align=right><a href='javascript:hideGraph_new()'> <span> Close </span> </a></td></tr><tr><td class='body-style'><span id='content_new'></span></td></tr>")
		
			
        //document.write ("</table></div><div id='selectMonth' class='div-style'></div><div id='selectYear' class='div-style'></div>");
	}

	function init2()	{
        document.getElementById("content_new").innerHTML="";
		if (!ns4)
		{
			if (!ie) { yearNow += 1900	}
			crossobj_new=(dom1)?document.getElementById("message").style : ie? document.all.message : document.message
			hideGraph_new()
            sHTML1=""
			//sHTML1= "<span id='spanLeft'  class='title-control-normal-style' onmouseover='swapImage(\"changeLeft\",\"left2.gif\");this.className=\"title-control-select-style\";window.status=\""+scrollLeftMessage+"\"' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);swapImage(\"changeLeft\",\"left1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartDecMonth()\",500)'	onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'>&nbsp<IMG id='changeLeft' SRC='"+imgDir+"left1.gif' width=10 height=11 BORDER=0>&nbsp</span>&nbsp;"
			//sHTML1+="<span id='spanRight' class='title-control-normal-style' onmouseover='swapImage(\"changeRight\",\"right2.gif\");this.className=\"title-control-select-style\";window.status=\""+scrollRightMessage+"\"' onmouseout='clearInterval(intervalID1);swapImage(\"changeRight\",\"right1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartIncMonth()\",500)'	onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'>&nbsp<IMG id='changeRight' SRC='"+imgDir+"right1.gif'	width=10 height=11 BORDER=0>&nbsp</span>&nbsp"
		    //sHTML1+="<span id='spanMonth' class='title-control-normal-style' onmouseover='swapImage(\"changeMonth\",\"drop2.gif\");this.className=\"title-control-select-style\";window.status=\""+selectMonthMessage+"\"' onmouseout='swapImage(\"changeMonth\",\"drop1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onclick='popUpMonth()'></span>&nbsp;"
			//sHTML1+="<span id='spanYear'  class='title-control-normal-style' onmouseover='swapImage(\"changeYear\",\"drop2.gif\");this.className=\"title-control-select-style\";window.status=\""+selectYearMessage+"\"'	onmouseout='swapImage(\"changeYear\",\"drop1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"'	onclick='popUpYear()'></span>&nbsp;"
			
			document.getElementById("caption").innerHTML  =	""
		    bPageLoaded=true
		}
		document.getElementById("caption").innerHTML  =	""
		    bPageLoaded=true
	}

	function hideGraph_new()	{
		if(crossobj_new){
		    bPageLoaded=false
			crossobj_new.visibility="hidden"
			if (crossMonthObj_new != null){crossMonthObj_new.visibility="hidden"}
			if (crossYearObj_new !=	null){crossYearObj_new.visibility="hidden"}

			showElement2( 'SELECT' );
			showElement2( 'APPLET' );
		}
	}
	
	function closeCalendar_new() {
		var	sTmp
            
		hideGraph_new();
		//ctlToPlaceValue.value =	constructDate(dateSelected,monthSelected,yearSelected)
	}
	/*** message ***/
	function constructGraph1(str) {
	
		//onLoad(row,idcomp,n_p);
		document.getElementById("content_new").innerHTML   = str
		}
   
function popCalculation(ctl,val) {
		var	leftpos=0
		var	toppos=0
	
		if (val=="-" || val=="")
		   return; 
		//oFunctions = OtherFunctions
		
		if (bPageLoaded)
		{
			if ( crossobj_new.visibility ==	"hidden" ) {
				//ctlToPlaceValue	= ctl2
				//dateFormat=format;

				//formatChar = " "
				//aFormat	= dateFormat.split(formatChar)
				//if (aFormat.length<3)
				tokensChanged =	0
				aTag = ctl
				do {
					aTag = aTag.offsetParent;
					leftpos	+= aTag.offsetLeft;
					toppos += aTag.offsetTop - aTag.scrollTop;;
				} while(aTag.tagName!="BODY");

				crossobj_new.left =	fixedX==-1 ? ctl.offsetLeft	+ leftpos - 430 :	fixedX
				crossobj_new.top = fixedY==-1 ?	ctl.offsetTop +	toppos + ctl.offsetHeight +	2 :	fixedY
				constructGraph1(val);
				crossobj_new.visibility=(dom1||ie)? "visible" : "show"
				
				hideElement2( 'SELECT', document.getElementById("message") );
				hideElement2( 'APPLET', document.getElementById("message") );			

				bShow = true;
				
			}
		}
		else
		{
			init2()
			popCalculation(ctl,val)
		
		}
	}
	document.onkeypress = function hidecal1 () { 
		if (event.keyCode==27) 
		{
			hideGraph_new()
		}
	}
	document.onclick = function hidecal2 () { 		
		if (!bShow)
		{
			hideGraph_new()
		}
		bShow = false
	}

	//window.onload=init()