// JScript source code
	var buydesc ;
	var quantity ;
	var unit_price;
	var discount ;
	var spanbuydesc ;
	var spanquantity ;
	var spanunit_price ;
	var spandiscount ;
	//this is for the global choise area
	var namebox;
	var discriptionBox;
	
function UpdateHdValues(hdID,hdValue)
{
//	UpdateParentHdValues(string nameOfObject,String Value);
	var objHd = parent.document.getElementById(hdID);
	//alert("hdid" + hdID + ", value: " +hdValue);

	if (objHd != null)
	{
		objHd.value = hdValue;
		//alert("1hdid" + hdID + ", value: " +hdValue);
	}
	else
	{
	    var objHD1 = window.frames.document.getElementById(hdID);
	    if (objHD1 != null)
	    {
	    	objHD1.value = hdValue;
	    	//alert("2hdid" + hdID + ", value: " +hdValue);
    	}
	}
}

function setHiddendValViaRadioList(rdolistID,objID,selectValue)			
{
    var rdolist = parent.document.getElementsByName(rdolistID);
    var objHd = parent.document.getElementById(objID);

    if ( rdolist != null)
    {
        for ( var i=0, len=rdolist.length; i<len; ++i )
        {
            if (rdolist[i].checked)
            {
                if ((objHd != null) && (rdolist[i].value == selectValue))
                {
		            current = 'inline';
		            objHd.style.display = current;
        	    }
        	    else
        	    {
                    if (objHd != null)
                    {
		                current = 'none';
		                objHd.style.display = current;
        	        } 	        
        	    }
            }
        }
    }
}

function DescHdValues(hdID)
{
//	UpdateParentHdValues(string nameOfObject,String Value);

	var objHd = parent.document.getElementById(hdID);
	if (objHd != null)
	{
		if(objHd.value == 0)
			objHd.value = 1;
		else if(objHd.value == 1)
			objHd.value = 0;
	}
}

function checkEnter(e, buttonsID)//e is the event for the keyPress and ButtonsID is what you want to click
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

    if (key == 13)
    {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonsID);
        if (btn != null)
        { //If we find the button click it
            btn.click();
            event.keyCode = 0
        }
    }
}

function buttonClick (btnName)
{
    var btn = document.getElementById(btnName);
    if (btn) btn.click();
}

function getElemValue(itemID)
{
    //alert("in getElem");
	var obj = parent.document.getElementById(itemID);
	if (obj != null)
	{
		return obj.value;
		//alert("got to it");
	}
	else
	{
	    return -1;
	}
}

function checkItemQty(textBoxItemID, hdfID,validationCheckBoxID, caseTextBoxID)
{
	var obj =  parent.document.getElementById(hdfID);
	var obj1 = parent.document.getElementById(textBoxItemID);
	var validationCheckBox = parent.document.getElementById(validationCheckBoxID);
	
	if ((validationCheckBox != null) && (validationCheckBox.checked))
	{
	    if ((obj != null) && (obj1 != null))
	    {
	        var orderByQty = obj.value;
	        var toOrderQty = obj1.value;
	        var remainderNumb = toOrderQty%orderByQty;
	        if ( remainderNumb != 0 )
	        {
	            //alert(toOrderQty+" is not a valid quantity to order. Your order must be in quantaties of "+orderByQty+". ");
	            if( !confirm(toOrderQty+" is not a valid quantity to order. Your order must be in quantities of "+orderByQty+".  \n\rWould you like to override this?"))
	            {
	                var qtyLess = orderByQty-remainderNumb;
	                toOrderQty = (toOrderQty*1)+ qtyLess;
	                obj1.value = toOrderQty;
	                setCaseQtyFromPieceQty(toOrderQty, getElemValue(hdfID), caseTextBoxID);
	                return true;
	            }
                return true;
	        }
	        return true;
	    } 
	}
	return true; 
}

function setPieceQtyFromCaseQty(caseQty, orderQty,  textBoxItemID)
{
	var obj1 = parent.document.getElementById(textBoxItemID);
	if (obj1 != null)
	{
		obj1.value = caseQty*orderQty;
	}
}

