<!--
//Add additional prototyped helper methods to all arrays (we want to treat the arrays like a dictionary)
Array.prototype.IndexOf = IndexOf;
Array.prototype.ValueOf = ValueOf;
Array.prototype.ContainsValue = ContainsValue;

var UserCart = new Cart();
var Global = new SessionItems();  //Holds global session parameters
var Page = new SessionItems();  //Holds session parameters particular to this page
var FormUpdate = new Form();
var EAWCurrent=""; // Current Edition Assistance Wizard 

var PageContextTag="";

var IE6 = true;

// for now only target IE
if(navigator.appName == 'Microsoft Internet Explorer') { 
    // if IE7 then set our flag to false!
    if(parseInt(navigator.appVersion) > 3)
    {
        if(navigator.userAgent.toLowerCase().indexOf("msie 7") != -1) IE6 = false; 
        if (navigator.userAgent.toLowerCase().indexOf("msie 8") != -1) IE6 = false;
    }
}

function SessionItems()
{
    this.Items = new Array();
    this.GetItem = GetSessionItem;
    this.SetItem = SetSessionItem;
    this.ModifyItem=ModifySessionItem;
    this.SetItemByExpression = SetSessionItemByExpression;
    this.ToString = SessionItemsToString;
}

function SetSessionItem(key, value) 
{ 
	// get the value and evaluate it
	var evaluatedvalue=(GetAbsoluteValueOf(value));
	//Sets an attribute value 
	var idx = this.Items.IndexOf(key);
	//If the item exists, update it else add it to the collection
	if (idx == null)
		this.Items.push(new KeyPair(key, evaluatedvalue));
	else
		this.Items[idx].value = evaluatedvalue;
}	

function ModifySessionItem(key, value) 
{ 
	// get the value and evaluate it
	var evaluatedvalue=(GetAbsoluteValueOf(value));
	//Sets an attribute value 
	var idx = this.Items.IndexOf(key);
	//If the item exists, update it else do nothing
	if (idx != null)
		this.Items[idx].value = evaluatedvalue;
}	


function SetSessionItemByExpression(key, expression)
{
    this.SetItem(key,PreEval(expression, "expression"));
}

function GetSessionItem(key) 
{ 
    //Gets an attribute value
    var strReturn="";
	var idx = this.Items.IndexOf(key);
	if (idx == null)
	{
	    return strReturn;
	}
	else
	{
	    return this.Items.ValueOf(key);
	}
}

function SessionItemsToString() { 
	var ret = '';
	//Serialise the items (key:value;key:value)
	for(var si=0;si<this.Items.length; si++) 
	{
        if ((this.Items[si].key.indexOf("|")==-1)&&(this.Items[si].value.toString().indexOf("|")==-1))
	    {
		    ret += 	this.Items[si].key + ':' + this.Items[si].value.toString() + ";";
		}
	}
	
	if (ret.endsWith(';')) {
		ret = ret.substr(0,ret.length - 1);
	}	
	return ret;
}

function Form()
{
	this.FormItems = new Array();			
	this.SetItem = SetFormItem;
	this.SetItemByExpression = SetFormItemByExpression;
	this.toString = FormToString;
}

function SetFormItem(pageName,pageSection,control,value)
{
	var evaluatedvalue=(GetAbsoluteValueOf(value));
    var key=pageName+pageSection+control;
	var idx = this.FormItems.IndexOf(key);
	if (idx == null)
	{
	    this.FormItems.push(new KeyPair(key, new FormItem()));
	    idx = this.FormItems.IndexOf(key);
	}
	this.FormItems[idx].key = key;
	this.FormItems[idx].pageName=pageName;
	this.FormItems[idx].pageSection=pageSection;
	this.FormItems[idx].control=control;
	this.FormItems[idx].value=evaluatedvalue; 
}

function SetFormItemByExpression(pageName,pageSection,control,expression)
{
	var evaluatedvalue=PreEval(expression, "expression");
    this.SetItem(pageName,pageSection,control,evaluatedvalue)
}

function FormToString() 
{ 
	var ret = '';
	for(var ctsi=0;ctsi<this.FormItems.length; ctsi++) 
	{
        if (this.FormItems[ctsi].control.toString().toLowerCase()!="ctl00$masterscriptmanager")
	    {
    		ret += 	this.FormItems[ctsi].pageName.toString()+":"+this.FormItems[ctsi].pageSection.toString()+":"+this.FormItems[ctsi].control.toString()+":"+this.FormItems[ctsi].value.toString()+";";
    	}
	}
	return ret;
}


function FormItem() 
{
	this.key='';
	this.pageName='';
	this.pageSection='';
	this.control='';
	this.value='';
}

/* SC Cart */
function Cart()
{
	this.Attribs = new Array();				//Array of keypair objects
	this.Products = new Array();			//Array of keypair objects, where the value is of type 'product'
	this.SetAttribute = SetCartAttribute;
	this.SetAttributeByExpression = SetCartAttributeByExpression;
	this.GetAttribute = GetCartAttribute;
	this.SetProductAttribute = SetCartProductAttribute;
	this.GetProductAttribute = GetCartProductAttribute;
	this.SetProductAttributeByExpression = SetCartProductAttributeByExpression;
	this.AddNewProduct = CartAddNewProduct;
	this.AddProduct = CartAddProduct;
	this.RemoveProduct = CartRemoveProduct;
	this.toString = CartToString;
}

function SetCartAttribute(key, value) 
{ 
	// get the value and evaluate it
	var evaluatedvalue=(GetAbsoluteValueOf(value));
	//Sets an attribute value 
	var idx = this.Attribs.IndexOf(key);
	//If the item exists, update it else add it to the collection
	if (idx == null)
		this.Attribs.push(new KeyPair(key, evaluatedvalue));
	else
		this.Attribs[idx].value = evaluatedvalue;
}	

function SetCartAttributeByExpression(key, expression) 
{ 
	var evaluatedvalue=PreEval(expression, "expression");
	//Sets an attribute value 
	var idx = this.Attribs.IndexOf(key);
	//If the item exists, update it else add it to the collection
	if (idx == null)
		this.Attribs.push(new KeyPair(key, evaluatedvalue));
	else
		this.Attribs[idx].value = evaluatedvalue;}	

function GetCartAttribute(key) { //Gets an attribute value
	return this.Attribs.ValueOf(key);
}

function SetCartProductAttribute (productkey, attributekey, value) {
	var prod = this.Products.ValueOf(productkey);
	if (prod != null) 
	{
		prod[attributekey] = GetAbsoluteValueOf(value);
	}
	// hack to force removal of products
	if ((attributekey=="Quantity")&&(value=="0")&&(prod==null))
	{
    	this.Products.push(new KeyPair(productkey, new Product()));
	    prod = this.Products.ValueOf(productkey);
	    if (prod != null) 
    	{
		    prod[attributekey] = GetAbsoluteValueOf(value);	
        }		
	}
}

function SetCartProductAttributeByExpression (productkey, attributekey, expression) 
{
	var prod = this.Products.ValueOf(productkey);
	if (prod != null) 
	{
		prod[attributekey] = PreEval(expression, "expression");
	}
}

function GetCartProductAttribute (productkey, attributekey) {
	var prod = this.Products.ValueOf(productkey);
	if (prod != null) {
		return prod[attributekey];
	}
	return '';
}

function CartAddNewProduct(productkey) 
{
	var idx = this.Products.IndexOf(productkey);
	
	//If the doesn't exist add it to the collection
	if (idx == null)
		this.Products.push(new KeyPair(productkey, new Product()));
}

function CartAddProduct(productkey, product) {
	var idx = this.Products.IndexOf(productkey);
	
	//If the doesn't exist add it to the collection
	if (idx == null)
	{
		this.Products.push(new KeyPair(productkey, product));
	}
}

function CartRemoveProduct(productkey) {
	var idx = this.Products.IndexOf(productkey);
	
	//If the doesn't exist add it to the collection
	if (idx != null)
	{
		this.Products.splice(idx, 1);
	}
}

function CartToString() { 
	var ret = '';
	
	//Global|Page|CartAttributes|CartProducts
	ret += Global.ToString() + '|';
	ret += Page.ToString() + '|';
	
	//Serialise the attributes (key:value;key:value)
	for(var ctsi=0;ctsi<this.Attribs.length; ctsi++) 
	{
        ret += 	this.Attribs[ctsi].key + ':' + this.Attribs[ctsi].value.toString() + ";";
	}
	if (ret.endsWith(';')) {
		ret = ret.substr(0,ret.length - 1);
	}
	
	//Deliminate the attributes from the products via a pipe
	ret += '|';
	
	//Serialise the products (property:value;property:value)
	for(var pi=0;pi<this.Products.length; pi++) {
		ret += 'ProductKey' + ':' + this.Products[pi].key + ';'
		ret += 'ProductFamilyCode' + ':' + this.Products[pi].value.ProductFamilyCode + ';'
		ret += 'ProductTypeCode' + ':' + this.Products[pi].value.ProductTypeCode + ';'
		ret += 'ProductLanguageCode' + ':' + this.Products[pi].value.ProductLanguageCode + ';'
		ret += 'NameDifferentiatorCode' + ':' + this.Products[pi].value.NameDifferentiatorCode + ';'
		ret += 'PriceDifferentiatorCode' + ':' + this.Products[pi].value.PriceDifferentiatorCode + ';'
		ret += 'LicenseCountCode' + ':' + this.Products[pi].value.LicenseCountCode + ';'
		ret += 'PoolName' + ':' + this.Products[pi].value.PoolName + ';'
		ret += 'DiskQuantity' + ':' + this.Products[pi].value.DiskQuantity + ';'
		ret += 'DiskLanguage' + ':' + this.Products[pi].value.DiskLanguage + ';'
		ret += 'DocQuantity' + ':' + this.Products[pi].value.DocQuantity + ';'
		ret += 'DocLanguage' + ':' + this.Products[pi].value.DocLanguage + ';'
		ret += 'Quantity' + ':' + this.Products[pi].value.Quantity + ';'
		ret += 'HardwareInterfaceCode' + ':' + this.Products[pi].value.HardwareInterfaceCode + ';'
		ret += 'ProductName' + ':' + this.Products[pi].value.ProductName + ';'
		ret += 'OfferingCode' + ':' + this.Products[pi].value.OfferingCode /* New field*/
		//Deliminate each product via a pount
		ret += '#';
	}
	if (ret.endsWith('#')) {
		ret = ret.substr(0,ret.length - 1);
	}
	return ret;
}
	
function Product() 
{
	//create the default product
	this.ProductFamilyCode='';
	this.ProductTypeCode='LSA';
	this.ProductLanguageCode='EN';
	this.NameDifferentiatorCode='NON';
	this.PriceDifferentiatorCode='N/A';
	//reset this default to 0, some products need to sell single units.
	this.LicenseCountCode=0;
	this.PoolName='';
	this.DiskQuantity='';
	this.DiskLanguage='';
	this.DocQuantity='';
	this.DocLanguage='';
	this.Quantity=0;
	this.Quantity=0;
	this.HardwareInterfaceCode='N/A';
	this.ProductName=''; /* New field */
	this.OfferingCode='N/A';
	
	
	//if we have an argument array of 15, restore the product properties
	if (Product.arguments.length == 15) {
		args = Product.arguments;
		this.ProductFamilyCode=args[0];
		this.ProductTypeCode=args[1];
		this.ProductLanguageCode=args[2];
		this.NameDifferentiatorCode=args[3];
		this.PriceDifferentiatorCode=args[4];
		this.LicenseCountCode=args[5];
		this.PoolName=args[6];
		this.DiskQuantity=args[7];
		this.DiskLanguage=args[8];
		this.DocQuantity=args[9];
		this.DocLanguage=args[10];
		this.Quantity=args[11];
		this.HardwareInterfaceCode=args[12];
		this.ProductName=args[13]; /* New field */
		this.OfferingCode=args[14]; /* New field */
	}
}

//Function prototype returns the index of the keypair element based on a comparison of the keypair.key and key param.
function IndexOf(key) {
	for (i=0; i<this.length; i++) 
	{
	    if (this[i]!=null)
	    {
    		if (this[i].key == key) 
	    	{
		    	return i;
		    }
        }
	}	
}

