﻿// JScript File
var selectedElmnt = ""

function ShowHideMenu(elmnt)
{
	var e = document.getElementById(elmnt);
	if(e.style.display == 'none')
	{
		if (selectedElmnt != ""){document.all(selectedElmnt).style.display = "none";}
		e.src = 'images/' +elmnt + '_up.jpg';
		e.style.display = 'block';
		selectedElmnt = e.id;
	}
	else
	{
		e.src = 'images/' +elmnt + '_down.jpg';
		e.style.display = 'none';
	}
}
function emptyDDL(ddl)
{   
    for (;;) 
    { 
        if (document.all(ddl).options.length == 0) 
            break 
        document.all(ddl).remove(0) 
    } 
    var comp = document.createElement("Option") 
    comp.text="--Select One--" 
    comp.value=0 
    document.all(ddl).add(comp) 
}

function changeDDLs(ddl1,ddl2,hf,status,ddlupper,upperhf)
{
if (ddlupper !='')
     {
        if(document.all(ddl1).value =="0")
        {
            ddl1=ddlupper
            hf=upperhf
            //alert(ddl1);
        }

     }
//  if(document.all(ddl1).value !="0")
//  {
     if (status=="R")
     {
        arr_val = document.all(hf).value.split("$")
            ddl1_code = document.all(ddl1).value
//            for (;;) 
//            { 
//                if (document.all(ddl2).options.length == 0) 
//	                break 
//                document.all(ddl2).remove(0) 
//            } 
//            var comp = document.createElement("Option") 
//            comp.text="--Select One--" 
//            comp.value=0 
//            document.all(ddl2).add(comp) 
            for (i=0; i < arr_val.length-1 ;i++) 
            { 
                arr_val2 = arr_val[i].split("@") 
                if (arr_val2[0] == ddl1_code || arr_val2[0]==0) 
                { 
                    var comp = document.createElement("Option") 
                    //comp.text=arr_val2[2] 
                    comp.value=arr_val2[1] 
                    //document.all(ddl2).add(comp) 
                    document.all(ddl2).value=comp.value
                } 
            } 
     }
     else
     {
         
            arr_val = document.all(hf).value.split("$")
            if (document.all(ddl1))
                ddl1_code = document.all(ddl1).value
            for (;;) 
            { 
                if (document.all(ddl2).options.length == 0) 
                {
	                break 
	             //alert('hello');   
	            }
                document.all(ddl2).remove(0) 
            } 
            var comp = document.createElement("Option") 
            comp.text="--Select One--" 
            comp.value=0 
            document.all(ddl2).add(comp) 
            for (i=0; i < arr_val.length-1 ;i++) 
            { 
                arr_val2 = arr_val[i].split("@") 
                if (arr_val2[0] == ddl1_code || arr_val2[0]==0) 
                { 
                    var comp = document.createElement("Option") 
                    comp.text=arr_val2[2] 
                    comp.value=arr_val2[1] 
                    document.all(ddl2).add(comp) 
                } 
            } 
      } 
  // }
}

function changeDDLsALLCAse(ddl1,ddl2,hf,status,ddlupper,upperhf)
{
//alert(ddl1);
//alert(ddl2);
//alert(hf);
if (ddlupper !='')
     {
        if(document.all(ddl1).value =="0")
        {
            ddl1=ddlupper
            hf=upperhf
            //alert(ddl1);
        }

     }
//  if(document.all(ddl1).value !="0")
//  {
     if (status=="R")
     {
        arr_val = document.all(hf).value.split("$")
            ddl1_code = document.all(ddl1).value
//            for (;;) 
//            { 
//                if (document.all(ddl2).options.length == 0) 
//	                break 
//                document.all(ddl2).remove(0) 
//            } 
//            var comp = document.createElement("Option") 
//            comp.text="--Select One--" 
//            comp.value=0 
//            document.all(ddl2).add(comp) 
            for (i=0; i < arr_val.length-1 ;i++) 
            { 
                arr_val2 = arr_val[i].split("@") 
                if (arr_val2[0] == ddl1_code || arr_val2[0]==0) 
                { 
                    var comp = document.createElement("Option") 
                    //comp.text=arr_val2[2] 
                    comp.value=arr_val2[1] 
                    //document.all(ddl2).add(comp) 
                    document.all(ddl2).value=comp.value
                } 
            } 
     }
     else
     {
         
            arr_val = document.all(hf).value.split("$")
            if (document.all(ddl1))
                ddl1_code = document.all(ddl1).value
            for (;;) 
            { 
                if (document.all(ddl2).options.length == 0) 
                {
	                break 
	             //alert('hello');   
	            }
                document.all(ddl2).remove(0) 
            } 
            var comp = document.createElement("Option") 
            comp.text="All" 
            comp.value=0 
            document.all(ddl2).add(comp) 
            for (i=0; i < arr_val.length-1 ;i++) 
            { 
                arr_val2 = arr_val[i].split("@") 
                if (arr_val2[0] == ddl1_code || arr_val2[0]==0) 
                { 
                    var comp = document.createElement("Option") 
                    comp.text=arr_val2[2] 
                    comp.value=arr_val2[1] 
                    document.all(ddl2).add(comp) 
                } 
            } 
      } 
  // }
}