function setCaseQtyFromPieceQty(pieceQty, orderQty,  textBoxItemID)
{	
	var obj1 = parent.document.getElementById(textBoxItemID);
	if (obj1 != null)
	{
		obj1.value = pieceQty/orderQty;
	}
}
function setVisibility(hdID)
{
	var objHD1 = parent.document.getElementById(hdID);
	if (objHD1 != null)
	{
    	var Value = (document.getElementById(hdID).style.display == 'none') ? 'block' : 'none';
		objHD1.style.display = Value;
    }
}

function setVisibilityVal(hdID,Value)
{
	var objHD1 = parent.document.getElementById(hdID);
	if (objHD1 != null)
	{
		objHD1.style.display = Value;
    }
}

function setPopulateNumber(dropDownID,populateHDID)
{
	var dropDownObj = parent.document.getElementById(dropDownID);
	var populateHDObj = parent.document.getElementById(populateHDID);
	var selectedVal = "";
	var button = null; 
	var length = 0;
	if (dropDownObj != null && populateHDObj != null)
	{
        selectedVal = dropDownObj[dropDownObj.selectedIndex].value
	}
	if (selectedVal != "")
	{
	    populateHDObj.value = selectedVal;
	    return true;
	}
	else
	{
	    alert("Please Select a Function");
	    return false;
	}
}

function checkGlobalSubmitDropdown(dropDownID)
{
	var dropDownObj = parent.document.getElementById(dropDownID);
	var selectedVal = "";
	var button = null; 
	var length = 0;
	if (dropDownObj != null)
	{
        if (dropDownObj[dropDownObj.selectedIndex].value == "0")
        {
	        alert("Please Select a Warehouse");
	        return false;
	    }
	    else
	    {
	        return true;
	    }
	}
}

function UpdateHideLableValues(hdID,hdValue1,hdValue2)
{
	var objHd = parent.document.getElementById(hdID);

	if (objHd != null)
	{

	    if (objHd.innerHTML  == hdValue1)
	    {
		    objHd.innerHTML  = hdValue2;
		}
	    else if (objHd.innerHTML  == hdValue2)
	    {
		    objHd.innerHTML  = hdValue1;
		}
	}
}
function switchImages(itemID, imgURL1,imgURL2)
{
	var objHd = parent.document.getElementById(itemID);
    if (objHd != null)
	{
	    if (objHd.src.indexOf(imgURL1) != -1)
	    {
		    objHd.src = imgURL2;
		}
	    else if (objHd.src.indexOf(imgURL2) != -1 )
	    {
		    objHd.src = imgURL1;
		}
	}
}

function setBackgroundColor(object, color)
{
    if (object != null)
	{
	    object.style.backgroundColor = color;
	}
}

function setTextColor(objectId, color)
{
	var objlink = parent.document.getElementById(objectId);
    if (objlink != null)
	{
	    objlink.style.color = color;
	}
}

function addTextToHdValues(hdID, hdValue, boxID)
{
//	UpdateParentHdValues(string nameOfObject,String Value);
	var objHd = parent.document.getElementById(hdID);
	var objbox = parent.document.getElementById(boxID);
	//alert("hdid" + hdID + ", value: " +hdValue);

	if (objHd != null && objbox != null)
	{
	    if(objHd.value == "")
	    {
		    objHd.value = hdValue + ";" + objbox.value;
		}
		else
		{
		    objHd.value = objHd.value + "," + hdValue + ";" + objbox.value;
		}
		//alert("1hdid" + hdID + ", value: " +hdValue);
	}
	else
	{
	    var objHD1 = window.frames.document.getElementById(hdID);
	    var objbox = window.frames.document.getElementById(boxID);
	    if (objHD1 != null)
	    {
	        if(objHD1.value == "" && objbox != null)
	        {
		        objHD1.value = hdValue + ";" + objbox.value;;
		    }
		    else
		    {
		        objHD1.value = objHD1.value + "," + hdValue + ";" + objbox.value;
		    }
	    	//alert("2hdid" + hdID + ", value: " +hdValue);
    	}
	}
}

function UpdateHdValuesFromDropdown(hdID,Dropdown)
{

	var objHd = parent.document.getElementById(hdID);
	if (objHd != null && Dropdown != null)
	{
        var SelValue = Dropdown.options[Dropdown.selectedIndex].value;
		objHd.value = SelValue;
	}
}

