﻿/* JScript File
if(navigator.appName == "Netscape" || (typeof(opera) != "undefined" && parseFloat(opera.version()) >= 9) || navigator.vendor == "Apple Computer, Inc." || navigator.vendor == "KDE")
{    
    window.addEventListener("load",resizeElement,true);
    window.addEventListener("resize",resizeElement,true);
}

function resizeElement()
{    
    if(document.body != null)
    {        
        try
        {
            var x = 0;             
            x = document.body.clientHeight - 38;          
            var t = document.body.getElementsByTagName("TABLE")[0];     
            var h = 0;
            var xr = null; 
            if(t != null && t.rows != null)
            {
                t.style.height = ""; 
                for(var i=0;i<t.rows.length;i++)
                {
                    var r = t.rows[i]; 
                    if(r.getAttribute("id") != "xr")
                        h += r.offsetHeight;        
                    else
                            xr = r;                     
                }        
                if(xr != null)
                {
                    xr.cells[0].style.height = (x-h);           
                    xr.style.height = (x-h);                           
                }
            }
        }
        catch(xx) 
        {
           
         } 
    }
}
*/

function ExpandAll()
{
	var lnkExpand = document.getElementById("ctl00_cphContent_linkExpandAll");
	var imgExpand = document.getElementById("ctl00_cphContent_imgExpandAll");
	
	if ( lnkExpand == null && imgExpand == null )
	{
	    lnkExpand = document.getElementById("linkExpandAll");
	    imgExpand = document.getElementById("imgExpandAll");
    }
	
	var expanded = false;
	var divs = document.getElementsByTagName("DIV");	
	
	if(lnkExpand.innerText == "Expand All")
	{
		expanded = true;
		lnkExpand.innerText = "Collapse All";
		imgExpand.src = "images/up.gif";		
		for(var i=0; i < divs.length; i++)
		{
			if(divs[i].id.substring(0, 7).toLowerCase() == "members")
				divs[i].style.display = "block";
		}
	}
	else
	{
		expanded = false;
		lnkExpand.innerText = "Expand All";
		imgExpand.src = "images/down.gif";		
		for(var i=0; i < divs.length; i++)
		{
			if(divs[i].id.substring(0, 7).toLowerCase() == "members")
				divs[i].style.display = "none";
		}
	}
}

function EnsureHoursIsFilled(control){
	var field = document.getElementById(control);
	var value = field.value.toString();
	
	if(value.length < 4)
	{
		var decimalPlace = value.indexOf(".");
		if(decimalPlace == -1)
		{
			field.value = value + ".00";
		}
		else
		{
			var array = value.split(".");
			
			if(array[1].length != 2)
			{
				if((array[1] == "0") || (array[1] == "5"))
				{
					field.value = value + "0";								
				}
			}
		}					
		Page_ClientValidate();
	}
}

function IsValidHourPeriod(val){
	var fullHours;
	var partHours;
	var temp = new Array();
	var fullHoursValid = false;
	
	temp = val.split('.');
	
	fullHours = temp[0];
	fullHours = fullHours * 1;
	if(fullHours >= 0)
		if(fullHours <= 24)
			fullHoursValid = true;			
	
	partHours = temp[1];
	switch(partHours){
		case "0":
			if(fullHoursValid)
				return true;
		case "00":
			if(fullHoursValid)
				return true;
		case "25":
			if(fullHoursValid)
				return true;
		case "5":
			if(fullHoursValid)
				return true;
		case "50":
			if(fullHoursValid)
				return true;
		case "75":
			if(fullHoursValid)
				return true;
	}	
	return false;
}

function ShowChangedValueHelp(propertyName, propertyValue, oldValue)
{
	var sz = "";
	
	sz += "Issue properties highlighted with blue text specifies that the value of this issue property was modified \r\n";
	sz += "when the history item being viewed was created. The value shown for the issue property is the value\r\n";
	sz += "that the property was changed to during said creation.";
	sz += "\r\n\r\n";
	sz += "In this case: The property '" + unescape(propertyName) + "' was changed from \r\n\n'" + unescape(oldValue) + "'\r\n\nto\r\n\n '" + unescape(propertyValue) + "' \r\n\nwhen the history item ";
	sz += "you are currently viewing was saved.";
	sz += "\r\n\r\n";
	sz += "All other issue properties shown are displaying the current value of the property.";
	
	sz = sz.replace(/\+/gi, " ");
	sz = sz.replace(/<BR>/gi, "\r\n");
	alert(sz);
}

function SubscriptionTypeChanged(ddlID, txtID){
	
	var ddl = document.getElementById(ddlID);
	var txt = document.getElementById(txtID);
	
	if(ddl.value == "OnceOff")
		txt.disabled = false;
	else
		txt.disabled = true;
}	

function ValidateHours(source, args)
{
	if(IsValidHourPeriod(args.Value))
		args.IsValid=true;
	else 
		args.IsValid=false;
}