//Function prototype returns the keypair value object based on a comparison of the keypair.key and key param.
function ValueOf(key) 
{
	for (i=0; i<this.length; i++) 
	{
	    if (this[i]!=null)
	    {
    		if (this[i].key == key) 
    		{
			    return this[i].value;
			}
		}
	}	
}

//Function prototype returns the index of the element whose value is equal to the supplied param.  Returns -1 of no match is found.
function ContainsValue(value) {
	var ret = -1;
	for (i=0; i<this.length; i++) {
		if (this[i].value == value) {
			ret = i;
		}
	}
	return ret;	
}

function GetFirstProgram(strOrgType)
{
    var strReturn="";
	var strPrograms=GetAbsoluteValueOf("programs").replace(/,/g,';');
	var programArray = strPrograms.split(";");
    var programOptions = CorrectProgramOptions().split(";");
	for (var rpi=0; rpi<programArray.length; rpi++) 
	{
	    for (var rpi2=0; rpi2<programOptions.length; rpi2++) 
	    {
	        if (strReturn=="")
	        {
        	    var programOptionsDetail = programOptions[rpi2].split("_");
        	    if ((programOptionsDetail[1]==strOrgType)&&(programOptionsDetail[0]==programArray[rpi]))
    	        {
        	        strReturn=programOptionsDetail[0];
		        }
        	    if ((programOptionsDetail[1]==strOrgType)&&(programOptionsDetail[0]=="OLV")&&("OLVCWO"==programArray[rpi]))
    	        {
        	        found=programOptionsDetail[0];
		        }		        
            }
        }
    }
    return strReturn;
}


function CorrectProgramOptions()
{
    var strReturn=GetAbsoluteValueOf("programOptions");
    strReturn=strReturn.replace("_NON","_CRP");
    strReturn=strReturn.replace("_ACD","_EDU");
    return strReturn;
}


//Function sets the 'recommended-programs' cart attribute to all available programs
function RecommendAllPrograms() 
{
	UserCart.SetAttribute('recommended-programs',GetAbsoluteValueOf("programs").replace(/,/g,';'));
    var strOrgType=GetValueOf("OrgType");
	var programArray = UserCart.GetAttribute('recommended-programs').split(";");
    var programOptions = CorrectProgramOptions().split(";");
	for (var rpi=0; rpi<programArray.length; rpi++) 
	{
	    var found=false;
	    for (var rpi2=0; rpi2<programOptions.length; rpi2++) 
	    {
	        if (found==false)
	        {
        	    var programOptionsDetail = programOptions[rpi2].split("_");
        	    if ((programOptionsDetail[1]==strOrgType)&&(programOptionsDetail[0]==programArray[rpi]))
    	        {
        	        found=true;
		        }
        	    if ((programOptionsDetail[1]==strOrgType)&&(programOptionsDetail[0]=="OLV")&&("OLVCWO"==programArray[rpi]))
    	        {
        	        found=true;
		        }
		        
            }
        }
        if (found==false)
        {
            RejectProgram(programArray[rpi]);
        }
    }
}

function RejectProgram(program) 
{		
	var programArray = UserCart.GetAttribute('recommended-programs').split(";");
	for (var rpi=0; rpi<programArray.length; rpi++) 
	{
		if (programArray[rpi] == program) 
		{
			programArray.splice(rpi,1);
		}
	}
	UserCart.SetAttribute('recommended-programs',programArray.join(";"));
}

function AddProgram(program) 
{		
	var programArray = UserCart.GetAttribute('recommended-programs').split(";");
	var blnFound=false;
	for (rpi=0; rpi<programArray.length; rpi++) 
	{
		if (programArray[rpi] == program) 
		{
			blnFound=true;
		}
	}
	if (blnFound==false)
	{
			programArray.push(program);	
	}
	UserCart.SetAttribute('recommended-programs',programArray.join(";"));
}

function ContainsProgram(strProgram,strOrgType) 
{		
	var strPrograms=GetAbsoluteValueOf("programs").replace(/,/g,';');
    var programOptions = CorrectProgramOptions().split(";");
    for (var rpi2=0; rpi2<programOptions.length; rpi2++) 
    {
        var programOptionsDetail = programOptions[rpi2].split("_");
        if ((programOptionsDetail[1]==strOrgType)&&(programOptionsDetail[0]==strProgram))
        {
            return true;
        }
    }
    return false;
}

function ContainsOrgType(strOrgType)
{
	var strPrograms=GetAbsoluteValueOf("programs").replace(/,/g,';');
    var programOptions = CorrectProgramOptions().split(";");
    for (var rpi2=0; rpi2<programOptions.length; rpi2++) 
    {
        var programOptionsDetail = programOptions[rpi2].split("_");
        if ((programOptionsDetail[1]==strOrgType))
        {
            return true;
        }
    }
    return false;
}

function SetOrgType(el)
{
    ToggleOrgType(el.value);
}

function ToggleOrgType(orgType)
{
    var qs = document.getElementsByTagName('INPUT');
    for(i=0; i<qs.length; i++)
    {
        if (qs[i].id.indexOf('Q_') > -1)
        {
            if (qs[i].id.indexOf(orgType) > 0)
                qs[i].parentNode.parentNode.parentNode.style.display = 'block';
            else
                qs[i].parentNode.parentNode.parentNode.style.display = 'none';
        }
    }
}

//Gets the priority recommendation (TODO:  Might be easier just to supply a compare() method to Array.Sort)
function GetPriority() 
{
	var priorityArray = GetAbsoluteValueOf("programs").replace(/,/g,';').split(";");
	var programArray = UserCart.GetAttribute('recommended-programs').split(";");
	for (var gp=0; gp<priorityArray.length; gp++) 
	{
		for (var gpi=0;gpi<programArray.length; gpi++) 
		{
			if (programArray[gpi] == priorityArray[gp]) 
			{
				priorityArray[gp];
				return priorityArray[gp];
			}
		}
	}
}

function SetDefaultTrainerValues()
{
    if (ContainsOrgType("CRP")==true)
    {
        if (ContainsProgram("OLP","CRP")==false)
        {
            if (ContainsProgram("OLV","CRP")==false)
            {
                if (ContainsProgram("SEL","CRP")==true)
                {
                    ExecuteProcess("Processes_Default_CRP_SEL") 
                }
            }
            else
            {
                ExecuteProcess("Processes_Default_CRP_OLV") 
            }
        }
    }
    if (ContainsOrgType("EDU")==true)
    {
        if (ContainsProgram("OLP","EDU")==false)
        {
            if (ContainsProgram("SEL","EDU")==false)
            {
                if (ContainsProgram("SC","EDU")==true)
                {
                    ExecuteProcess("Processes_Default_EDU_SC") 
                }
            }
            else
            {
                ExecuteProcess("Processes_Default_EDU_SEL") 
            }
        }
    }
    if (ContainsOrgType("GVT")==true)
    {
        if (ContainsProgram("OLP","GVT")==false)
        {
            if (ContainsProgram("OLV","GVT")==false)
            {
                if (ContainsProgram("SEL","GVT")==true)
                {
                    ExecuteProcess("Processes_Default_GVT_SEL") 
                }
            }
            else
            {
                ExecuteProcess("Processes_Default_GVT_OLV") 
            }
        }
    }
}

function AnalyseProgram(control) 
{	
    //alert(control);
    var bln_Q_1_6=false;
    var bln_Q_2_10=false;
    var backupprogramArray = UserCart.GetAttribute('recommended-programs');
    RecommendAllPrograms(); 
    RejectProgram("FPP");
    RejectProgram("EAS");
    var controlArray=control.split("_");
    if (controlArray.length==4)
    {
        var controlbase=controlArray[0];
        var controlorg=controlArray[1];
        var controlstem=controlbase+"_"+controlArray[1]+"_"+controlArray[2];
        var controlelem = GetHolderElement(control);
        var controlform = controlelem.form;
        
        var container = document.getElementById("Trainer"+controlorg);
        
        if (container) // as long as we have a container to look in
        {
            var radios = container.getElementsByTagName('input');
            for (var i=0;i<radios.length;i++)
            {
                // if it is a radio input and is not our control block and is checked
                if (radios[i].type=='radio' && radios[i].name!=controlstem && radios[i].checked==true)
                {
                    var thisradio = radios[i].name.split("_");
                    if(thisradio[0]==controlbase)
                    {
                        if(thisradio=radios[i].id=="Q_"+controlorg+"_1_6")
                        {
                            bln_Q_1_6=true;
                        }
                        if (thisradio=radios[i].id=="Q_"+controlorg+"_2_10")
                        {
                            bln_Q_2_10=true;
                        }
                        var strProcess="ExecuteProcess('Processes_"+radios[i].id.replace("Q_"+controlorg+"_","P_"+controlorg+"_")+"');";
                        eval(strProcess);
                    } 
                }
            }
            if ((bln_Q_1_6==true)&&(bln_Q_2_10==true))   
            {
                RejectProgram("SEL");
            }
            var adjustedprogramArray = UserCart.GetAttribute('recommended-programs');
            for (var i=0;i<radios.length;i++)
            {
                if (radios[i].type=='radio' && radios[i].name==controlstem && radios[i].checked!=true)
                {
                    var thisradio = radios[i].name.split("_");
                    if(thisradio[0]==controlbase)
                    {
                        var strProcess="ExecuteProcess('Processes_"+radios[i].id.replace("Q_"+controlorg+"_","P_"+controlorg+"_")+"');";
                        eval(strProcess);
                        if (thisradio=radios[i].id=="Q_"+controlorg+"_1_6")
                        {
                            if (bln_Q_2_10==true)
                            {
                                RejectProgram("SEL"); 
                            }

                        }
                        if (thisradio=radios[i].id=="Q_"+controlorg+"_2_10")
                        {
                            if (bln_Q_1_6==true)
                            {
                                RejectProgram("SEL");
                            }
                        }                            
                        if (UserCart.GetAttribute('recommended-programs')=="")
                        {
                            radios[i].disabled=true;
                        }
                	    UserCart.SetAttribute('recommended-programs',adjustedprogramArray);
                    }
                }   
            }
        }      
        
//        for (var i=0;i<controlform.length;i++)
//        {
//            if (controlform.elements[i].type=='radio')
//            {
//                if (controlform.elements[i].name!=controlstem)
//                {
//                    if (controlform.elements[i].checked==true)
//                    {
//                        var thiscontrol=controlform.elements[i].name.split("_");
//                        if (thiscontrol[0]==controlbase)
//                        {
//                            if (thiscontrol=controlform.elements[i].id=="Q_CRP_1_6")
//                            {
//                                bln_Q_1_6=true;
//                            }
//                            if (thiscontrol=controlform.elements[i].id=="Q_CRP_2_10")
//                            {
//                                bln_Q_2_10=true;
//                            }                            
//                            var strProcess="ExecuteProcess('Processes_"+controlform.elements[i].id.replace("Q_CRP_","P_CRP_")+"');";
//                            eval(strProcess);
//                        }
//                    }
//                }
//            }   
//        }        
//        if ((bln_Q_1_6==true)&&(bln_Q_2_10==true))   
//        {
//            RejectProgram("SEL");
//        }
//        var adjustedprogramArray = UserCart.GetAttribute('recommended-programs');
//        for (var i=0;i<controlform.length;i++)
//        {
//            if (controlform.elements[i].type=='radio')
//            {
//                if (controlform.elements[i].name==controlstem)
//                {
//                    if (controlform.elements[i].checked!=true)
//                    {
//                        var thiscontrol=controlform.elements[i].name.split("_");
//                        if (thiscontrol[0]==controlbase)
//                        {
//                            var strProcess="ExecuteProcess('Processes_"+controlform.elements[i].id.replace("Q_CRP_","P_CRP_")+"');";
//                            eval(strProcess);
//                            if (thiscontrol=controlform.elements[i].id=="Q_CRP_1_6")
//                            {
//                                if (bln_Q_2_10==true)
//                                {
//                                    RejectProgram("SEL");
//                                }

//                            }
//                            if (thiscontrol=controlform.elements[i].id=="Q_CRP_2_10")
//                            {
//                                if (bln_Q_1_6==true)
//                                {
//                                    RejectProgram("SEL");
//                                }
//                            }                            
//                            if (UserCart.GetAttribute('recommended-programs')=="")
//                            {
//                                controlform.elements[i].disabled=true;
//                            }
//                        	UserCart.SetAttribute('recommended-programs',adjustedprogramArray);
//                        }
//                    }
//                }
//            }   
//        }           
    }
	UserCart.SetAttribute('recommended-programs',backupprogramArray);
}