function setDropDownIndex(rdolistID,dropDownID,value, radioSelectValue)
{
	var dropDownObj = parent.document.getElementById(dropDownID);
    var rdolist = parent.document.getElementsByName(rdolistID);
    
    if ( rdolist != null)
    {
        if (dropDownObj != null)
        {
            dropDownObj.options[0].selected = true;        
        }
        
        for ( var i=0, len=rdolist.length; i<len; ++i )
        {
            if (rdolist[i].checked)
            {
                if ((rdolist[i].value == radioSelectValue) && (dropDownObj != null))
                {
                    dropDownObj[value].selected = true;
                }
            }
        }
    }
}

function setHiddenValue(rdolistID,objHdID,value,radioSelectValue)
{
	var objHd = parent.document.getElementById(objHdID);
    var rdolist = parent.document.getElementsByName(rdolistID);
    
    if ( rdolist != null)
    {
        if (objHd != null)
        {
            objHd.value = '10';
        }
        
        for ( var i=0, len=rdolist.length; i<len; ++i )
        {
            if (rdolist[i].checked)
            {
                if ((rdolist[i].value == radioSelectValue) && (objHd != null))
                {
                    objHd.value = value;
                }
            }
        }
    }
}


function setAddressVisibility(dropDownObj,ID_prefix)
{
	if (dropDownObj != null)
	{
        for( i=0; i < dropDownObj.length ; i++)
        {
            var visibleObj = parent.document.getElementById(ID_prefix + i);
            if (visibleObj != null)
            {
                if (dropDownObj[dropDownObj.selectedIndex].value == i)
                {
                    visibleObj.style.display = 'block';
                    //alert("block "+ID_prefix + i);
                }
                else
                {
                    visibleObj.style.display = 'none';
                    //alert("none "+ ID_prefix + i);
                }
            }
            else
            {
                //alert("Error: The boject to be displayed is null.");
            }
        }
	}
}


function setVisibilityWithDropdown(dropDownObj)
{
	if (dropDownObj != null)
	{
        for( var x = 0; x < dropDownObj.options.length; x++)
        {
            var visibleObj = parent.document.getElementById(removeSpaces(dropDownObj[x].value));
        	if (visibleObj != null)
	        {
                if (dropDownObj.selectedIndex == x)
                {
                    visibleObj.style.display = 'block';
                }
                else
                {
                    visibleObj.style.display = 'none';
                }
            }
        }
	}
}

function removeSpaces(string) {
 return string.split(' ').join('');
}


function setVisibilityUsingDropdown(dropDownID,visibleItemID,visibleItem)
{
	var dropDownObj = parent.document.getElementById(dropDownID);
	var visibleObj = parent.document.getElementById(visibleItemID);
	if (dropDownObj != null && visibleItemID != null)
	{
         if (dropDownObj[dropDownObj.selectedIndex].value == visibleItem)
         {
             visibleObj.style.display = 'block';
         }
         else
         {
            visibleObj.style.display = 'none';
         }
	}
}

//############################## service area ################
// -----------------------  llbo service area ----------------
// this is using the llbo service for updating the supplier Records
function UpdateSupplier(buyPriceIDValue, buydescID, quatID, upriceID, discID, spanbuydescID, spanquatID, spanupriceID, spandiscID)
{
    var supplierRecordsObj = new Object();
    
	buydesc = parent.document.getElementById(buydescID);
	quantity = parent.document.getElementById(quatID);
	unit_price = parent.document.getElementById(upriceID);
	discount = parent.document.getElementById(discID);
	spanbuydesc = parent.document.getElementById(spanbuydescID);
	spanquantity = parent.document.getElementById(spanquatID);
	spanunit_price = parent.document.getElementById(spanupriceID);
	spandiscount = parent.document.getElementById(spandiscID);

	var doNotDo = 0 ;

	if ((quantity != null ) && (buydesc != null ) && (unit_price != null ) && (discount != null ))
	{
        supplierRecordsObj.Buyprice_Id=buyPriceIDValue;
        supplierRecordsObj.Quantity=quantity.value;
        supplierRecordsObj.Buydesc=buydesc.value;
        supplierRecordsObj.Unit_Price=unit_price.value;
        supplierRecordsObj.Discount=discount.value;
    }
    else
    {
        doNotDo = 1;
    }
    
    if( doNotDo == 0)
    {    
        llbo.UpdateSupplierObject(supplierRecordsObj,UpdateSupplierResult,ErrorHandler,TimeOutHandler);
    }
    else
    {
        UpdateSupplierResult(-1);
    }
}
function UpdateSupplierResult(result)
{
    if(result>0)
    {
        UpdateSupplierSpanTextBox(result);
    }
    else
    {
        alert("Error occured while updating!");
    }
}


