/* NOT BEING USED YET
function validateBrowser()
{
	strVers=navigator.appVersion
	strName=navigator.appName
	strPlat=navigator.platform
	intIndex1=strVers.indexOf("MSIE");
	intIndex1=intIndex1+5
	intIndex2=strVers.lastIndexOf(";");
	intVer=strVers.substring(intIndex1, intIndex2)
	intVer=parseInt(intVer)
	if (strName != "Microsoft Internet Explorer" || strPlat != "Win32" || intVer < "6")
	{
		strMsgGetIE="<TABLE cellSpacing=0 cellPadding=0 width='95%' border=0 height='8'><TR>"
		strMsgGetIE+="<TD bgColor='#336699' height=25 width=15>&nbsp;</TD><TD bgColor='#666666' width=500px><FONT face=Tahoma "
		strMsgGetIE+="size=4 color=white><b>Data Access Page Notification</B></FONT></TD></TR>"
		strMsgGetIE+="<TR><TD bgColor='#cccccc' width=15>&nbsp;</TD><TD bgColor='#cccccc' width=500px><br />"
		strMsgGetIE+="<p><font face='Tahoma' size='2'>"
		strMsgGetIE+="This page requires Windows IE 6.0 or higher.</p>"
		strMsgGetIE+="<a href='http://www.microsoft.com/isapi/redir.dll?Prd=Office&Sbp=Access&Pver=10&Ar=DPdesigner&Sba=IEhome&Plcid=1033'><p align='center'>"
		strMsgGetIE+="Click here to install the latest version of Internet Explorer.</a></font></p><br /></TD></TR></TABLE>"
		document.write(strMsgGetIE)
	}
}
*/

/*
//==================================================================================
function window_onload()
//==================================================================================
{
	//keep after other onload code 
	ResetScrollPos(); 
} 

//==================================================================================
function SaveScrollPos() 
//==================================================================================
{
	if (document.all) 
		thisForm.SCROLLPOS.value = document.body.scrollTop; 
} 

//==================================================================================
function ResetScrollPos()
//==================================================================================
{
	<%
	if (Request.Form["SCROLLPOS"] != null && Request.Form["SCROLLPOS"] != "") 
		Response.Write("if (document.all) document.body.scrollTop = " + Request.Form["SCROLLPOS"]); 
	%>
	return;
}
*/


//==================================================================================
//Function culled from www.paye.org/greg/code/
function Replace(sExpression, sFind, sReplaceWith, iStart, iCount)
//==================================================================================
{
	var iLengthExp 		= 0;
	var iRemoveLength 	= 0;
 	var iStartPosition 	= 0;
	var iSubstringLength= 0;
	var iLoop			= 0;
	var sFirstPart 		= "";
	var sThirdPart 		= "";
	var sStartSubstring = "";

	// check for nulls in required parameters	
	if ((sExpression == null) || (sFind == null) || (sReplaceWith == null))
		return null;

	// prevent nasty recursion later
	if (sFind == sReplaceWith)
		return sExpression;
	
	// parameter check, default to 0
	if ((iStart == null) || (iStart < 0))
		iStart = 0;
	
	// parameter check, default to -1
	if ((iCount == null) || (iCount < 1))
		iCount = -1;

	iLengthExp = sExpression.length;	// check length of expression
	iRemoveLength = sFind.length;		// check length of sFind

	// check if sExpression or sFind are empty/blank
	if ((iLengthExp < 1) || (iRemoveLength < 1))
		return sExpression;			

	// sanity check start vs. expression length
	if (iStart > iLengthExp)
		return sExpression;	

	// do this if the user specified a place to start the replacement(s)
	if (iStart > 0)
	{	
		// extract substring left of the start position
		sLeftOfStart = sExpression.substring(0, iStart);
		
		// replace sExpression with the substring to the right of the iStart specified
		sRightOfStart = sExpression.substring(iStart, iLengthExp);	
		sExpression	= sRightOfStart;	
	}

	// check to see if sFind is in sExpression 
	iStartPosition = sExpression.indexOf(sFind);
	
	// do this while sFind is found within sExpression
	while (iStartPosition != -1)
	{
		// sExpression's length will probably change in this loop
		iLengthExp = sExpression.length;		
		
		// based on the new iStartPosition, determine where 
		// we will get sExtract from sExpression
		iSubstringLength = iStartPosition + iRemoveLength;

		// get everything to the left of the substring being removed
		sFirstPart = sExpression.substring(0, iStartPosition);
		
		// get everything to the right of the substring being removed
		sThirdPart = sExpression.substring(iSubstringLength, iLengthExp);

		// reform sExpression with the left substring, the replacement substring, and the right substring
		sExpression = sFirstPart + sReplaceWith + sThirdPart;

		// check to see if there is another instance of the sFind 
		// substring left in sExpression
		iStartPosition = sThirdPart.indexOf(sFind);

		// if substring still remains in the string, move the cursor up to prevent any nasty recursion
		if (iStartPosition > -1)
			iStartPosition = sFirstPart.length + sReplaceWith.length + iStartPosition;
		
		iLoop++;	

		// if the user specified a count, only do as many replacements as specified
		if ((iCount > -1 ) && (iLoop == iCount)) 
			iStartPosition = -1;

	}// end while( iStartPosition != -1 )
	
	// if user specified start point, put the substring from before the start point back 
	// with the substring that had the replacement(s) performed on it
	if (iStart > 0) 
		sExpression = sLeftOfStart + sExpression;

	return sExpression;
}

