
/**
 * This method opens a new window of predefined size. This is being used by calander.jsp for date selection.
 *
 * @param theURL	URL to the resource to be loaded into the new window.
 * @param winName	Title for the pop-up window
 */
function MM_openBrWindow(theURL,winName)
{
  window.open(theURL,winName,'toolbar=yes,location=no,status=yes,scrollbars=yes,resizable=yes,width=472,height=420');

}

var doubleClickCounter = 0;

function checkMyDoubleClick()
{
    if (doubleClickCounter == 0)
    {
        doubleClickCounter++;

        return true;
    }

    return false;
}

function submitForm(formObj, p_dispatch, actionURL)
{
	if (checkMyDoubleClick()){
	  	formObj.action = actionURL ;
	  	formObj.submit();
	  	return true;
	}
	return false;
}

 /**
  * This method verifies the radio button, if the user has selected a choice or not.
  * If the user hasn't selected a choice, pop up a reminder window.
  *
  * @para radio is the html radio name
  */
 function CheckRadioByName(radio)
 {
     if(radio == undefined)
     {
         alert ("Please make a valid selection first.");
        return false;
     }

     var n = radio.length;

     if(n >= 2)
     {
        for(var i=0;i<n;i++)
        {

            if(radio[i].checked==true)
            {
                return true;
            }
        }
     }
     else
     {
        if(radio.checked==true)
        {
            return true;
        }

     }
     alert ("Please select an item from the list.");
    return false;
 }
 
 /**
  * The function is used print anything avaible between print ready tags.
  **/
 function printGraphs()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY>\n';
		
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
		var printWin = window.open("","printGraphs");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (true)
		{
			printWin.print();
			printWin.close("printGraphs");
		}
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}

/**
* This method verifies the radio button, if the user has selected a choice or not and also ask for confirmation.
* If the user hasn?t selected a choice, pop up a reminder window.
* Added new constraint to see whether there are any records existsing in the list.
*
* @para form     form is the html form name
*/
function CheckRadioButtonandConfirmation(radio)
{

    if (radio == undefined)
    {
        alert("Please make a valid selection first.");
        return false;
    }

    var n = radio.length;

    if (n >= 2)
    {
        for (var i = 0; i < n; i++)
        {

            if (radio[i].checked == true)
            {

                if (confirm('Are you sure you want to continue the selected item?'))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
    }
    else
    {
        if (radio.checked == true)
        {

            if (confirm('Are you sure you want to continue the selected item?'))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

    }
    alert("Please make a valid selection first.");
    return false;
}
 
 
function promptUserWithThisMessage (msg)
{
	if (msg.length > 0 )
		alert(unescape(msg));
}