//"number" "BinDropDown" "PiecesTextBox" "SelectedValuePO" "HDSelectedRButton" "updateLable"
function PO_Submit(HDnumberID, BinDropDownID, PiecesTextBoxID,poDropDownID,HDSelectedRButtonID,pices_error_LableID,pending_PiecesID)
{
	var number = parent.document.getElementById(HDnumberID);
	var BinDropDown = parent.document.getElementById(BinDropDownID);
	var PiecesTextBox = parent.document.getElementById(PiecesTextBoxID);
	var SelectedValuePO = parent.document.getElementById(poDropDownID);
	var HDSelectedRButton = parent.document.getElementById(HDSelectedRButtonID);
	var RecordsObj = new Object();
	var RecordsObj1 = new Object();
	
	var doNotDo = 0 ;

	if ((number != null ) && (BinDropDown != null ) && (PiecesTextBox != null ) && (SelectedValuePO != null ) && (HDSelectedRButton != null ))
	{
        RecordsObj1.number=number.value;
        RecordsObj1.BinDropDown=BinDropDown[BinDropDown.selectedIndex].value;
        RecordsObj1.PiecesTextBox=PiecesTextBox.value;
        RecordsObj1.SelectedValuePO=SelectedValuePO[SelectedValuePO.selectedIndex].value;
        RecordsObj1.HDSelectedRButton=HDSelectedRButton.value;
        RecordsObj1.pending_Pieces=pending_PiecesID;
        RecordsObj1.updateLable=pices_error_LableID;
                
        RecordsObj = HashTableToOrderedTable(RecordsObj1)
    }
    else
    {
        doNotDo = 1;
    }
    
    if( doNotDo == 0)
    {    
        llbo.execute_PO_Submit(RecordsObj,PO_SubmitResult,ErrorHandler,TimeOutHandler);
    }
    else
    {
        PO_SubmitResult(-1);
    }
}

function PO_SubmitResult(result)
{
    if(result[0] != null && result[1] != null)
    {
	    var updateLable = parent.document.getElementById(result[1]);
	    updateLable.innerHTML = result[0];
	    var pendingPoLable = parent.document.getElementById(result[3]);
	    pendingPoLable.innerHTML = result[2];
	    if(result[2] > 0 )
	    {
	        var pendingPoCell = parent.document.getElementById(result[3]+'_cell');
	        pendingPoCell.style.backgroundColor = "#FAFAD2";
	    }
	    else
	    {
	    	var pendingPoCell = parent.document.getElementById(result[3]+'_cell');
	        pendingPoCell.style.backgroundColor = "#FFFFFF";
	    }
	    //("background-color", "#FAFAD2");
        //var lblMsg=document.getElementById("lblMsg");
        //lblMsg.innerText="Employee updated successfully!";
    }
    else
    {
        // var lblMsg=document.getElementById("lblMsg");
        //lblMsg.innerText="Error occured while updating the employee!";
        alert("Error occured while submitting!");
    }
}



function UpdateGlobalChoiceData(choiceDropDownID, nameBoxID, discriptionBoxID)
{
    var RecordsObj = new Object();
    var RecordsObj1 = new Object();
	var choiceDropDown = parent.document.getElementById(choiceDropDownID);
	namebox = parent.document.getElementById(nameBoxID);
	discriptionBox = parent.document.getElementById(discriptionBoxID);

	var doNotDo = 0 ;

	if ((choiceDropDown != null ) && (namebox != null ) && (discriptionBox != null ))
	{
        RecordsObj1.id=choiceDropDown[choiceDropDown.selectedIndex].value;
        RecordsObj1.name=namebox.value;
        RecordsObj1.discript=discriptionBox.value;
        RecordsObj = HashTableToOrderedTable(RecordsObj1)
    }
    else
    {
        doNotDo = 1;
    }
    
    if( doNotDo == 0)
    {    
        llbo.UpdateGlobalChoiceObject(RecordsObj,UpdateGlobalResult,ErrorHandler,TimeOutHandler);
    }
    else
    {
        UpdateSupplierResult(-1);
    }
}

