﻿// Common JScript File

function doPostBackAsync( eventName, eventArgs ){
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if( !Array.contains( prm._asyncPostBackControlIDs, eventName) )
    {
       prm._asyncPostBackControlIDs.push(eventName);
    }

    if( !Array.contains( prm._asyncPostBackControlClientIDs, eventName) )
    {
       prm._asyncPostBackControlClientIDs.push(eventName);
    }
    __doPostBack( eventName, eventArgs );
}

function modalClicked(eventName, eventArgs){
    Sys.WebForms.PageRequestManager.getInstance()._doPostBack(eventName, eventArgs);
}

function showClock(location)
{
    /* showClock() function extracts the current time hours, minutes and seconds and then displays
     them in the div id location passed in from the BODY section */ 
    var clock=new Date();
    var hours=clock.getHours();
    var minutes=clock.getMinutes();
    var seconds=clock.getSeconds();
    var end = " AM";
    
    // for a nice disply we'll add a zero before the numbers between 0 and 9
    if(hours >12){
        hours -= 12;
        end = " PM";
        }
    if (hours<10){
        //hours="0" + hours;
    }
    if (minutes<10){
        minutes="0" + minutes;
    }
    if (seconds<10){
        seconds="0" + seconds;
    }
    
    document.getElementById(location).innerHTML=hours+":"+minutes+":"+seconds+end;
    t=setTimeout('showClock('+"'"+location+"'"+')',500);
        /* setTimeout() JavaScript method is used to call showClock() every 1000 milliseconds
         (that means exactly 1 second) */
}

function setCaretPosition(ctrl, pos){
    if(ctrl.setSelectionRange)
    {
        ctrl.focus();	
	    ctrl.setSelectionRange(pos,pos);
	}
	else if(ctrl.createTextRange)
	{	
        var range = ctrl.createTextRange();		
		range.collapse(true);		
		range.moveEnd('character', pos);
		range.moveStart('character', pos);	
		range.select();
	}
}


