

//function reportView(id)
//{
//	window.open("../analysis/report.asp?id="+id,"RADAR :: Analysis","fullscreen,scrollbars")
//}


function getHeight()
	{
		var height = window.innerHeight;
		return height;
	}

function getWidth()
	{
		var width = window.innerWidth;
		return width;
	}


function getBrowserName()
{


	var nVer = navigator.appVersion;
	var nAgt = navigator.userAgent;
	var browserName  = navigator.appName;
	var fullVersion  = ''+parseFloat(navigator.appVersion); 
	var majorVersion = parseInt(navigator.appVersion,10);
	var nameOffset,verOffset,ix;

	// In MSIE, the true version is after "MSIE" in userAgent
	if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
	 browserName = "Microsoft Internet Explorer";
	 fullVersion = nAgt.substring(verOffset+5);
	}
	// In Opera, the true version is after "Opera" 
	else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
	 browserName = "Opera";
	 fullVersion = nAgt.substring(verOffset+6);
	}
	// In Chrome, the true version is after "Chrome" 
	else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
	 browserName = "Chrome";
	 fullVersion = nAgt.substring(verOffset+7);
	}
	// In Safari, the true version is after "Safari" 
	else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
	 browserName = "Safari";
	 fullVersion = nAgt.substring(verOffset+7);
	}
	// In Firefox, the true version is after "Firefox" 
	else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
	 browserName = "Firefox";
	 fullVersion = nAgt.substring(verOffset+8);
	}
	// In most other browsers, "name/version" is at the end of userAgent 
	else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) 
	{
	 browserName = nAgt.substring(nameOffset,verOffset);
	 fullVersion = nAgt.substring(verOffset+1);
	 if (browserName.toLowerCase()==browserName.toUpperCase()) {
	  browserName = navigator.appName;
	 }
	}
	// trim the fullVersion string at semicolon/space if present
	if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
	if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);

	majorVersion = parseInt(''+fullVersion,10);
	if (isNaN(majorVersion)) {
	 fullVersion  = ''+parseFloat(navigator.appVersion); 
	 majorVersion = parseInt(navigator.appVersion,10);
	}

var dir = location.pathname.substring(0,location.pathname.lastIndexOf('/')+1);
	
//	alert('browserName'+browserName);	
//	alert('dir' + dir);

	return browserName;

//	document.write('Browser name  = '+browserName+'<br>');
//	document.write('Full version  = '+fullVersion+'<br>');
//	document.write('Major version = '+majorVersion+'<br>');
//	document.write('navigator.appName = '+navigator.appName+'<br>');
//	document.write('navigator.userAgent = '+navigator.userAgent+'<br>');


}