function UpdateGlobalResult(result)
{
    if(result>0)
    {
        //var lblMsg=document.getElementById("lblMsg");
        //lblMsg.innerText="Employee updated successfully!";
        alert("Updated Successfully!");
    }
    else
    {
        // var lblMsg=document.getElementById("lblMsg");
        //lblMsg.innerText="Error occured while updating the employee!";
        alert("Error occured while updating!");
    }
}

function GetGlobalAreaData(choiceDropDownID, nameBoxID, discriptionBoxID)
{
	namebox = parent.document.getElementById(nameBoxID);
	discriptionBox = parent.document.getElementById(discriptionBoxID);
	choiceDropDown = parent.document.getElementById(choiceDropDownID);
	var GlobalChoiceid = choiceDropDown[choiceDropDown.selectedIndex].value;
	
	if (namebox != null && discriptionBox != null && choiceDropDown != null && GlobalChoiceid != "")
	{
        var supplierRecordsObj = new Object();
        llbo.GetGlobalChoiceRecord(GlobalChoiceid,SetGlobalChoiceData,ErrorHandler,TimeOutHandler);
    }
    else if ((namebox != null ) && (discriptionBox != null ))
	{
        namebox.value = "";
	    discriptionBox.value = "";
	}
}

function SetGlobalChoiceData(result)
{
	if ((namebox != null ) && (discriptionBox != null ))
	{
	    var myResult = new Object();
	    myResult = orderedTableToHashTable(result)
	    
	    var temp = new Object();
	    temp = HashTableToOrderedTable (myResult);
        namebox.value = myResult.name;
	    discriptionBox.value = myResult.discript;
	}
}

function UpdateSupplierSpanTextBox(buyPriceIDValue)
{
    var supplierRecordsObj = new Object();

    llbo.GetOneSupplierRecord(buyPriceIDValue,UpdateSupplierSpanTextBoxResult,ErrorHandler,TimeOutHandler);
}

function UpdateSupplierSpanTextBoxResult(result)
{
	if ((quantity != null ) && (buydesc != null ) && (unit_price != null ) && (discount != null ) && (spanbuydesc != null ) && (spanquantity != null ) && (spanunit_price != null ) && (spandiscount != null ))
	{
        quantity.value= result.Quantity;
        spanquantity.innerText = result.Quantity;

        buydesc.value= result.Buydesc;
        spanbuydesc.innerText = result.Buydesc;

        unit_price.value= result.Unit_Price;
        spanunit_price.innerText = result.Unit_Price;

        discount.value= result.Discount;
        spandiscount.innerText = result.Discount;
    }
}

function supplierRecord(result)
{
    if(result>0)
    {
        var lblMsg=document.getElementById("lblMsg");
        lblMsg.innerText="Employee updated successfully!";
    }
    else
    {
        var lblMsg=document.getElementById("lblMsg");
        lblMsg.innerText="Error occured while updating the employee!";
    }
}

//----------- shop service -----------------
// this is using the shopservice to add theme to shop relationships
function SetShopToTheme(shopId,themeId)
{
    var shopToThemeObj = new Object();
    shopToThemeObj.ShopId = shopId;
    shopToThemeObj.ThemeId = themeId;
    shopService.SetShopToThemeRelation(shopToThemeObj,ShopToThemeResult,ErrorHandler,TimeOutHandler);
}

// this is using the shopservice to remove theme to shop relationships
function RemoveShopToTheme(ID)
{
    var shopToThemeObj = new Object();
    shopToThemeObj.ID = ID;
    shopService.RemoveShopeToThemRelation(shopToThemeObj,ShopToThemeResult,ErrorHandler,TimeOutHandler);
}

function ShopToThemeResult(result)
{
    if(result<0)
    {
        alert("Error updating Shop Thems!");
    }
}