//==================================================================================
// Allows accessing querystring parameters as properties
// Usage: 
//	 var args = QueryStringArgs();
//	 if (args.x) //parameter found - returns value
function QueryStringArgs()
//==================================================================================
{
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i = 0; i < pairs.length; i++)
	{
		var pos = pairs[i].indexOf("=");
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos + 1);
		args[argname] = unescape(value);
	}
	
	return args;
}

//==================================================================================
function Popup(url, height, width)
//==================================================================================
{
	var popup = window.open(url,"Choices_Popup","height=" + height + ", width=" + width + ", scrollbars, resizable");
	popup.focus();
}

//==================================================================================
function PopupModal(url, height, width)
//==================================================================================
{
	var popup = window.open(url,"Choices_Popup","height=" + height + ", width=" + width);
	popup.focus();
}

//==================================================================================
function GetSearchString()
//==================================================================================
{
	var search = window.prompt("Enter search string:","");

	if (search.length > 0)
		__doPostBack("search", search);
}

//==================================================================================
function SetTextboxStyles(newstyle, isreadonly)
//==================================================================================
{
	var thisForm = document.forms[0];

	var InputTags = document.body.all.tags("INPUT");

	for (var i = 0; i < InputTags.length; i++) 
	{
		//alert(InputTags[i].name + " " + InputTags[i].value);
		thisTag = InputTags[i];
		if (thisTag.getAttribute("type") == 'text')
		{
			thisTag.style.borderStyle = newstyle;
			//thisTag.setAttribute("attributename",newvalue);
		}
	}
	
	//TODO: Readonly attribute CANNOT BE SET this way!?
	var InputTags2 = document.body.all.tags("TEXTAREA");
	
	for (var i = 0; i < InputTags2.length; i++) 
	{
		thisTag = InputTags2[i];
		thisTag.style.borderStyle = newstyle;
		thisTag.setAttribute("readonly","");
	}
}

