// Common JavaScript functions

//----------------------------------------------------------------------------------------------------
//-- newWindowPopup opens a new popup window
//-- The URL of the window is passed as well as its width and height
//----------------------------------------------------------------------------------------------------
function eduPopup(URL,w,h) {

	if(w=="")
		w = 425;
	if(h=="")
		h=500;
			
	var newWin = window.open(URL,"NEW_WINDOW_POPUP",'width=' + w + ', height=' + h + ',resizable,menubar=0,status,toolbar,scrollbars');	
	newWin.focus();
}

function eduPopup2(URL,w,h,name)
{	
	if(w=="")
		w = 425;
	if(h=="")
		h=500;
			
	var newWin = window.open(URL,name,'width=' + w + ', height=' + h + ',resizable,menubar=0,status,toolbar,scrollbars');	
	newWin.focus();
}

var browser;
var calendarWinName = "";
function calWindow(passCName,calName,imgName,extraURLFilters) {

    if(calendarWinName != "")
    {
        document.getElementById(calendarWinName).style.display='none';        
    }
    if(calendarWinName != calName)
    {
        calendarWinName = calName;
    
        if('undefined' == typeof extraURLFilters)
        {
            extraURLFilters = "";
        }
        
        showiframe(passCName,calName,imgName,extraURLFilters);
    }    
    else
    {
        calendarWinName = "";
    }
}

function showiframe(passCName,calName,imgName,extraURLFilters)
{   		
    var objImg = document.getElementById(imgName);
    var imgTop = objImg.style.top;
    var imgLeft = objImg.style.left;    
    
    if(imgTop == "")
        imgTop = 0;
    if(imgLeft == "")
        imgLeft = 15;    
    document.getElementById(calName).src = '../../resources/calendarIE.aspx?frameName=' + calName + '&controlName='  + passCName + '&PassDate=' + document.getElementById(passCName).value + extraURLFilters;    
    document.getElementById(calName).style.top= imgTop+'px';
    document.getElementById(calName).style.left= imgLeft+'px';
    document.getElementById(calName).style.display='';    
    document.getElementById(calName).focus();
}

function cvcPopUp(URL, w, h)
{	        
    if(w=="")
        w = 425;
    if(h=="")
        h=500;
			
    var newWin = window.open(URL,"CVCPopUp",'width=' + w + ', height=' + h + ',resizable,menubar=0,status,toolbar,scrollbars');	
    newWin.focus();
}

function closeCalendar(calName)
{
    document.getElementById(calName).style.display ='none';
    calendarWinName = "";
}

function setCurrentTimeToField(currObj)
{
    var currentTime = new Date();
    document.getElementById(currObj).value = padString(currentTime.getHours().toString(),"0",2) + ":" + padString(currentTime.getMinutes().toString(), "0",2);
}

function padString(currVal, padChar, requiredLength)
{
    var paddedString = currVal;    
    if(currVal.length < requiredLength)
    {    
        for(i=currVal.length; i<requiredLength;i++)
        {     
            paddedString = "0" + paddedString;
        }
    }
    return paddedString;
}