function SetSelectedShopToTheme(listObj, HDshopIdObj) 
{
	if (!hasOptions(listObj) || HDshopIdObj == null) { return; }
	for (var i=0; i<listObj.options.length; i++) 
	{
		if (listObj.options[i].selected == true)
		{
		    SetShopToTheme(HDshopIdObj.value,listObj.options[i].value);
		}
	}
}

function RemoveSelectedShopToTheme(listObj) 
{
	if (!hasOptions(listObj)) { return; }
	for (var i=0; i<listObj.options.length; i++) 
	{
		if (listObj.options[i].selected == true)
		{
		    RemoveShopToTheme(listObj.options[i].value);
		}
	}
}

function ClearShopToTheme(listObj) 
{
	if (!hasOptions(listObj)) { return; }
	for (var i=0; i<listObj.options.length; i++) 
	{
		RemoveShopToTheme(listObj.options[i].value);
	}
}
//----------- shop service -----------------
// this is using the shopservice to add Collect to shop relationships
function SetShopToCollect(shopId,CollectId)
{
    var shopToCollectObj = new Object();
    shopToCollectObj.ShopId = shopId;
    shopToCollectObj.CollectId = CollectId;
    shopService.SetShopToCollectRelation(shopToCollectObj,ShopToCollectResult,ErrorHandler,TimeOutHandler);
}

// this is using the shopservice to remove theme to shop relationships
function RemoveShopToCollect(ID)
{
    var shopToCollectObj = new Object();
    shopToCollectObj.ID = ID;
    shopService.RemoveShopeToCollectRelation(shopToCollectObj,ShopToCollectResult,ErrorHandler,TimeOutHandler);
}

function ShopToCollectResult(result)
{
    if(result<0)
    {
        alert("Error updating Shop Collect!");
    }
}

function SetSelectedShopToCollect(listObj, HDshopIdObj) 
{
	if (!hasOptions(listObj) || HDshopIdObj == null) { return; }
	for (var i=0; i<listObj.options.length; i++) 
	{
		if (listObj.options[i].selected == true)
		{
		    SetShopToCollect(HDshopIdObj.value,listObj.options[i].value);
		}
	}
}

function RemoveSelectedShopToCollect(listObj) 
{
	if (!hasOptions(listObj)) { return; }
	for (var i=0; i<listObj.options.length; i++) 
	{
		if (listObj.options[i].selected == true)
		{
		    RemoveShopToCollect(listObj.options[i].value);
		}
	}
}

function ClearShopToCollect(listObj) 
{
	if (!hasOptions(listObj)) { return; }
	for (var i=0; i<listObj.options.length; i++) 
	{
		RemoveShopToCollect(listObj.options[i].value);
	}
}
//----------- shop service -----------------
// this is using the shopservice to add new shope body
function addNewShopeBody(shopId)
{
    shopService.addNewShopeBodySection(shopId,addNewShopeBodyResult,ErrorHandler,TimeOutHandler);
}

function addNewShopeBodyResult(result)
{
    if(result<0)
    {
        alert("Error adding new shope body !");
        return false;
    }
    else
    {
        return true;
    }
}

// this is using the shopservice to remove shope body
function removeShopeBody(BodyId)
{
    if(confirm('Are you sure you wish to continue?'))
    {
        shopService.removeShopeBodySection(BodyId,removeShopeBodyResult,ErrorHandler,TimeOutHandler);
    }
}

function removeShopeBodyResult(result)
{
    if(result<0)
    {
        alert("Error adding new shope body !");
        return false;
    }
    else
    {
        return true;
    }
}

function orderedTableToHashTable(orderedTable)
{
    var MyHash= new Object();
    for (var i =0; i< orderedTable.length ; i++)
    {
        MyHash[orderedTable[i].Name] = orderedTable[i].Value
    }
    return MyHash;
}

function HashTableToOrderedTable(HashTable)
{
    var MyOrderedTable = new Array();
    var count = 0;
    for (var obj in HashTable)
    {
        var MyTableObject= new Object();
        MyTableObject.Name = obj;
        MyTableObject.Value = HashTable[obj];
        MyOrderedTable[count] = MyTableObject;
        count++;
    }
    return MyOrderedTable;
}