function sql_safe(str)
{
   str = escape(str);	
   str = str.replace(/[']/g, '');
   str = str.replace(/["]/g, '');
   return str.replace(/[\"]/g, "");
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
//alert( 'cookie : ' + c_name + ' value :' + value);

exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

// This function is used to add data into a Cookie
// The function accepts 2 values.
// The first variable is used in case only 1 variable is needed to be stored.
// The second variable is used in case a variable - value pair needs to be stored.
// In case 2 variable are used the value will be used to in "variable : value," format
function addtoCookie(c_name,value,value2,expiredays)
{
var exdate=new Date();
var data = getCookie(c_name);
//alert( 'DIMENSION Cookie : ' +  getCookie('DIMENSION'));
if (data.length > 0){
		if (value2.length > 0)
		{	data = data + value + ":" + value2 + "," ;		}
		else
		{	data = data + value + "," ;						}
	}
else{
		if (value2.length > 0)
		{	data = value + ":" + value2 + "," ;			}
		else
		{	data = value + "," ;						}
	}
//alert( 'Cookie : ' + c_name + ' value :' + data);
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(data)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function removeFromCookie(c_name,value,value2,expiredays)
{
var exdate=new Date();
var data = getCookie(c_name);
// Check if the cookie has anything
if (data.length > 0)
	{	//Check if its a 2 variable thingy. 
		if (value2.length > 0)
		{	data = data.replace(value + ":" + value2 + ",", '');	}
		else //Check if its a 1 variable thingy. 
		{	data = data.replace(value + ",", '');					}	
	}
//alert( 'Cookie : ' + c_name + ' value :' + data);
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(data)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons

//The following line is used to check the onClick event of a radio button
//onclick=""alert('Checked value is:+getCheckedValue(document.forms['radioExampleForm'].elements['chartmeasure']));

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";

	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// The following function is used to limit the number of characters within a text box
// The function will take 2 arguments. One is the text box value and secondly the max limit for 
// that text box
function textCounter(field, maxlimit) {
	//Checking if the text box value has exceeded the max limit or not
    if (field.value.length > maxlimit) // if too long...trim it!
	{
        field.value = field.value.substring(0, maxlimit);
	}
// alert (' Value : ' + field.value + ' :: Limit :: ' + maxlimit)
}

//This function is used to check if a variable has a minimum amount of text or not.
function mintextCheck(name,value,minlimit)
{
	
	// alert ('Value is :' + 	value + ':' + value.length)

	if ( value == 0 )
	{
		alert (name + ' is blank. Please enter to proceed. ')
		return false;
	}
	else if ( value.length < minlimit)
	{
		alert (name + ' name has to be a minimum of ' + minlimit + ' characters.')
		return false;
	}
return true;
}


//This function is to ensure on alphabet characters are entered in a text box.
// If anything else is entered it will not allow it to be entered
function ValidateAlphabets(evt)
{
         var charCode = (evt.which) ? evt.which : evt.keyCode;
		 //alert('In ValidateAlpha charCode' + charCode );

		//Capital/Large Alphabets					Small Alphabets
		if  ( ( (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) ) || charCode < 30 )
		{	return true;	}
		// for underscore _
		if ( charCode == 95 )
		 {   return true;	}

         return false;
}

//This function is to ensure on alpanumeric characters are entered in a text box.
// If anything else is entered it will not allow it to be entered
function ValidateAlpha(evt)
{
         var charCode = (evt.which) ? evt.which : evt.keyCode;
		 //alert('In ValidateAlpha charCode' + charCode );

		//Capital/Large Alphabets					Small Alphabets
		if  ( ( (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) ) || charCode < 30 )
		{	return true;	}
		// For numeric 
		 if ( ( charCode >= 48 && charCode <= 57) || charCode < 30 )
		 {   return true;	}
		// for underscore _
		if ( charCode == 95 )
		 {   return true;	}

         return false;
}

//This function is to ensure only numeric characters are entered in a text box.
// If anything else is entered it will not allow it to be entered
function ValidateNumeric(evt)
{
         var charCode = (evt.which) ? evt.which : evt.keyCode;
		 //alert('In ValidateAlpha charCode' + charCode );

		// For numeric 
		 if ( ( charCode >= 48 && charCode <= 57) || charCode < 30  )
		 {   return true;	}

         return false;
}

//This function is to ensure only numeric + decimal characters are entered in a text box.
// If anything else is entered it will not allow it to be entered
function ValidateDecimal(evt)
{
         var charCode = (evt.which) ? evt.which : evt.keyCode;
//		 alert('In ValidateAlpha charCode' + charCode );

		// For numeric 
		 if ( ( charCode >= 48 && charCode <= 57) || charCode < 30 || charCode == 46 )
		 {   return true;	}

         return false;
}


//This function is to ensure on alpanumeric characters along with space are entered in a text box.
// If anything else is entered it will not allow it to be entered
function ValidateAlphaWithSpace(evt)
{
         var charCode = (evt.which) ? evt.which : evt.keyCode;
		 //alert('In ValidateAlpha charCode' + charCode );

		//Capital/Large Alphabets					Small Alphabets												'Space
		if  ( ( (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) ) || charCode < 30 || charCode == 32)
		{	return true;	}
		// For numeric 
		 if ( ( charCode >= 48 && charCode <= 57) || charCode < 30 || charCode == 32)
		 {   return true;	}
		// for underscore _
		if ( charCode == 95 )
		 {   return true;	}
		// for left and right arrows and the delete button
		if ( charCode == 37 || charCode == 39 || charCode == 46 )
		 {   return true;	}

         return false;
}



//This functions is used to clear the text of a text box
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

//Nothing
function nothing()
	{
	}


//Blank function.
function blank()
	{
		return true;
	}
//Show function
function showloading()
{
	var myBox=document.getElementById('myDiv');document.getElementById('myDiv').style.display=(document.getElementById('myDiv').style.display=='none' ? 'block': 'none');
}

//Show function withing a window
function showloadingWindows()
{
	var myBox=document.getElementById('myDivWindows');document.getElementById('myDivWindows').style.display=(document.getElementById('myDivWindows').style.display=='none' ? 'block': 'none');
}

//Alert Box functin
function alertbox(msg)
{
	alert (msg);
}

//Function to convert text box string into UPPER STRING
function up(lstr)
{
	var str=lstr.value;
	lstr.value=str.toUpperCase();
}

//Print function
function printpage()
  {
	window.print()
  }



function chageImageSize(strImg,i)
{
	alert('Bye ');
strImg.height=32+i;
strImg.width=32+i;
}



//function for getting the window size
// Function to resize the Data Grid component as per the window size
function scr_load() 
	{
      var divh = document.body.offsetHeight;
	  var divw = document.body.offsetWidth;
	  var target = document.getElementById('ContentDiv');
	  target.style.width = ( divw - 305 ) + "px";
	  target.style.height = ( divh - 370 ) + "px";

//	  var charttarget = document.getElementById('chartingArea');
//	  charttarget.style.width = ( divw - 305 ) + "px";
//	  charttarget.style.height = ( divh - 520 ) + "px";
	}

function refresh() 
{ 
    window.location.reload(); 
} 



//SETTING THE VALUE OF A GIVEN ELEMENT
function setElementValue(elementName,value)
{		
//	alert(elementName);
	document.getElementById(elementName).value = value;
//	alert ( ' Element ' + elementName + " Value " + document.getElementById(elementName).value);	
}


//GETTING THE VALUE OF A GIVEN ELEMENT
function getElementValue(elementName)
{	
//	alert('elementName' + elementName);

	var value  = document.getElementById(elementName).value; 

//	alert ( ' Element ' + elementName + " Value " + value);	
	return value;
}