//==================================================================================
function CallPrint(div)
//==================================================================================
{
	var prtContent = document.getElementById(div);
	var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
	WinPrint.document.write(prtContent.innerHTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
	//prtContent.innerHTML = strid;
}


//==================================================================================
function SelectAll(parent)
//==================================================================================
{
    //alert("in here 1");
    var checkedStatus = 0;
    var saveProductBtn = document.all("ctl00_ContentPlaceHolder1_Activate");
    //alert("in here 2**" + parent);    
    if(parent.checked)
    {
        //alert("in here 3");
        checkedStatus = 1;
        saveProductBtn.disabled = false;  		
        saveProductBtn.style.display = "inline";
    }
    else
    {
        saveProductBtn.style.display = "none";
        saveProductBtn.disabled = true;
        checkedStatus = 0;
    }
    //ctl00_ContentPlaceHolder1_inactiveStudents_ctl02_CheckBox1
    //ctl00_ContentPlaceHolder1_inactiveStudents_ctl03_CheckBox1
    var table = document.all("ctl00_ContentPlaceHolder1_inactiveStudents");
	for(index=2;index<=table.rows.length;index++)
	{
		var qtyValue;  
		if(index < 9)
		{    
			document.all("ctl00_ContentPlaceHolder1_inactiveStudents_ctl0" + index + "_CheckBox1").checked = checkedStatus;            
		}
		else
		{    
			document.all("ctl00_ContentPlaceHolder1_inactiveStudents_ctl" + index + "_CheckBox1").checked = checkedStatus;
		}
	}   
}

//==================================================================================
function EnableButton(child)
//==================================================================================
{
    var checkedCount = 0;
    var saveProductBtn = document.all("ctl00_ContentPlaceHolder1_Activate");	
    var allCheck = document.all("ctl00_ContentPlaceHolder1_inactiveStudents_ctl01_selectProduct");    
    var unchecked = 0;
    
    var table = document.all("ctl00_ContentPlaceHolder1_inactiveStudents");
    var rowCount = table.rows.length - 1;
    for(index=2;index<=table.rows.length;index++)
    {
        var ctrlId;  
        if(index < 9)
        {    
            ctrlId  = "ctl00_ContentPlaceHolder1_inactiveStudents_ctl0" + index + "_CheckBox1";
        }
        else
        {    
            ctrlId  = "ctl00_ContentPlaceHolder1_inactiveStudents_ctl0" + index + "_CheckBox1";
        }
        if(document.all(ctrlId).checked)
        {            
            checkedCount = checkedCount + 1;
        }
        else
        {			
			unchecked = unchecked + 1;			
        }
    }    
    
	if(checkedCount > 0)
    {
        saveProductBtn.style.display = "inline";
        saveProductBtn.disabled = false;
    }
    else
    {
        saveProductBtn.style.display = "none";
        saveProductBtn.disabled = true;
    }
    
    if(unchecked > 0)
    {
		allCheck.checked = 0;
    }
    else if(checkedCount == rowCount)
    {
		allCheck.checked = 1;
    }
}

//==================================================================================
//  Hide Column Functions
//==================================================================================

// Hide each cell in a gridview column
function HideCol(gridView, colIndex, colName) {
    var rows = document.getElementById(gridView).rows;
    for (i = 0; i < rows.length; i++)
        if (rows[i].id != gridView + "_pager")
            rows[i].cells[colIndex].style.display = "none";
    // Add the name and index of the hidden column to the dropdown list
    var hiddenCols = document.getElementById(gridView + "_showCols");
    hiddenCols.options[hiddenCols.length] = new Option(colName, colIndex);

    SetupHiddenCols(gridView);
}

// Show each cell in a gridview column    
function ShowCol(gridView, colIndex) {
    var rows = document.getElementById(gridView).rows;
    for (i = 0; i < rows.length; i++)
        if (rows[i].id != gridView + "_pager")
            rows[i].cells[colIndex].style.display = "";
    // Remove the name and index of the hidden column from the dropdown list
    var hiddenCols = document.getElementById(gridView + "_showCols");
    for (i = 0; i < hiddenCols.options.length; i++)
        if (hiddenCols.options[i].value == colIndex)
            hiddenCols.options[i] = null;

    SetupHiddenCols(gridView);
}

// Setup the drop down list to show the hidden columns
function SetupHiddenCols(gridView) {
    var hiddenCols = document.getElementById(gridView + "_showCols");
    if (hiddenCols)
        if (hiddenCols.options.length > 1)
            hiddenCols.style.display = "";
        else
            hiddenCols.style.display = "none";
}