function getAllforGlobalSubmit(all_LLBOID,warehouseDropDownId)
{
    var hdAllIds = document.getElementById(all_LLBOID);
    var warehouseDropDown = document.getElementById(warehouseDropDownId);
    if (hdAllIds != null)
    {
        var MyArray = hdAllIds.value.split(",");
        for(var i = 0 ; i <MyArray.length-1 ; i++)
        {
            var hdsubmitOBJ = document.getElementById(MyArray[i]);
            var MyArray2 = hdsubmitOBJ.value.split(",");
            var HDnumberID = MyArray2[0];
            var BinDropDownID = MyArray2[1];
            var PiecesTextBoxID = MyArray2[2];
            var poDropDownID = MyArray2[3];
            var HDSelectedRButtonID = MyArray2[4];
            var pices_error_LableID = MyArray2[5];
            var pending_PiecesID = MyArray2[6];
            
            var BinDropDown = document.getElementById(BinDropDownID);
          
            for( var x = 0; x < BinDropDown.length; x++)
            {
                if(BinDropDown[x].text.indexOf(warehouseDropDown[warehouseDropDown.selectedIndex].text) >= 0)
                {
                    BinDropDown.selectedIndex = x;
                    var test = 1;
                }        
            } 
            
            PO_Submit(HDnumberID, BinDropDownID, PiecesTextBoxID,poDropDownID,HDSelectedRButtonID,pices_error_LableID,pending_PiecesID);
            var test = 1;

        }
    }
   
   var test = 1;
}


//--------------- Error handler and time out for all services -------------------
function TimeOutHandler(result)
{
    alert("Timeout :" + result);
}

function ErrorHandler(result)
{
    var msg=result.get_exceptionType() + "\r\n";
    msg += result.get_message() + "\r\n";
    msg += result.get_stackTrace();
    alert(msg);
}

function setTabStatus(containerID,activeTab)
{
	var obj = parent.document.getElementById(containerID);
	if (obj!= null)
	{
	    var aTab = obj.getElementsByTagName('a');
	    for( var x = 0; x < aTab.length; x++ ) 
	    {
			if(aTab[x].tagName.toLowerCase() == 'a')
			{
			    aTab[x].className='tab';
			}			
		}
		activeTab.className='tabActive';
	}
}


var TimeToFade = 1000.0;