function SortProgram(strProgramOrder)
{
    var programArray = "";
    var temp=UserCart.GetAttribute('recommended-programs').replace(/,/g,';').split(";");
    var sort=strProgramOrder.split(",");
    for (var i=0;i<sort.length;i++)
    {
        for (var j=0;j<temp.length;j++)
        {
            if (sort[i]==temp[j])
            {
                programArray+=sort[i]+";";
            }
        }
    }    
    UserCart.SetAttribute('recommended-programs',programArray);
}


//'Class' used to store value/display pairs.
function KeyPair(key,value) {
	this.key = key;
	this.value = value;
}

// 'Class' to represent a process
function Process(strStatements) {
	//A process consists of many statements, which will be evaluated.
	this.Statements = strStatements.split(';'); 
}

// 'Class' to represent an action
function Action(ConditionCount, RulesetCount) {
	this.Conditions = new Array(ConditionCount);
	this.RuleSets = new Array(RulesetCount);
}

// 'Class' to represent a condition.  A condition is an expression that can be evaluated
function Condition(strCompareFrom, strFromType, strOperator, Value, strValueType) {
	this.CompareFrom = strCompareFrom;
	this.FromType = strFromType;
	this.Operator = strOperator;
	this.Value = Value;
	this.ValueType = strValueType;
}

// 'Class' to represent a rulesset.  A ruleset is a collection of rules held by an action
function RuleSet(strDisableOnPreempt, strTarget, boolCondition, intRuleCount) {
	this.DisableOnPreempt = strDisableOnPreempt //Disable this control on preeptive recommendation
	this.Target = strTarget;			//Target process
	this.Condition = boolCondition;		//true or false:  what the evalution of the rules should return if we are to execute the target
	this.Rules = new Array(intRuleCount)//
}

// 'Class to represent a rule
function Rule(strCondition, strOperator, boolOutcome) {
	this.Condition = strCondition;		//expression
	this.Operator = strOperator;		//'and', 'or', '':  opperator used to apply to the next rule in the set.
	this.Outcome = boolOutcome			//true or false
}

function replaceNullWithZero(val)
{if (val.value=="" || val.value==null || val.value=="undefined")
    val.value="0";   
}

function OLVCWO_Selected()
{
    var returnValue=false;
    if (GetValueOf('CWO')=='1')        
    {
        returnValue=true;
    }
    return(returnValue); 
}