function fade(eid)
{
    var element = document.getElementById(eid);
    if(element == null)
        return;

    if(element.FadeState == null)
    {
    if(element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1')
        {
          element.FadeState = 2;
        }
        else
        {
          element.FadeState = -2;
        }
    }

    if(element.FadeState == 1 || element.FadeState == -1)
    {
        element.FadeState = element.FadeState == 1 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }
    else
    {
        element.FadeState = element.FadeState == 2 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade;
        setTimeout("animateFade(" + new Date().getTime()+ ",'" + eid + "')", 33);
    } 
}

function animateFade(lastTick, eid)
{ 
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;

    var element = document.getElementById(eid);

    if(element.FadeTimeLeft <= elapsedTicks)
    {
        element.style.opacity = element.FadeState == 1 ? '1' : '0';
        element.style.filter = 'alpha(opacity = '+ (element.FadeState == 1 ? '100' : '0') + ')';
        element.FadeState = element.FadeState == 1 ? 2 : -2;
        return;
    }

    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft/TimeToFade;
    if(element.FadeState == 1)
        newOpVal = 1 - newOpVal;

    element.style.opacity = newOpVal;
    element.style.filter ='alpha(opacity = ' + (newOpVal*100) + ')';

    setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}

function submitForm(formID)
{
	var objHd = parent.document.getElementById(formID);
	if (objHd != null)
	{
		objHd.submit();
	}
}

function setNavBackgroundColor(objectId, color)
{
	var obj = parent.document.getElementById(objectId);
    if (obj != null)
	{
	   setBackgroundColor(obj, color);
	}
}

function changeClass(objectId,myClass) 
{ 
  var obj = document.getElementById(objectId); 
    if (obj != null)
    {
        obj.className = myClass; 
    }
} 
//---------- front news area start ---------------
function setVisibilityFalseAll()
{
    for (var x = 1; x < totalItems; x++)
    {
        setVisibilityVal("Arrow_Image_span_"+x,"none");
        setVisibilityVal("text_div_"+x,"none");
        setVisibilityVal("Lg_Image_div_"+x,"none");
        setVisibilityVal("link_div_"+x,"none");
        setBorderColor("image_div_"+x,"#CCCCCC");
        //setVisibilityVal("main_div_"+x,"none");
    }

    for (var x = startItems; x < totalItems; x++)
    {
        setVisibilityVal("Arrow_Image_span_spacer_"+x,"block");
    }
}

function setVisibilityTrue(ItemNumber)
{
    setVisibilityVal("image_div"+ItemNumber,"block");
    setVisibilityVal("Arrow_Image_span_"+ItemNumber,"block");
    setVisibilityVal("text_div_"+ItemNumber,"block");
    setVisibilityVal("Lg_Image_div_"+ItemNumber,"block");
    setVisibilityVal("link_div_"+ItemNumber,"block");
    setVisibilityVal("Arrow_Image_span_spacer_"+ItemNumber,"none");
    setBorderColor("image_div_"+ItemNumber, "#FF6600");
}

function setBorderColor(objectId, color)
{
    var obj = parent.document.getElementById(objectId);
    if (obj != null)
    {
        obj.style.borderColor = color;
    }
}

function display(number)
{
    if (number == totalItems || number >= maxItems)
        number = startItems;

    setVisibilityFalseAll();
    setVisibilityTrue(number);
    number++;
    t=setTimeout("display(" + number + ")",3000) ;
}

function stopCount()
{
    clearTimeout(t);
}

function moveNext()
{
    //alert("maxItems: "+maxItems+" totalItems:"+totalItems);
    if (maxItems >= totalItems && totalItems < 17)//
    {
        clearTimeout(t);
        for (var x = startItems; x < totalItems; x++)
        {
            setVisibilityVal("main_div_"+x,"none");
            setVisibilityVal("image_div_"+x,"none"); 
            setVisibilityVal("Arrow_Image_span_spacer_"+x,"none");
        }
       
        startItems = startItems + 1 ;
        totalItems = totalItems + 1;
        
        for (var x = startItems; x < totalItems; x++)
        {
            setVisibilityVal("image_div_"+x,"block");
            setVisibilityVal("Arrow_Image_span_spacer_"+x,"block");
            setVisibilityVal("main_div_"+x,"block");
        }
        if(0 < startItems )
        {
            setVisibilityVal("arrowLeft","block"); 
            setVisibilityVal("no_arrowLeft","none"); 
        }
        
        if(maxItems < totalItems || totalItems > 17 )
        {
            setVisibilityVal("arrowRight","none"); 
            setVisibilityVal("no_arrowRight","block"); 
        }
        display(startItems)
        return false;
    }
}

function movePrev()
{
    if (0 < startItems - 1)
    {
        clearTimeout(t);
        setVisibilityFalseAll()
        for (var x = startItems; x < totalItems; x++)
        {
            setVisibilityVal("main_div_"+x,"none");        
            setVisibilityVal("image_div_"+x,"none"); 
            setVisibilityVal("Arrow_Image_span_spacer_"+x,"none");
        }
       
        startItems = startItems - 1 ;
        totalItems = totalItems - 1;
        
        for (var x = startItems; x < totalItems; x++)
        {
            setVisibilityVal("image_div_"+x,"block");
            setVisibilityVal("Arrow_Image_span_spacer_"+x,"block");
            setVisibilityVal("main_div_"+x,"block");
        }
        
        if(1 > startItems - 1)
        {
            setVisibilityVal("arrowLeft","none"); 
            setVisibilityVal("no_arrowLeft","block"); 
        }
        
        if(maxItems > totalItems || totalItems < 17 )
        {
            setVisibilityVal("arrowRight","block"); 
            setVisibilityVal("no_arrowRight","none"); 
        }
        display(startItems)
        return false;
    }
}
//---------- front news area end ---------------


function get_check_value(checkBoxName)
{
    var c_value = "";
    var checkBoxObj = parent.document.getElementsByName(checkBoxName);

    for (var i=0; i < checkBoxObj.length; i++)
    {
        if (checkBoxObj[i].checked)
        {
            if (c_value != "")
            {
                c_value =c_value +",";
            }
            c_value = c_value + checkBoxObj[i].value ;
        }
    }
    //alert(c_value);
    return c_value;
}