function E6Reorder_Selected(bSwitch)
{
    var returnValue=false;
    if (GetValueOf('E6Reorder_0')=='1')        
    {
        returnValue=true;
    }
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}
function E6Renewal_Selected(bSwitch)
{
    var returnValue=false;
    if (GetValueOf('E6_R_Routes')=='0')        
    {
        returnValue=true;
    }
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function SCReorder_Selected(bSwitch)
{
    var returnValue=false;
    if (GetValueOf('SCReorder_0')=='1')        
    {
        returnValue=true;
    }
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}


function SCReorder_AdditionalDevicesNeedValue()
{
    var returnValue = false;
    if (GetValueOf('SCStudentOption_0') == '0')
    {
        returnValue = true;
    }
    else
    {
        returnValue = false;
    }
    return(returnValue);
}


function CCReorder_AdditionalDevicesNeedValue()
{
    var returnValue = false;
    if (GetValueOf('CCStudentOption_0') == '0')
    {
        returnValue = true;
    }
    else
    {
        returnValue = false;
    }
    return(returnValue);
}


function CCReorder_Selected(bSwitch)
{
    var returnValue=false;
    if (GetValueOf('CCReorder_0')=='1')        
    {
        returnValue=true;
    }
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function OLVReorder_Selected_66(bSwitch)
{
    var returnValue=false;
    // Always fail if Company wide not chosen
    if (GetValueOf('OLV_CWO')=='0')
    {
        return(returnValue);
    }
    // Otherwise see if "Existing Ageement" is checked
    if (GetValueOf('OLVExistingAgreement_0')=='1')        
    {
        returnValue=true;
    }
    // And flip the result, depending on the input switch
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function OLVReorder_Selected_67(bSwitch)
{
    var returnValue=false;
    // Always fail if Company wide not chosen
    if (GetValueOf('OLV_CWO')=='0')
    {
        return(returnValue);
    }
    // Otherwise see if "Existing Ageement" is checked
    if (GetValueOf('OLVExistingAgreement_0')=='1')        
    {
        returnValue=true;
    }
    // And flip the result, depending on the input switch
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function OLV_Office_Selected_67(bSwitch)
{
    var returnValue=false;
    // Always fail if Company wide not chosen
    if (GetValueOf('OLV_CWO')=='0')
    {
        return(returnValue);
    }
    // Otherwise see if "Microsoft Office" is checked
    if (GetValueOf('OLVProducts_67_Office')=='1')        
    {
        returnValue=true;
    }
    // And flip the result, depending on the input switch
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function OVSReorder_Selected(bSwitch)
{
    var returnValue=false;

    // See if "Existing Ageement" is checked
    if (GetValueOf('OVSExistingAgreement_0')=='1')        
    {
        returnValue=true;
    }
    // And flip the result, depending on the input switch
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function OVS_Office_Selected_67(bSwitch)
{
    var returnValue=false;

    // Otherwise see if "Microsoft Office" is checked
    if (GetValueOf('OVSProducts_67_Office')=='1')        
    {
        returnValue=true;
    }
    // And flip the result, depending on the input switch
    if (bSwitch) {
        return(returnValue); 
    } else {
        return(!returnValue); 
    }
}

function E6_Selected()
{
 var sel1 = GetHolderElement("quickprograms_selector");
 var sel2 = GetHolderElement("quickprogramlist_E6");
 var returnValue=false;
 if (sel1!=null && sel2!=null)
  {  if (sel1.checked&& sel2.checked) 
        returnValue=true;
  }
 
 
 return(returnValue); 
}


function OVS_Selected()
{
 var sel1 = GetHolderElement("quickprograms_selector");
 var sel2 = GetHolderElement("quickprogramlist_OVS");
 var returnValue=false;
 if (sel1!=null && sel2!=null)
  {  if (sel1.checked&& sel2.checked) 
        returnValue=true;
  }
  
  
 
 return(returnValue); 
}

function OLV_Selected()
{ 
    var sel1 = GetHolderElement("quickprograms_selector");
    var sel2 = GetHolderElement("quickprogramlist_OLV");
    var returnValue=false;
    if (sel1!=null && sel2!=null)
    {  
        if (sel1.checked&& sel2.checked) 
        {
            returnValue=true;
        }
    }
    return(returnValue); 
}

function HideLanguages_Selected()
{
	var strBool=GetAbsoluteValueOf("hideLanguages");
	if (strBool == "1")
	{
	    return true;
	}
	return false;
}

function GetRecommendedProgram()
{
	var programArray = UserCart.GetAttribute('recommended-programs').split(";");
	if (programArray[0]=="")
	{
	    return false;
	}
    return true;
}

function SetProgram() 
{ 
	var programArray = UserCart.GetAttribute('recommended-programs').split(";");
	var prog = programArray[0];

	UserCart.SetAttribute('selected-program',prog);
	if (GetHolderElement('divSelectedProgram')!=null)
	{
    	//document.getElementById('divSelectedProgram').innerHTML = GetFullProgramName(prog) + ' (' + UserCart.GetAttribute('recommended-programs') + ')';
    	GetHolderElement('divSelectedProgram').innerHTML = GetFullProgramName(prog);
    }
}

function GetFullSolutionName(code)
{
	var ret="";
	
	if (code=="1") { ret="<label>" + LOC_UnifiedCommunicationsCollaboration + "</label>"; }
	if (code=="2") { ret="<label>" + LOC_EnterpriseContentManagement + "</label>"; }
	if (code=="3") { ret="<label>" + LOC_BusinessIntelligence + "</label>";	}
	
    if (code=="101") { ret="<label>" + LOC_SoftwareDistributionandPatchManagement + "</label>";	}
	if (code=="102") { ret="<label>" + LOC_BranchOfficeInfrastructure + "</label>"; }
	if (code=="103") { ret="<label>" + LOC_ServerConsolidation + "</label>"; }
	if (code=="104") { ret="<label>" + LOC_MessagingServices + "</label>";	}
	if (code=="105") { ret="<label>" + LOC_RemoteAccessServices + "</label>";	}
	if (code=="106") { ret="<label>" + LOC_CollaborationServices + "</label>";	}
	if (code=="107") { ret="<label>" + LOC_CustomerService + "</label>"; }		
	if (code=="108") { ret="<label>" + LOC_AutomatedSales + "</label>"; }
	if (code=="109") { ret="<label>" + LOC_SystemsManagementServerMonitoring + "</label>"; }
	if (code=="110") { ret="<label>" + LOC_MOM2005SLAScorecardforExchange + "</label>"; }		
	return ret;
}

function GetFullProgramName(program)
{
	var ret="";
	if (program=="E6")
	{
		ret="<a target='_new' href='"+GLO_E6Link+"'>"+LOC_ENTTitle+"</a>";
	}
	else if (program=="EAS")
	{
		ret = LOC_ENTAgreement;
	}
	else if (program=="SEL")
	{
		ret="<a target='_new' href='"+GLO_SELLink+"'>"+LOC_SELTitle+"</a>";
	}
	//TODO: PJM check this
	else if (program=="SLP")
	{
		ret="<a target='_new' href='"+GLO_SLPLink+"'>"+LOC_SLPTitle+"</a>";
	}
	else if (program=="OLVCWO")
	{
		ret="<a target='_new' href='"+GLO_OLVLink+"'>"+LOC_OLVCWOTitle+"</a>";
	}
	else if (program=="OLV")
	{
		ret="<a target='_new' href='"+GLO_OLVLink+"'>"+LOC_OLVTitle+"</a>";
	}
	else if (program=="OVS")
	{
		ret="<a target='_new' href='"+GLO_OVSLink+"'>"+LOC_OVSTitle+"</a>";
	}
	else if (program=="OLP")
	{
		ret="<a target='_new' href='"+GLO_OLPLink+"'>"+LOC_OLPTitle+"</a>";
	}
	else if (program=="SC")
	{
		ret="<a target='_new' href='"+GLO_SCLink+"'>"+LOC_SCTitle+"</a>";
	}
	else if (program=="CC")
	{
		ret="<a target='_new' href='"+GLO_CCLink+"'>"+LOC_CCTitle+"</a>";
	}
	else if (program=="FPP")
	{
		ret = LOC_FullPackage;
	}
	return ret;	
}

//Function steps through the supplied action or all the actions if no actionid is supplied. 
function Walk() 
{
    //PJW07
    fastwalk();
    /*
	//Walk all actions
	for (var actionIndex=0; actionIndex<Actions.length; actionIndex++) 
	{
	    if (Actions[actionIndex]!=null)
	    {
    		Step (Actions[actionIndex].value);
    	}
	}
	*/	
}

function WalkSpecificAction(actionid) 
{
    //PJW07
	eval(actionid +'();');
    /*
    var action = Actions.ValueOf(actionid);
    
    //#Speedup
    if (action == null)
	{
	    eval('actions_' + actionid +'()');
	    action = Actions.ValueOf(actionid);
	 }
	 
    if (action != null)
            Step (action);
    */    
}

// Eval each ruleset in the action and execute the process if required
function Step(Action) 
{
	//For each ruleset in the action
	for (var rulesetIndex=0; rulesetIndex<Action.RuleSets.length; rulesetIndex++) 
	{ 
		auxStep(Action,rulesetIndex);
	}
}

function auxStep(Action,rulesetIndex)
{
	var ruleset = Action.RuleSets[rulesetIndex] //.value
	if (EvalRuleSet(Action.Conditions, ruleset)) 
	{
		var StepProcess = Processes.ValueOf(ruleset.Target);
		
	    //#Speedup
	 	if (StepProcess == null)
		{ 
		    eval('process_' + ruleset.Target +'()');
	        StepProcess = Processes.ValueOf(ruleset.Target);
        }
	    if (StepProcess != null)   
		{
		    for (var pi=0; pi<StepProcess.Statements.length; pi++) { //For each statement in the process
			    eval(StepProcess.Statements[pi]);
		    }
		}
	}
}

//Function evaluates a rule set of conditions and returns true or false
function EvalRuleSet(arrConditions, arrRuleSet) 
{
	var condition, boolRuleOutcome, previousRuleOperator;
	var quickeval=true;
	for (var rs=0; rs<arrRuleSet.Rules.length; rs++) 
	{   
    	if (arrRuleSet.Rules[rs].Operator=="or")
    	{
    	    quickeval=false;
    	}
    }
	for (var rs=0; rs<arrRuleSet.Rules.length; rs++) 
	{   
	    //For each rule
		//Grab the condition
		condition = arrConditions.ValueOf(arrRuleSet.Rules[rs].Condition);
        if (null == condition)
            alert("Null condition: " + arrRuleSet.Rules[rs].Condition);
        
		//Eval the actual rule
		switch (previousRuleOperator) {
			case "or":
				boolRuleOutcome = ((boolRuleOutcome) || (eval(PreEval(condition.CompareFrom, condition.FromType) + ' ' + condition.Operator + ' ' + PreEval(condition.Value,condition.ValueType)) == arrRuleSet.Rules[rs].Outcome ));
				break
			case "and":
				boolRuleOutcome = ((boolRuleOutcome) && (eval(PreEval(condition.CompareFrom, condition.FromType) + ' ' + condition.Operator + ' ' + PreEval(condition.Value,condition.ValueType)) == arrRuleSet.Rules[rs].Outcome ));
				break
			default:
				boolRuleOutcome = (eval(PreEval(condition.CompareFrom, condition.FromType) + ' ' + condition.Operator + ' ' + PreEval(condition.Value,condition.ValueType)) == arrRuleSet.Rules[rs].Outcome );
				break
		}
		previousRuleOperator = arrRuleSet.Rules[rs].Operator;
		if ((quickeval)&&(!boolRuleOutcome))
		{
		    return ((arrRuleSet.Condition) == (boolRuleOutcome));
		}
	}
	//Compare the ruleset condition with the rules outcome
	return ((arrRuleSet.Condition) == (boolRuleOutcome));
}


//Function eval's expressions, dereferences control values, checks for numeric comparison or preps strings
function PreEval(val, type) {
	var ret;
	switch (type)	{
		case "expression":
			ret = eval(val);
			if (ret!=null)
			{
				if (ret=="Infinity")
				{
					ret=0;
				}
				if (isNaN(ret))
				{
					ret = "'"+ret+"'";
				}
			}
			break
		case "control":
			ret = GetValueOf(val);
			if ((isNaN(ret)) && (!ret.startsWith("'")))
			    ret = "'" + ret + "'";
			break
		case "string":
			if (!val.startsWith("'"))
				ret = "'" + val + "'";
			break
		case "number":
				ret = val;
			break
		default:
			ret = GetValueOf(val);
			break
	}
	if (ret==null)
	{
		ret="''";
	}
	return ret;
}

function ExecuteProcess(ProcessId) 
{
//PJW07
    eval(ProcessId +'()');
/*
	var process = Processes.ValueOf(ProcessId);
	
	//#Speedup
	if (process == null)
	{
	    //eval('process_' + ProcessId +'()');
	    eval(ProcessId +'()');
	    process = Processes.ValueOf(ProcessId);
	 }
	    
    if (process != null)    
    {	
	    for (var processIndex=0; processIndex<process.Statements.length; processIndex++) { //For each statement in the process
		    {
		        eval(process.Statements[processIndex]);
		    }
	    }
	}
	*/
}

function GetQuestionStem(strQuestion)
{
	var breakpos=strQuestion.indexOf("_");
	if (breakpos!=-1)
	{
		return strQuestion.substring(0,breakpos);
	}
	return strQuestion;
}

//If the controls associated programs intersect with the current recommendations, enable the control.
function PreemptAction(control, programs) 
{
	var currentRecommendations = UserCart.GetAttribute('recommended-programs');	
	if(currentRecommendations.length != 0)
	{       
	    var associatedArray = programs.split(",");
	    toggleEnabled(control, false);
	    for (var pa=0; pa<associatedArray.length; pa++) 
	    {
	        if (currentRecommendations.indexOf(associatedArray[pa]) !=-1 )
	        {
	            toggleEnabled(control, true);    
	            break;
	        }
	    }
	}
}

function DoOnClick(id)
{    
    SetValueOf(id,"on"); 
}


//Mark Johnson - 7 April 2006 - Added to return add a value to 
//                  the control based on the expression passed in
function SetValueFromExpression(id, expression)
{
    SetValueOf(id, PreEval(expression, "expression"))
}


//Function sets the value of the given element
function SetValueOf(id,value) 
{
	var element = GetHolderElement(id)
	
	//this might be a list, so test that too
	if (element == null) 
	{
		element = GetHolderElement(id + '_0');
	
	}
		
	if (element != null) {
	        
		switch (element.type){
		    case "span" :
		        element.innerHTML =value;
		        break;
			case "text" : case "textarea" : case "file" : case "password" : case "hidden" :
				element.value = value;
				break;
			case "select-one" : case "select-multiple" :
			    var bfound=false;
				for (var svi=0,iOptions=element.options.length; svi<iOptions; svi++)
				{
    				if (element.options[svi].value == value)
	    			{
		    			element.options[svi].selected = true;
		    			bfound=true;
			    		break;
				    }
		        }
		        if (!bfound)
		        {
    				for (var svi=0,iOptions=element.options.length; svi<iOptions; svi++)
	    			{
    	    			if ((element.options[svi].value != "ZZZ")&&(element.options[svi].value != ""))
	    	    		{
		    	    		element.options[svi].selected = true;
			    	    	break;
    				    }
	    	        }
	    	    }
				break;
			case "radio" :  
				//Check all the other radio buttons associated with this one				
				var svi=0;
				while (element != null)
				{
					if (element.value == value) 
					{
						element.checked = true;					
					    break;
					}
					element = GetHolderElement(id + '_' + svi);
					svi++;
				}
				element = GetHolderElement(value);
				if (element != null)
				{
					element.checked = true;
    				break;
				}	
				element = GetHolderElement(id+"_"+value);
				if (element != null)
				{
					element.checked = true;
    				break;
				}
				element=GetHolderElement(id);
                var controlform = element.form;
                for (var i=0;i<controlform.length;i++)
                {
                    if (controlform.elements[i].type=='radio')
                    {
                        if (controlform.elements[i].name!=id)
                        {
                            if (controlform.elements[i].value == value) 
					        {
		            			controlform.elements[i].checked = true;
            		    		break;
					        }
                        }
                    }                        
				}
				break;
			case "checkbox" :
				if (element.disabled==false)
				{
				    if (value == true)
				    {
				        element.checked = true;
				    }
					else if (value == false)
				    {
				        element.checked = false;
				    }
					else if (element.value == value)
					{
						element.checked = true;
    					//element.onclick();
					}
					else if (value=='off')
					{
						element.checked = false;
    					//element.onclick();
					}

				}
				break;
			default :				    
			    if (id.substring(0,4)=="SPAN")
     			    element.innerHTML =value;
                    break;
		}
	}
}

function removeQuotes(value)
{
    if ((value!=null) && (value.indexOf!=null))
    {
        while (value.indexOf("'")!=-1)
        {
            value=value.replace("'","");
        }
    }
    return value;
}

function GetAbsoluteValueOf(id)
{
    if (id != null)
        return removeQuotes(GetValueOf(id));
}

//Method checks that we have a visible route selected
function SelectFirstVisibleRoute()
{
    /*
    var invalidSelection = false;
    var routes = new Array('group_G1','group_G7','group_G8','group_G9','group_G10');
    var options = new Array('trainer_selector','pf_trainer_selector','solution_trainer_selector','quickprograms_selector','bpio_trainer_selector');

    //Do we have an invalid group selection?
    for (ix=0; ix<routes.length; ix++) 
	{
	    if ((!isDivVisible(routes[ix])) && (IsRadioButtonChecked(options[ix])))
        {
            invalidSelection = true;
            break;
        }
	}
	
	//Is so, select the first visible route.
	if (invalidSelection)
    {
	    for (ix=0; ix<routes.length; ix++) 
	    {
	        if (isDivVisible(routes[ix]))
            {
                CheckRadioButton(options[ix]);
                break;
            }
	    }
    }
    */
}

//Is a radio buttons .checked property set to true?
function IsRadioButtonChecked(id)
{
	var element = GetHolderElement(id);
	if (null != element)
	{
	    if (element.type == "radio")
	    {
	        return element.checked;
	    }
	}
}
//Set a radio buttons .checked property to true
function CheckRadioButton(id)
{
	var element = GetHolderElement(id);
	if (null != element)
	{
	    if (element.type == "radio")
	    {
	        element.checked = true;
	        element.onclick();
	    }
	}
}

function GetHolderElement(id)
/*
Function to find element ID in the document with following search sequence :
1. Check ID in document
2. Check ID in Body placeholder
3. Check ID in Pop placeholder
4. Check ID in Contex place holder, e.g. user control
*/
{
    if ((id != null) && (id != "") && (id != "0"))
    {
        var element;
         var counter=1;
         var found=false;
         var ori_id=id;
         
         var prefixTag = new Array() 
         prefixTag[1] =PageBodyTag;//body holder
         prefixTag[2] =PagePopTag;//pop holder
         prefixTag[3] ="ctl00$";//master page
         prefixTag[4] =PageContextTag;//context tag
         prefixTag[5] = "ctl00$MainContent$ProductReportSummary1$";  // ProductReportSummary
         prefixTag[6] = "ctl00$MainContent$ProductConfiguration1$";  // ProductConfiguration
         prefixTag[7] = "ctl00$MainContent$ProductBenefitSummary1$";  // Summary Benefits
         prefixTag[8] = "ctl00$MainContent$ProductList1$";  // Product List
         

         
	        while (!found && counter<=9)
	        {
	            element = document.getElementById(id)
	            //this might be a list
	            if (element == null) 
	            {
		            element = document.getElementById(id + '_0');
	            }
	            // see if it's a div with no name
	            if (element == null) 
	            {
	                var divid=""+id+""    
		            element = document.getElementById(divid.replace(/[$]/g,'_'));
	            }	            
	            if (element !=null)
	            {
	                found=true;
	            }
                else
                {
                    id= prefixTag[counter]+ori_id;     
                }        
                counter++;	
	        }	
       
	        
	        return(element);
	}
}

function GetHolderElementByName(name)
/*
Function to find element ID in the document with following search sequence :
1. Check ID in document
2. Check ID in Body placeholder
3. Check ID in Pop placeholder
4. Check ID in Contex place holder, e.g. user control
*/
{
    var element;
    var counter=1;
    var found=false;
    var ori_id=name;
    var prefixTag = new Array() 
    prefixTag[1] = PageBodyTag;//body holder
    prefixTag[2] =PagePopTag;//pop holder
    prefixTag[3] ="ctl00$";//master page
    prefixTag[4] =PageContextTag;//context tag
    prefixTag[5] = "ctl00$MainContent$ProductReportSummary1$";  // ProductReportSummary
    prefixTag[6] = "ctl00$MainContent$ProductConfiguration1$";  // ProductConfiguration
    prefixTag[7] = "ctl00$MainContent$ProductBenefitSummary1$";  // Summary Benefits
    prefixTag[8] = "ctl00$MainContent$ProductList1$";  // Product List

    while (!found && counter<=9)
	{
	    element = document.getElementsByName(name)
	    if (element.length==0)
	    {
	        element=null;
	    }
	    //this might be a list
	    if (element == null)
	    {
		    element = document.getElementsByName(name + '_0');
	        if (element.length==0)
    	    {
	            element=null;
    	    }
	    }

	    if (element !=null)
	    {
	        found=true;
        }	       
        else
        {
            name= prefixTag[counter]+ori_id;     
        }
        counter++;	
	}
	return(element);
}



//Return the value of a form field
function GetValueOf(id)
{
    var element = null;
	//var element = GetHolderElement(id)
	if ((id != "") && (id != "0"))
	    element=GetHolderElement(id);
	
	// if not a list then just return the value
	if (element == null) 
	{
	    /*
	    if (id.indexOf("_")!=-1)
	    {
            return "'"+id+"'";
        }
        else
        {
            return id;
        } 
        */  
        return id;
	}	
	var returnValue=null;
	switch (element.type){
		case "text" : case "textarea" : case "file" : case "password" : case "hidden" :	
            if (element.value!="")
            {
			    if (isNaN(element.value))
		    	{
	    			returnValue="'"+element.value+"'";
    			}
			    else
		    	{
	    			returnValue=element.value;
    			}
            }
            else
            {
                returnValue=0;
            }
			break;
		case "select-one" :
			if(element.selectedIndex>=0)
				returnValue=element.options[element.selectedIndex].value;
			break;
		case "select-multiple" :
			for(var i=0,iOptions=element.options.length; i<iOptions; i++)
				if(element.options[i].selected && trim(element.options[i].value.toString())){
					returnValue=true;
					break;
				}
			break;
		case "radio" : 
				//Check all the other radio buttons associated with this one
			
				var gvi=0;
				while (element != null)
				{
					if (element.checked) 
					{
						returnValue=element.value;
					}
					
            		element = GetHolderElementByName(id)[gvi];            		
            		gvi++;
				}				
				break;
		case "checkbox" :
			returnValue=element.checked;
			break;
		default:
			returnValue = null;
	}
	return returnValue;
}
	
 //For the given form (f), serialise all elements and their current values.  Skips asp.net control elements.
 function serialise(f) {
    var s = '';
    var form = document.forms[f];
    if (form != 'undefinded') {    
        for (var i=0;i<form.length;i++) {
            if ((form[i].id.substring(0,2) != '__') )   { //drop all the asp.net __eventname etc fields
              switch (form[i].type) {
		            case "text" : case "textarea" : case "file" : case "password" : case "hidden" :	
                        s += form[i].id + '=' + form[i].value + ';';
			            break;
		            case "select-one" : 
			            if(form[i].selectedIndex>=0)
			                s += form[i].id + '=' + form[i].options[form[i].selectedIndex].value + ';';
			            else
			                s += form[i].id + '=;';
			            break;
			        case "radio" :
		                if (form[i].checked)
			                s += form[i].id + '=true;';
			             else
			                s += form[i].id + '=false;';
			            break;
		            case "select-multiple" :
		                    s += form[i].id + '=';
			                for(var k=0;k<form[i].options.length; k++) {
				             if(form[i].options[k].selected)
					            s += form[i].options[k].value + ',';
				            }
				            s += ';';
			            break;
		            case "checkbox" :
			             if (form[i].checked)
			                s += form[i].id + '=true;';
			             else
			                s += form[i].id + '=false;';
			            break;
                }
            }
        }
    }
    return s;
 }	

//Loop through ALL the divs in the parent div, setting the supplied div to visible and the rest to hidden
function setActiveDiv(parent,div) {
	if ((GetHolderElement(parent) != null) && (GetHolderElement(div) != null ))
	{
		var element = GetHolderElement(parent);
		for(var i=0;i<element.childNodes.length;i++)
		{	
			if (element.childNodes[i].id == div)
				element.childNodes[i].style.display='';
			else {
				if (element.childNodes[i].style) {
					element.childNodes[i].style.display='none';
				}
			}
		}
	}		
}

function checkboxVisibility(selector,div)
{
	if (selector.checked)	{
		GetHolderElement(div).style.display = '';
	}
	else  {
		GetHolderElement(div).style.display = 'none';
	}
}

//Toggle the visibility of the given div on / off
function toggleVisibility(div) {
    var element = GetHolderElement(div);
    if (element != null)
    {
	    if ((element.style.display == null) || (element.style.display == ''))
		    element.style.display = 'none';
	    else
		    element.style.display = '';
    }
}

//Is an div visible?
function isDivVisible(div)
{
    if(GetHolderElement(div) != null)
        return !(GetHolderElement(div).style.display == 'none');
}

//hide the given 
function hideDiv(div) 
{
    if (GetHolderElement(div) == null)
        return;
	else ((GetHolderElement(div).style.display == null) || (GetHolderElement(div).style.display == ''))
		GetHolderElement(div).style.display = 'none';
}

// hide the given table row
function hideTableRow(tableRow)
{   
    if(GetHolderElement(tableRow) != null)
        GetHolderElement(tableRow).style.display='none';
}

//show the given div 
function showDiv(div) 
{
    if (GetHolderElement(div) == null)
    {
        return;
    }
	else ((GetHolderElement(div).style.display == null) || (GetHolderElement(div).style.display == 'none'))
	{
		GetHolderElement(div).style.display = 'block';
	}
}

function showDivXY(div,minX,minY) {
var div=GetHolderElement(div);
if (div!=null)
{
 if (tempX<minX)
    div.style.left = minX  ;
 else
    div.style.left = tempX;

 if (tempY<minY)
    div.style.top = minY;
 else
    div.style.top = tempY;
    
 if ((div.style.display == null) || (div.style.display == 'none'))
    {
     div.style.display = '';
    }
 }  
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

/* EAW Functionality */

// EAW Function
function EAWShowDiv(div)
{
 showDivXY(div,450,0);  
 EAWCurrent=div;
}

function EAWToggle(EAWID,productSetID)
{

var imgID= EAWID +'_img';
var element = GetHolderElement(imgID)
if (Right(element.src,16) == "btn_contract.gif")
  {hideDiv(EAWID);
   element.src = "images/btn_expand.gif";
  }
else
  {var prefix='EAW_'+productSetID;
   Page.SetItem('EAW_R_'+productSetID,'');
   WalkSpecificAction(prefix+'_A1');
   EAWUseRecommendation(productSetID);
   EAWShowDiv(EAWID);
   element.src = "images/btn_contract.gif";
   
  }
}

function EAWUseRecommendation(productSetID)
{   
    var element = GetHolderElement("EAWRecommendation");
    var strProductSet= productSetID+';';
      
    if (element.value.indexOf(strProductSet)<0)
        {element.value = element.value+ strProductSet;        
        } 
}

function EAWClick(pfamcode,pfamname)
{
    var url="ReportHandler.ashx?reporttype=EAW&data="+encodeQueryString(pfamcode)+"*"+encodeQueryString(pfamname);
    ClientPost(url);
}

// Reporting reseller link selection.
function resellerClick()
{
    var url="ReportHandler.ashx?reporttype=RES&data=null";
    ClientPost(url);
}

/* End of EAW */
/* Recommendation Functionality */
//Download

function remove(s, t) {
  /*
  **  Remove all occurrences of a token in a string
  **    s  string to be processed
  **    t  token to be removed
  **  returns new string
  */
  i = s.indexOf(t);
  r = "";
  if (i == -1) return s;
  r += s.substring(0,i) + remove(s.substring(i + t.length), t);
  return r;
  }

function addClick(e,associationID,downloadText)
{
    var value="0";
    if (e.checked==true)
    {
        value="1";
    }
    var url="ReportHandler.ashx?reporttype=ADD&data="+encodeQueryString(downloadText)+"*"+associationID+"*"+value;
    ClientPost(url);
}

function preClick(e,associationID,downloadText)
{
    var value="0";
    if (e.checked==true)
    {
        value="1";
    }
    var url="ReportHandler.ashx?reporttype=PRE&data="+encodeQueryString(downloadText)+"*"+associationID+"*"+value;
    ClientPost(url);
}
  
function adddownloadClick(associationID,downloadText)
{
    var url="ReportHandler.ashx?reporttype=ADD2&data="+encodeQueryString(downloadText)+"*"+associationID;
    ClientPost(url);
}

function predownloadClick(associationID,downloadText)
{
    var url="ReportHandler.ashx?reporttype=PRE2&data="+encodeQueryString(downloadText)+"*"+associationID;
    ClientPost(url);
}

function encodeQueryString(queryStr) 
{
     var encodedString = escape(queryStr);
     return(encodedString);
}



function addOnDownload(associationID,downloadText)
{ var element = GetHolderElement("AddOnDownload");
  var element2 =GetHolderElement("AddOnDownloadUnSelected");
  var strAssociation= associationID+':'+downloadText+',';

  if (element.value.indexOf(strAssociation)<0)
        {element.value += strAssociation;        
        }         
  element2.value=remove(element2.value,strAssociation);
  
  return(element.value);     
}

function addRecommendedProduct(associationID,downloadText,recType)
{
 if (recType=="addon")
 {
 var element = GetHolderElement("AddOnDownloadUnSelected");
 var strAssociation= associationID+':'+downloadText+','; 
 element.value+=strAssociation;
 }
}

/* End of Recommendation */

//Enable / disable a control
function toggleEnabled(id,isEnabled) 
{
    var element = GetHolderElementByName(id)
    if (element!=null)
    {
        if (element.length != null)
	    {
	        var gvi=0;
	        var element = GetHolderElementByName(id);
	        for (var gvi=0; gvi < element.length; gvi++)
	        {
			    element[gvi].disabled = !isEnabled;
	        }	
	    }
	    else
	    {
	        if (GetHolderElement(id) != null)
	        {
		        GetHolderElement(id).disabled = !isEnabled;
	        }
	    }
	}
    else
    {
        if (GetHolderElement(id) != null)
        {
	        GetHolderElement(id).disabled = !isEnabled;
        }
    }
}

//PJW performance

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, String.Empty);
}

String.prototype.startsWith = function(prefix) {
	return new RegExp("^" + prefix).test(this);
}

String.prototype.endsWith = function(suffix) {
	return new RegExp(suffix + "$").test(this);
}

function checkRequired(id)
{
	if (id!="")
	{
        var controlid=getParameterValue(id,"controltovalidate");
    	if (controlid!="")
	    {
            var control2=GetHolderElement(controlid);
            if (control2!=null)
            {
                // We have a controltovalidate.
                // If we are showing a modal popup and the controltovalidate is on that popup
                // continue the validation, otherwise return false to indicate the validation is not required
                var inPopup = control2.getAttribute('inPopup');
                if (isDivVisible && inPopup != 'true') {
                    return false; // Validation not required
                }
                // Continue the validation by checking to see if controltovalidate is enabled
		        if (control2.disabled==true)
		        {
            	    return false; // Validation not required
    		    }
            }
        }
		var control1=GetHolderElement(id);
		if (control1!=null)
		{
			var attribute=control1.getAttribute('requiredid');
			if (attribute!=null)
			{
				if (attribute!="")
				{
				    if (attribute.indexOf("(")>0 ) // function check
				    {
				        var result=eval(attribute);	
				        return(result);
				    }
				    else // input check
    			    {
				        var control2=GetHolderElement(attribute);
    			        if (control2!=null)
				        {
					        if (!control2.checked)
					        {
						        return false;
					        }				
				        }
				        else
				        {
					        return false;
				        }
					}
				}
			}
		}
	}
	return true;
}

function getParameter(id)
{
    return (getParameterValue(id,'parameter'));
    /*
    var returnattribute="";
	if (id!="")
	{
		var control1=GetHolderElement(id);
		if (control1!=null)
		{
			var attribute=control1.getAttribute('parameter');
			if (attribute!=null)
			{
			    returnattribute=GetValueOf(attribute);
			}
		}
	}
	return returnattribute;
	*/
}

function getParameterValue(id,parameter)
{
    var returnattribute="";
	if (id!="")
	{
		var control1=GetHolderElement(id);
		if (control1!=null)
		{
			var attribute=control1.getAttribute(parameter);
			if (attribute!=null)
			{
			    returnattribute=attribute;
			}
		}
	}
	return returnattribute;
}

/*function IntegerClientValidate(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	arguments.IsValid=false;
	var temp=arguments.Value;
	if (isInteger(temp))
	{
		arguments.IsValid=true;
	}
}*/

function IntegerClientValidate(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	
	// check null 
    	
	var element=GetHolderElement(source.element);
    if (element==null || element.value=="")
     {  arguments.IsValid=false;
        return;
     }
     
	arguments.IsValid=false;
	var temp=element.value;
	if (isInteger(temp))
	{
		arguments.IsValid=true;
	}
}

function CustomMinCheck(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	var nMin=5;
	var countrycode=UserCart.GetAttribute('country');
	if (countrycode=='JP')
	{
    	nMin=3;
	}
	var validatetext=LOC_CUSTOM_MIN;
	validatetext=validatetext.replace("<value/>",nMin);
	var errormessage=GetHolderElement(source.id);
	if (errormessage!=null)
	{
	    errormessage.innerHTML="<p class=errorMessage>"+validatetext+"</p>";
	}
	
	arguments.IsValid=false;
	var temp=arguments.Value;
	if (isNumeric(temp))
	{
	    if ((temp-0)>=nMin)
	    {
    		arguments.IsValid=true;
    	}
	}
}


function MinClientValidate(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	var nMin=(getParameter(source.id)-0);
	arguments.IsValid=false;
	var temp=arguments.Value;
	if (isNumeric(temp))
	{
	    if ((temp-0)>=nMin)
	    {
    		arguments.IsValid=true;
    	}
	}
}

function CompareClientValidate(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	
	var operator;
	switch(source.Operator)
	{case "LessThanEqual" :
	    operator="<=";
	    break;
	 case "GreaterThanEqual" :
	    operator=">=";
	    break;
	 case "Equal" :
	    operator="==";
	    break;
	 case "LessThan" :
	    operator="<";
	    break;
	 case "GreaterThan" :
	    operator=">";
	    break;
     case "NotEqual" :
	    operator="!=";
	    break;
	}

	var compareFrom;
	var compareTo;
	var elementFrom=GetHolderElement(source.controltovalidate);
	var elementTo=GetHolderElement(source.ControlToCompare);
    if (elementFrom==null || elementTo==null || isNaN(elementFrom.value) ||isNaN(elementTo.value) )
     {  
        arguments.IsValid=false;
        return;
     }     
    compareFrom=elementFrom.value;
    compareTo=elementTo.value;    
	var compareString=compareFrom +" " + operator+" " +compareTo ;	
    arguments.IsValid=eval(compareString);
}

function MaxClientValidate(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	var nMax=(getParameter(source.id)-0);
	arguments.IsValid=false;
	var temp=arguments.Value;
	if (isNumeric(temp))
	{
	    if ((temp-0)<=nMax)
	    {
    		arguments.IsValid=true;
    	}
	}
}

function OLVMagicQuestion_Show67 () 
{
    // Function to examine the components that effect the OLV Magic Question and return TRUE if v6.7 should display else FALSE
    if (
        (GetValueOf('OLVExistingAgreement') == "1" &&   // Do you have an Existing Agreement = Yes
         GetValueOf('OLV_CWO') == "1" &&                // and Company Wide = Yes
         GetValueOf('OLVMagicQuestion02') == "BYO")     // and Platform Type = Build Your Own
         ||                                             // OR
         GetValueOf('OLVExistingAgreement') == "1" &&   // Do you have an Existing Agreement = Yes
         GetValueOf('OLV_CWO') == "0"                   // and Company Wide = No
         ||                                             // OR
         GetValueOf('OLVExistingAgreement') == "0"      // Do you have an Existing Agreement = No
       )
       {
        return true;
       }

       return false;
} 

function OVSMagicQuestion_Show67 () 
{
    // Function to examine the components of the OVS Magic Question and return TRUE if v6.7 should display else FALSE
    if (
        (GetValueOf('OVSExistingAgreement') == "1" &&   // Do you have an Existing Agreement = Yes
         GetValueOf('OVSMagicQuestion02') == "BYO")     // and Platform Type = Build Your Own
         ||                                             // OR
         GetValueOf('OVSExistingAgreement') == "0"      // Do you have an Existing Agreement = No
       )
       {
        return true;
       }

       return false;
} 

function OLV_Validator_66(source, arguments)
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if CWO is selected AND showing v6.6
    if (GetValueOf('OLV_CWO')=='1' && UserCart.GetAttribute('OLVshowing66')=='true')
    {
        // make sure something is checked ProProducts
        if ((GetValueOf('OLVPlatform_66')=='1')||GetValueOf('OLVProducts_66_Office') || GetValueOf('OLVProducts_66_CAL') ||(GetValueOf('OLVWindowsVista_66_WindowsVista')&&GetValueOf('OLVProducts_66_Windows')))               
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;

}

function OLV_Validator_67(source, arguments) // Validator to check that some component products have been chosen
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if CWO is selected AND showing v6.7
    if (GetValueOf('OLV_CWO')=='1' && UserCart.GetAttribute('OLVshowing66')=='false')
    {
        // make sure something is checked in the v6.7 component section
        if (GetValueOf('OLVProducts_67_Office') || GetValueOf('OLVProducts_67_CAL') || GetValueOf('OLVProducts_67_Windows'))
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;

}

function OLV_OfficeValidator_67(source, arguments) // Validator to check that the quantities of Office products match the desktops specified
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if CWO is selected AND showing v6.7
    if (GetValueOf('OLV_CWO')=='1' && UserCart.GetAttribute('OLVshowing66')=='false')
    {
        // if Office Products is Checked
        if (GetValueOf('OLVProducts_67_Office'))
        {
            // Work out the maximum quantity allowed
            var MaxQ = 0;
            var oQ = 0;
            var aQ = 0;
            if (GetValueOf('OLVExistingAgreement')) {
                // For an existing agreement two values can be entered - original desktops and additional desktops
                oQ = GetValueOf('InitialOLVDesktopCount_67') - 0;
                aQ = GetValueOf('AdditionalOLVDesktopCount_67') - 0;
                // if they are "Adding these Enterprise Products to their existing Company Wide Agreement" then Max = Original + Additional
                if (GetValueOf('OLVAddToExisting_Office_67_text'))
                {
                    MaxQ = oQ + aQ;
                }
                else // Max is just the Additional Desktops
                {
                    MaxQ = aQ;
                }
            }
            else
            {
                // For a new order only a single value can be entered - the number of desktops
                oQ = GetValueOf('OLVDesktopCount_67') - 0;
                MaxQ = oQ;
            }
            // Get the values of the Office component quantities
            var oppQ = 0;
            var osbQ = 0;
            var oeeQ = 0;
            oppQ = GetValueOf('OLVOfficeProducts_67_Office_ProPlus') - 0;
            osbQ = GetValueOf('OLVOfficeProducts_67_Office_SmallBusiness') - 0;
            oeeQ = GetValueOf('OLVOfficeProducts_67_Office_Enterprise') - 0;
            // Having assembled all the info, take the final decision
            if (0 < (oppQ + osbQ + oeeQ) && (oppQ + osbQ + oeeQ) == MaxQ)
            {
                ret = true;
            }
        }
        else
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;

}

function OLV_CALValidator_67(source, arguments)
{
    ret = false;
    if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if CWO is selected AND showing v6.7
    if (GetValueOf('OLV_CWO')=='1' && UserCart.GetAttribute('OLVshowing66')=='false')
    {
        // if Office Products is Checked
        if (GetValueOf('OLVProducts_67_CAL'))
        {
            var blnSBSelected=GetValueOf('OLVCALSuiteSelection_67')=='sb';
            var blnEBSelected=GetValueOf('OLVCALSuiteSelection_67')=='eb';
            // Work out the quantity allowed
            var MaxQ = 0;
            var oQ = 0;
            var aQ = 0;
            if (GetValueOf('OLVExistingAgreement')) {
                // For an existing agreement two values can be entered - original desktops and additional desktops
                oQ = GetValueOf('InitialOLVDesktopCount_67') - 0;
                aQ = GetValueOf('AdditionalOLVDesktopCount_67') - 0;
                // if they are "Adding these Enterprise Products to their existing Company Wide Agreement" then Max = Original + Additional
                if (GetValueOf('OLVAddToExisting_CAL_67_text'))
                {
                    MaxQ = oQ + aQ;
                }
                else // Max is just the Additional Desktops
                {
                    MaxQ = aQ;
                }
            }
            else
            {
                // For a new order only a single value can be entered - the number of desktops
                oQ = GetValueOf('OLVDesktopCount_67') - 0;
                MaxQ = oQ;
            }           
            if ((blnSBSelected==false)&&(blnEBSelected==false))
            {
                ret = true;
            }
            else if (blnSBSelected==true)
            {
                var nTotal=GetValueOf('OLVCALSuiteSelection_67sb_std')-0;
                nTotal+=GetValueOf('OLVCALSuiteSelection_67sb_pre')-0;
                if (nTotal==MaxQ)
                {
                    ret=true;
                }
            }
            else if (blnEBSelected==true)
            {
                var nTotal=GetValueOf('OLVCALSuiteSelection_67eb_std')-0;
                nTotal+=GetValueOf('OLVCALSuiteSelection_67eb_pre')-0;
                if (nTotal==MaxQ)
                {
                    ret=true;
                }
            }
        }
        else
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;
}

function OVS_Validator(source, arguments)
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //make sure something is checked ProProducts
    if ((GetValueOf('OVSPlatform')=='1')||GetValueOf('OVSProducts_Office') || GetValueOf('OVSProducts_CAL') ||(GetValueOf('OVSWindowsVista_WindowsVista')&&GetValueOf('OVSProducts_Windows')))               
    {
        ret = true;
    }
    arguments.IsValid = ret;
}

function OVS_Validator_66(source, arguments)
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if showing v6.6
    if (UserCart.GetAttribute('OVSshowing66')=='true')
    {
        // make sure something is checked ProProducts
        if ((GetValueOf('OVSPlatform_66')=='1')||GetValueOf('OVSProducts_66_Office') || GetValueOf('OVSProducts_66_CAL') ||(GetValueOf('OVSWindowsVista_66_WindowsVista')&&GetValueOf('OVSProducts_66_Windows')))
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;

}

function OVS_Validator_67(source, arguments) // Validator to check that some component products have been chosen
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if showing v6.7
    if (UserCart.GetAttribute('OVSshowing66')=='false')
    {
        // make sure something is checked in the v6.7 component section
        if (GetValueOf('OVSProducts_67_Office') || GetValueOf('OVSProducts_67_CAL') || GetValueOf('OVSProducts_67_Windows'))
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;

}

function OVS_Office_Enterprise_UTD_Validator_67(source, arguments)
{    
	arguments.IsValid = true;
	
	var Q;
	var UTDQ;
	var ownerName = source.id;
	
    // Depending on who called us, get the values to work with	
	if (ownerName.search(/OVSOfficeProducts_67_Office_Enterprise_UTD/) >= 0) {
	    Q = GetValueOf('OVSOfficeProducts_67_Office_Enterprise') - 0;
	    UTDQ = GetValueOf('OVSOfficeProducts_67_Office_Enterprise_UTD') - 0;
	} else if (ownerName.search(/OVSOfficeProducts_67_Office_SmallBusiness_UTD/) >= 0) {
	    Q = GetValueOf('OVSOfficeProducts_67_Office_SmallBusiness') - 0;
	    UTDQ = GetValueOf('OVSOfficeProducts_67_Office_SmallBusiness_UTD') - 0;
    } else {
	    Q = GetValueOf('OVSOfficeProducts_67_Office_ProPlus') - 0;
	    UTDQ = GetValueOf('OVSOfficeProducts_67_Office_ProPlus_UTD') - 0;
    }

	var DesktopQ = GetValueOf('OVSDesktopCount_67') - 0;
		
    // We DON'T need to validate if
    //  the Office checkbox isn't checked or
    //  Existing Agreement Checkbox is checked or
    //  the parent product has a quantity = 0
	if (GetValueOf('OVSProducts_67_Office') != '1' || GetValueOf('OVSExistingAgreement') == '1' || Q == '0')
	{
		return;
	}
	
	// The UTD quantity can't be greater than the parent quantity or the overall desktop quantity
	if (UTDQ > Q || UTDQ > DesktopQ)
	{
	    arguments.IsValid = false;
	}
	
}

function OVS_OfficeValidator_67(source, arguments) // Validator to check that the quantities of Office products match the desktops specified
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    //if showing v6.7
    if (UserCart.GetAttribute('OVSshowing66')=='false')
    {
        // if Office Products is Checked
        if (GetValueOf('OVSProducts_67_Office'))
        {
            // Work out the maximum quantity allowed
            var MaxQ = 0;
            var oQ = 0;
            var aQ = 0;
            if (GetValueOf('OVSExistingAgreement')) {
                // For an existing agreement two values can be entered - original desktops and additional desktops
                oQ = GetValueOf('InitialOVSDesktopCount_67') - 0;
                aQ = GetValueOf('AdditionalOVSDesktopCount_67') - 0;
                // if they are "Adding these Enterprise Products to their existing Company Wide Agreement" then Max = Additional ONLY
                if (GetValueOf('OVSAddToExisting_Office_67_text'))
                {
                    MaxQ = aQ;
                }
                else // Max is the difference between Additional Desktops and Original Desktops, as long as that's > 0, otherwise Max = 0
                {
                    if (aQ - oQ <= 0)
                    {
                        MaxQ = 0;
                    }
                    else
                    {
                        MaxQ = aQ - oQ;
                    }
                }
            }
            else
            {
                // For a new order only a single value can be entered - the number of desktops
                oQ = GetValueOf('OVSDesktopCount_67') - 0;
                MaxQ = oQ;
            }
            // Get the values of the Office component quantities
            var oppQ = 0;
            var osbQ = 0;
            var oeeQ = 0;
            oppQ = GetValueOf('OVSOfficeProducts_67_Office_ProPlus') - 0;
            osbQ = GetValueOf('OVSOfficeProducts_67_Office_SmallBusiness') - 0;
            oeeQ = GetValueOf('OVSOfficeProducts_67_Office_Enterprise') - 0;
            // Having assembled all the info, take the final decision
            if ((MaxQ == 0 && (oppQ + osbQ + oeeQ) == 0) || (MaxQ > 0 && 0 < (oppQ + osbQ + oeeQ) && (oppQ + osbQ + oeeQ) == MaxQ))
            {
                ret = true;
            }
        }
        else
        {
            ret = true;
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;

}

function OVS_CALValidator_67(source, arguments)
{
    ret = false;
    if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    // if Office Products is Checked
    if (GetValueOf('OVSProducts_67_CAL'))
    {
        var blnSBSelected=GetValueOf('OVSCALSuiteSelection_67')=='sb';
        var blnEBSelected=GetValueOf('OVSCALSuiteSelection_67')=='eb';
        // Work out the quantity allowed
        var MaxQ = 0;
        var oQ = 0;
        var aQ = 0;
        if (GetValueOf('OVSExistingAgreement')) 
        {
            // For an existing agreement two values can be entered - original desktops and additional desktops
            oQ = GetValueOf('InitialOVSDesktopCount_67') - 0;
            aQ = GetValueOf('AdditionalOVSDesktopCount_67') - 0;
            // if they are "Adding these Enterprise Products to their existing Company Wide Agreement" then Max = Original + Additional
            if (GetValueOf('OVSAddToExisting_CAL_67_text'))
            {
                MaxQ = oQ + aQ;
            }
            else // Max is just the Additional Desktops
            {
                MaxQ = aQ;
            }
        }
        else
        {
            // For a new order only a single value can be entered - the number of desktops
            oQ = GetValueOf('OVSDesktopCount_67') - 0;
            MaxQ = oQ;
        }           
        if ((blnSBSelected==false)&&(blnEBSelected==false))
        {
            ret = true;
        }
        else if (blnSBSelected==true)
        {
            var nTotal=GetValueOf('OVSCALSuiteSelection_67sb_std')-0;
            nTotal+=GetValueOf('OVSCALSuiteSelection_67sb_pre')-0;
            if (nTotal==MaxQ)
            {
                ret=true;
            }
        }
        else if (blnEBSelected==true)
        {
            var nTotal=GetValueOf('OVSCALSuiteSelection_67eb_std')-0;
            nTotal+=GetValueOf('OVSCALSuiteSelection_67eb_pre')-0;
            if (nTotal==MaxQ)
            {
                ret=true;
            }
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;
}

function OVS_UTDCALValidator_67(source, arguments)
{
    ret = false;
    if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    // if Office Products is Checked
    if (GetValueOf('OVSProducts_67_CAL'))
    {
        var blnSBSelected=GetValueOf('OVSCALSuiteSelection_67')=='sb';
        var blnEBSelected=GetValueOf('OVSCALSuiteSelection_67')=='eb';
        if ((blnSBSelected==false)&&(blnEBSelected==false))
        {
            ret = true;
        }
        else if (blnSBSelected==true)
        {
            var nStdTotal=GetValueOf('OVSCALSuiteSelection_67sb_std')-0;
            var nPreTotal=GetValueOf('OVSCALSuiteSelection_67sb_pre')-0;
            var nStdUTDTotal=GetValueOf('CALUTD_67_sb_std')-0;
            var nPreUTDTotal=GetValueOf('CALUTD_67_sb_pre')-0;
            if ((nStdTotal>=nStdUTDTotal)&&(nPreTotal>=nPreUTDTotal))
            {
                ret=true;
            }
        }
        else if (blnEBSelected==true)
        {
            var nStdTotal=GetValueOf('OVSCALSuiteSelection_67eb_std')-0;
            var nPreTotal=GetValueOf('OVSCALSuiteSelection_67eb_pre')-0;
            var nStdUTDTotal=GetValueOf('CALUTD_67_eb_std')-0;
            var nPreUTDTotal=GetValueOf('CALUTD_67_eb_pre')-0;
            if ((nStdTotal>=nStdUTDTotal)&&(nPreTotal>=nPreUTDTotal))
            {
                ret=true;
            }
        }
    }
    else
    {
        ret = true;
    }
    arguments.IsValid = ret;
}


function CalcOVSReorderDesktops()
{
    // OVS reorder desktops under v6.7 are the additional ones minus the original ones, if thats > zero, otherwise it's zero
    var oQ = UserCart.GetAttribute("TotalDesktops") - 0;
    var aQ = UserCart.GetAttribute("OrderDesktops") - 0;
    if (aQ - oQ > 0)
        return aQ - oQ;

    return 0;
}

function E6_Validator(source, arguments)
{
    var ret = false;
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    if ((GetValueOf('E6Platform')=='1')||GetValueOf('E6Products_Office_ProPlus')||GetValueOf('E6Products_Office_Enterprise')||GetValueOf('E6Products_CAL')||(GetValueOf('E6WindowsVista_WindowsVista')&&GetValueOf('E6Products_Windows')))
    {
        ret = true;
    }
    arguments.IsValid = ret;
}


function InputLength(id)
{
    var element=GetHolderElement(id);       
    //if (element == null) 
	//{
	//    return id;
	//}
	
	var iLength = 0;
	
	if (element.value.length > 0)
	{
	    iLength = element.value.length;
	} 
 
 //alert(iLength);
	return iLength;   
}

function CheckIfEmpty(source, arguments)
{
    var controlName = source.id;
    var valName = controlName.substring('ctl00_MainContent_'.length, controlName.lastIndexOf('_'));
    var validator = GetHolderElement(valName);

    controlName = controlName.substring('ctl00_MainContent_Hidden'.length, controlName.lastIndexOf('_'));
    if (GetValueOf(controlName) != null)
    {
        var element=GetHolderElement(controlName);
        if ((element.value.length < 1) && (element.disabled == false))
        {
            element.value = validator.value;
            arguments.IsValid = false;
        }
        else
            arguments.IsValid = true;
    }
    else
    {
        arguments.IsValid = false;
    }
    return;
}


function NormalizeNull(control)
{
if (control!=null)
  {if (control.value=="")
        control.value="0";
  }  
}



function SC_Validator(source, arguments)
{

//alert(source.id);
//var iLength = 1;
//iLength = InputLength(source.id);
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    var ret = true;
    var iValue=0;
    var iLength = 1;
    if (GetValueOf('SCReorder')==true)
    {    
        iValue=GetValueOf('AdditionalSCDesktopCount')-0;
        iValue+=GetValueOf('AdditionalSCStudentCount')-0;
    }
    else
    {
        iValue=GetValueOf('SCDesktopCount')-0;
        //iLength = InputLength(source.id);
    }
    //if ((iValue==0) || (iLength == 0))
    if (iValue==0)
    {   
        ret = false;
    }
   
    arguments.IsValid = ret;
    return;
}

function CC_Validator(source, arguments)
{
    // we don't need to perform the validation if the modal popup is showing
	if (isDivVisible)
	{
		arguments.IsValid=true;
		return;		
	}
    var ret = true;
    var iValue=0;
    if (GetValueOf('CCReorder')==true)
    {    
        iValue=GetValueOf('AdditionalCCDesktopCount')-0;
        iValue+=GetValueOf('AdditionalCCStudentCount')-0;
    }
    else
    {
        iValue=GetValueOf('CCDesktopCount')-0;
    }
    if (iValue==0)
    {   
        ret = false;
    }
   
    arguments.IsValid = ret;
    return;
}

function CartGetMaxCount(OfferingCode)
{
    var ret = 0;
    var prods = UserCart.Products;

	// Go through all products in the cart and get the maximum quantity value for OfferingCode supplied
	for(var pi=0;pi<prods.length; pi++) {
        if (prods[pi].value.OfferingCode == OfferingCode)
        {
           var q = (prods[pi].value.Quantity - 0);
           if ((q - 0) > (ret - 0)) {
           ret = q;
           }
        }
	}
    return ret;
}

//Sets up a relational validation check. If any field in the list has a non-whitespace value, then this field must have a non-whitespace value. (comma-delimited string of field names)
function RequiredAndValidator(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
    arguments.IsValid=true;
	var sValue=arguments.Value;
	if ((sValue=="ZZZ")||(sValue==""))
	{
	    arguments.IsValid=false;
	}
}

function RequiredValidator(source, arguments)
{
    arguments.IsValid=true;
	var sValue=arguments.Value;
	if ((sValue=="ZZZ")||(sValue==""))
	{
	    arguments.IsValid=false;
	}
}

function CustomClientValidate(source, arguments)
{
	if (!checkRequired(source.id))
	{
		arguments.IsValid=true;
		return;		
	}
	arguments.IsValid=eval(getParameter(source.id));
}

function getInnerHeight()
{ var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
     myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
     myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
     myHeight = document.body.clientHeight;
  }
return(myHeight);
}

function showHintGivenDiv(e,id)
{
    var content=GetHolderElement(id);
    if (content!=null)
    {
        var strContent=content.innerHTML;
        showHint(e,strContent);
    }
}

function hideHint()
{
    ///PJWfix
    //Hint.style.display="none";
}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
    ///PJWfix

/*
  if (IE) 
  { 
    // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } 
  else 
  {  
    // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
  */
}

function Mod(X, Y) { return X-Math.floor(X/Y)*Y }
function Div(X, Y) { return Math.floor(X/Y) }

function RoundedUpDiv(a,b)
{
    var result=0;
    result=Div(a,b);
    if (a%b>0)
    {
        result+=1;
    }
    return result;    
}

/* Useful functions used in config docs */

function SetProductForXP(ProductKey)
{
    var ProductType=UserCart.GetProductAttribute(ProductKey,"ProductTypeCode");
    if ((ProductKey=="WHP")|(ProductKey=="OBJ"))
    {
        if (ProductType=="LSA")
        {
            ProductType="USA";
        }
        if (ProductType=="STD")
        {
            ProductType="UPZ";
        }
    }
    else
    {
        if (ProductType=="USA")
        {
            ProductType="LSA";
        }
        if (ProductType=="UPZ")
        {
            ProductType="STD";
        }
    }
    UserCart.SetProductAttribute(ProductKey,"ProductTypeCode",ProductType);
    
}

function GetSCEDesktops(nDesks, nEntered) {
    // Return the number of Desktops, if not in Product First mode, in which case return the number entered
    if (Global.GetItem('productfirst') == 1)
        return nEntered;
    else
        return nDesks;
}

function Get1PackQuantity(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%5;
       
    return nCALs;
}
/*
    GetNNNPackQuantityForSCE functions implement special behaviour for SCE products......

    If SERVER, or SERVER + SQL, products have been ordered, these come with a certain number of
    Client ML and Server ML licenses. Client and Server ML products, dependant on the actual product,
    come in 1-Pack, 5-Pack or 20-Pack bundles. The following functions split the number required of
    these products into the Pack bundles, taking into account any licenses obtained "for free" 
    (in the "multiplier" parameter) with server products already ordered.
*/
function Get1PackQuantityForSCE(nCALs, nServers, nSQLServers, multiplier)
{
    nServers = nServers * multiplier;//include nnn free from servers
    nSQLServers = nSQLServers * multiplier;//include nnn free from SQL servers
    
    nCALs-=(nServers + nSQLServers);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%5;
       
    return nCALs;
}

function Get5PackQuantityForSCE(nCALs, nServers, nSQLServers, multiplier, has20)
{
    nServers = nServers * multiplier;//include nnn free from servers
    nSQLServers = nSQLServers * multiplier;//include nnn free from SQL servers
    
    nCALs-=(nServers + nSQLServers);
    if (nCALs<0)
    {
        nCALs=0;
    }
    
    var nResult=0;
    if (has20)
    {
        nCALs=nCALs%20;
        if (nCALs%5>0)
        {
            nResult+=1;
        }
        nResult+=Div(nCALs,5);
    }
   else
   {
        nResult+=Div(nCALs,5);
       //nResult = nCALs%5 
    }  
    return nResult;

}

function Get20PackQuantityForSCE(nCALs, nServers, nSQLServers, multiplier)
{
    nServers = nServers * multiplier;//include nnn free from servers
    nSQLServers = nSQLServers * multiplier;//include nnn free from SQL servers
    
    nCALs-=(nServers + nSQLServers);
    if (nCALs<0)
    {
        nCALs=0;
    }
    var nResult=Div(nCALs,20);  
    return nResult;
}

function Get1PackQuantityforSBS(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%20;
    nCALs=nCALs%5;
    var nResult=nCALs;
    return nResult;
}

function Get1PackQuantityforEBS(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%50;
    nCALs=nCALs%20;
    nCALs=nCALs%5;
    var nResult=nCALs;
    return nResult;
}

function Get5PackQuantityForSBS(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%20;
    var nResult=0;
    nResult+=Div(nCALs,5);  
    return nResult;
}

function Get5PackQuantityforEBS(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%50;
    nCALs=nCALs%20;
    var nResult=0;
    nResult+=Div(nCALs,5);  
    return nResult;
}

function Get5PackQuantity(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%20;
    var nResult=0;
    if (nCALs%5>0)
    {
        nResult+=1;
    }
    nResult+=Div(nCALs,5);  
    return nResult;
}

function Get20PackQuantity(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    var nResult=Div(nCALs,20);  
    return nResult;
}

function Get20PackQuantityforEBS(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    nCALs=nCALs%50;
    var nResult=Div(nCALs,20);  
    return nResult;
}

function Get50PackQuantityforEBS(nCALs,nServers)
{
    nCALs-=(nServers*5);
    if (nCALs<0)
    {
        nCALs=0;
    }
    var nResult=Div(nCALs,50);  
    return nResult;
}

function GetForefrontConsoleCount(nUsers)
{
    var nResult=1+Div(nUsers-1,10000);  
    return nResult;
}

function GetIAG1PackQuantity(nCALs)
{
    var nResult=nCALs-(10000*GetIAG10kPackQuantity(nCALs));  
    return nResult;
}

function GetIAG10kPackQuantity(nCALs)
{
    var nResult=Div(nCALs,10000);  
    return nResult;
}



function getzeromin(a,b)
{
    if ((a==0)||(b==0))
    {
        return 0;
    }
    return getmin(a,b);
}

function getmin(a,b)
{
	if (a==0)
	{
		return b;
	}
	if (b==0)
	{
		return a;
	}
	if (a<b)
	{
		return a
	}
	else
	{
		return b;
	}
}
function getmax(a,b)
{
	if (a<b)
	{
		return b
	}
	else
	{
		return a;
	}
}

// Handle client post request (target URL | Handler.ashx).
function ClientPost(url) 
{
    var strReturn="";
    var req;

    if (window.XMLHttpRequest) 
    {
        req = new XMLHttpRequest();
        req.open("POST", url, false);
        req.send(null);
        
        return req.responseText;
    }
    else if (window.ActiveXObject) 
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");

        if (req) 
        {
            req.open("POST", url, false);
            req.send();
            
            return req.responseText;
        }
    }        
    return strReturn;
}

// Return the correct number of license packs for the qty required.
// License packs for eLearning come in sizes of 50, 25, 5 and 1.
// E.g. 78 licenses would be 1x50, 1x25 and 3x1 packs.
function GetLearningPacks(nQty,nPackSize)
{
    var ret = 0;
    if ((nQty >= 50) && (nPackSize == 50))
    {
        ret = (Div(nQty,50));
    }
    else if ((nQty >= 25) && (nPackSize == 25))
    {
        var rem;
        rem = nQty - (Div(nQty,50)*50)
        ret = (Div(rem,25))
    }
    else if ((nQty >= 5) && (nPackSize == 5))
    {
        var rem;
        rem = nQty - (Div(nQty,50)*50)
        rem = nQty - (Div(nQty,25)*25)
        ret = (Div(rem,5))
    }
    else if ((nQty >= 1) && (nPackSize == 1))
    {
        var rem;
        rem = nQty - (Div(nQty,50)*50)
        rem = nQty - (Div(nQty,25)*25)
        rem = nQty - (Div(nQty,5)*5)
        ret = (Div(rem,1))
    }
    return ret;
}

function IgnoreKeypress(keyID)
{
var IE = document.all?true:false;
if(IE)
  {if(event.keyCode == keyID) 
        event.returnValue = false;
   }
else
   {if (event.which == keyID )
      return (false);
   }
     
}

function SetClassByBrowser(elementName,classname,browserID)
{
 switch(browserID)
 {case 'IE7' :
    if (!IE6)
    { var element=GetHolderElement(elementName);
      if (element!=null)
        element.className=classname;
     }
    break;
  case 'IE6' :
    if (IE6)
    { var element=GetHolderElement(elementName);
      if (element!=null)
        element.className=classname;
     }
    break;
 } 
}

function closedialog()
{
    var returnValue=null;
    if (preForm != serialise('aspnetForm')) 
    {
        if (showDialog==true)
        {
            returnValue=LOC_SAVE_DIALOG;
        }
    } 
    showDialog=false;
    hideDiv('ctl00_ProgressIndicator');
    if (returnValue!=null)
    {
        return returnValue;
    }
}

var preForm =null;
var nforcefail=false;

function doclosedialog()
{
    if (nforcefail==true)
    {
        nforcefail=false;
        return false;
    }
    
    var returnValue=null;
    if (preForm!=null)
    {
        if (preForm != serialise('aspnetForm')) 
        {
            var answer = confirm (LOC_SAVE_DIALOG);
            if (answer)
            {
                var addbutton=GetHolderElement("exss_cmdAddToCart");
                if (addbutton!=null)
                {
                    addbutton.click();
                }
                return false;
            }
            else
            {
                return true;
            }
            /*
            if (answer)
            {
                return true;
            }
            else
            {
                return false;
            }
            */
        }            
    }
    return true;
}

function SetClass(id,value)
{
    var element=GetHolderElement(id);
    if (element!=null)
    {
        if (element.className!=null)
        {
            element.className=value;
        }
    }
}
function EASeverCalcOnLoad(id) {

    var intsum = 0;
    var returnValue = null;

    switch (id) {
        case "EASM_E6DesktopCount":
            var intdeskcount = GetValueOf(id);
            if (intdeskcount != null) {
                //do addtional windows servers
                parseInt(intsum = (parseInt(intdeskcount/10)));
                intsum = intsum - 13 - 4 - 1;
                returnValue = intsum;
            }
            break
        case "EASM_WindowsServerExtra":
            var intwinstdcount = GetValueOf(id);
            if (intwinstdcount != null) {
                //do SCS
                parseInt(intsum = (parseInt(intwinstdcount) + parseInt(13)));
                returnValue = intsum;
            }
            break
        default:
            //TBC
            break
    }

    return returnValue;

}

function EASeverCalcOnPage(id) {

    var intsum = 0;
    var returnValue = null;

    switch (id) {
        case "EASM_WindowsServerExtra":
            var intwinxtotal = GetValueOf("EASM_WindowsServerExtra");
            var intwinstdtotal = GetValueOf("EASM_WindowsServerStd");
            var intwinenttotal = GetValueOf("EASM_WindowsServerEnt");
            var intwindatatotal = GetValueOf("EASM_WindowsServerData");
            if (intwinxtotal != null) {
                parseInt(intsum = parseInt(intwinxtotal) + parseInt(intwinstdtotal) + parseInt(intwinenttotal) + parseInt(intwindatatotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleWindows")
            objCheckLabel.nextSibling.innerText = LOC_EASM_WindowsCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        case "EASM_SQLStdPP":
            var intsqlstdtotal = GetValueOf("EASM_SQLStdPP");
            var intsqlenttotal = GetValueOf("EASM_SQLEntPP");
            if (intsqlstdtotal != null) {
                parseInt(intsum = parseInt(intsqlstdtotal) + parseInt(intsqlenttotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleSQL")
            objCheckLabel.nextSibling.innerText = LOC_EASM_SQLCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        case "EASM_ExchangeServerExtra":
            var intexchangextotal = GetValueOf("EASM_ExchangeServerExtra");
            var intexchangestdtotal = GetValueOf("EASM_ExchangeStd");
            var intexchangeenttotal = GetValueOf("EASM_ExchangeEnt");
            if (intexchangextotal != null) {
                parseInt(intsum = parseInt(intexchangextotal) + parseInt(intexchangestdtotal) + parseInt(intexchangeenttotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleExchange")
            objCheckLabel.nextSibling.innerText = LOC_EASM_ExchangeCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        case "EASM_SharepointServerExtra":
            var intsharetotal = GetValueOf("EASM_SharePoint");
            var intshareextratotal = GetValueOf("EASM_SharepointServerExtra");
            if (intsharetotal != null) {
                //do addtional sharepoint servers                
                parseInt(intsum = parseInt(intsharetotal) + parseInt(intshareextratotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleSharePoint")
            objCheckLabel.nextSibling.innerText = LOC_EASM_SharepointCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        case "EASM_SCSConfigMgr":
            var intscsconfigtotal = GetValueOf("EASM_SCSConfigMgr");
            var intscsmeenttotal = GetValueOf("EASM_SCSSMEEnt");
            var intscsopstotal = GetValueOf("EASM_SCSOpsMgr");
            var intscsdatatotal = GetValueOf("EASM_SCSDataProMgr");
            var intscsconfigsmltotal = GetValueOf("EASM_SCSConfigSML");
            var intscsopssmltotal = GetValueOf("EASM_SCSOpsMgrSML");
            if (intscsconfigtotal != null) {
                //do addtional scs servers                
                parseInt(intsum = parseInt(intscsconfigtotal) + parseInt(intscsmeenttotal) + parseInt(intscsopstotal) + parseInt(intscsdatatotal) + parseInt(intscsconfigsmltotal) + parseInt(intscsopssmltotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleSCS")
            objCheckLabel.nextSibling.innerText = LOC_EASM_SCSCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        case "EASM_OCSExtra":
            var intocstotal = GetValueOf("EASM_OCSEnt");
            var intocsextratotal = GetValueOf("EASM_OCSExtra");
            if (intocstotal != null) {
                //do addtional sharepoint servers                
                parseInt(intsum = parseInt(intocstotal) + parseInt(intocsextratotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleOCS")
            objCheckLabel.nextSibling.innerText = LOC_EASM_OCSCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        case "EASM_FFClientSMC":
            var intffclientsmctotal = GetValueOf("EASM_FFClientSMC");
            var intffserversmctotal = GetValueOf("EASM_FFServerSMC");
            var intffisatotal = GetValueOf("EASM_FFISAE");
            if (intffclientsmctotal != null) {
                //do addtional sharepoint servers                
                parseInt(intsum = parseInt(intffclientsmctotal) + parseInt(intffserversmctotal) + parseInt(intffisatotal));
                returnValue = intsum;
            }
            var objCheckLabel = GetHolderElement("EASM_toggleForefront")
            objCheckLabel.nextSibling.innerText = LOC_EASM_ForeFrontCheck + " " + LOC_EASM_GROUP + " " + intsum;
            break
        default:
            //TBC
            break
    }
    return returnValue;

}

function ShowEASM(e)
{
    if (e.disabled!=true)
    {
        showModalPopup('popEASM');
    }
}

function getform()
{
}