﻿function CheckFieldLength(nField,nMaxSize,evt)
{
     if(nField.value.length>nMaxSize && evt.keyCode!=8 && evt.keyCode!=32 && evt.keyCode!=46){alert('Content exceeds length allowed');nField.focus();nField.value = nField.value.substring(0,nMaxSize+1);evt.returnValue = false;}
} 

function CheckOnPaste(nField,nMaxSize,evt)
{
      doPaste(nField,nMaxSize)
}

var detect = navigator.userAgent.toLowerCase();
function doPaste(obj,maxLength)
{
     if(maxLength)
     {
        if ((window.event) && (detect.indexOf("safari") + 1 == 0)) 
	    { //IE
          var oTR = obj.document.selection.createRange();
          var iInsertLength = maxLength - obj.value.length + oTR.text.length;
		  try 
		  {
              var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
              oTR.text = sData;
		  }
		  catch (err) 
		  {
		  }
          if (window.event) 
          { //IE
			window.event.returnValue = null;
	      } 
	      else 
	      {
			//not IE
			obj.value = obj.value.substr(0,maxLength);
            alert('Content exceeds length allowed');
			return false;
		  }
		}
	 }
}

function changeAction(ctlDropDownID,txtGearID,aValue)
{
    
    ctlGear = document.getElementById(ctlDropDownID);
    txtGear = document.getElementById(txtGearID);
    
   
    
    if(ctlGear.options[parseInt(aValue)+1].text!='Other')
        txtGear.style.display='none';
    else
        txtGear.style.display='inline';
}

function changeAction1(ctlDropDownID1,txtGearID1,aValue1)
{
    
    ctlGear1 = document.getElementById(ctlDropDownID1);
    txtGear1 = document.getElementById(txtGearID1);
    
   
   
    if(aValue1!='5')
        txtGear1.style.display='none';
    else
        txtGear1.style.display='inline';
}



function CallPrint(strid,docName)
{     
    var strpre = "<html><head><script language='JavaScript' src='../js/global.js'></script><script type='text/javascript' src='../js/traceability.js'></script>" + 
                 "<link href='../style/style.css' rel='stylesheet' type='text/css' /><link href='../css/register.css' rel='stylesheet' type='text/css' /><script type='text/javascript' src='../../RadControls/Calendar/Scripts/2_2_1/RadCalendar.js'></script>" +
                 "<script type='text/javascript' src='../../RadControls/Input/Scripts/2_1_1/RadInput.js'></script><script type='text/javascript' src='../../RadControls/Input/Scripts/2_1_1/RadDateInput.js'></script>" +
                 "<script language='javascript'>function silentErrorHandler() {return true;}window.onerror=silentErrorHandler;</script><title>Print: "+docName+"</title></head><body style='background-color:#FFFFFF;'>";
    var strpost = "</body></html>";
    
    
    var prtContent = document.getElementById(strid);
    var strOldOne=prtContent.innerHTML;
    var WinPrint = window.open(document.location, '', 'left=100,top=100,width=1000,height=600,toolbar=0,scrollbars=1,status=0');
    var s = "<table cellpadding='0' cellspacing='0' border='0' class='ContentRegion1WithoutPadding' width='100%'><tr><td class='TitleBar_1'>Review and submit</td></tr></table>" + strpre + prtContent.innerHTML + strpost;
    //WinPrint.document.write(prtContent.innerHTML);
    WinPrint.document.write(s);
    var browser=navigator.appName;
    if (browser=="Microsoft Internet Explorer")
        WinPrint.document.close();

    WinPrint.focus(); 
    WinPrint.print(); 
    //WinPrint.close();
    if (browser=="Netscape")
        WinPrint.document.close();
    prtContent.innerHTML = strOldOne;
    
    
}

function CallPrintAdmin(strid)
{     
    var strpre = "<html><head><script language='JavaScript' src='../../Client/js/global.js'></script><script type='text/javascript' src='../../Client/js/traceability.js'></script>" + 
                 "<link href='../../Client/style/style.css' rel='stylesheet' type='text/css' /><script type='text/javascript' src='../../RadControls/Calendar/Scripts/2_2_1/RadCalendar.js'></script>" +
                 "<script type='text/javascript' src='../../RadControls/Input/Scripts/2_1_1/RadInput.js'></script><script type='text/javascript' src='../../RadControls/Input/Scripts/2_1_1/RadDateInput.js'></script>" +
                 "<script language='javascript'>function silentErrorHandler() {return true;}window.onerror=silentErrorHandler;</script></head><body style='background-color:#FFFFFF;'>";
    var strpost = "</body></html>";
    
    var prtContent = document.getElementById(strid);
    var strOldOne=prtContent.innerHTML;
    var WinPrint = window.open(document.location, '', 'left=100,top=100,width=1000,height=600,toolbar=0,scrollbars=1,status=0'); 
    var s = strpre + prtContent.innerHTML + strpost;
    //WinPrint.document.write(prtContent.innerHTML);
    WinPrint.document.write(s);
    var browser=navigator.appName;
    if (browser=="Microsoft Internet Explorer")
        WinPrint.document.close();

    WinPrint.focus(); 
    WinPrint.print(); 
    //WinPrint.close();
    if (browser=="Netscape")
        WinPrint.document.close();
    prtContent.innerHTML = strOldOne;
    
    
}

function OpenPrintPage(strid)
{     
   window.open(strid,'PagePrint','left=100,top=100,width=1000,height=600,toolbar=0,scrollbars=1,status=0');     
}


function CallPrintBorder(docName)
{
    //document.getElementById("divHeader_ForPrint").style.fontWeight= "bold";
    //document.getElementById("divHeader_ForPrint").style.fontSize= "18px";
    SetBorder(document.getElementById("divDetail1_ForPrint"));
    SetBorder(document.getElementById("divDetail2_ForPrint"));
    SetBorder(document.getElementById("divDetail3_ForPrint"));
    SetBorder(document.getElementById("divDetail4_ForPrint"));
    SetBorder(document.getElementById("divDetail5_ForPrint"));
    SetBorder(document.getElementById("divDetail6_ForPrint"));
    SetBorder(document.getElementById("divDetail7_ForPrint"));
    SetBorder(document.getElementById("divDetail8_ForPrint"));
    SetBorder(document.getElementById("divDetail9_ForPrint"));
    SetBorder(document.getElementById("divDetail10_ForPrint"));
    SetBorder(document.getElementById("divDetail11_ForPrint"));
    if(document.getElementById("divCmdBtn") != null)
    document.getElementById("divCmdBtn").style.display = "none";
    
    CallPrint('divPrint',docName);
    
    ReSetBorder(document.getElementById("divDetail1_ForPrint"));
    ReSetBorder(document.getElementById("divDetail2_ForPrint"));
    ReSetBorder(document.getElementById("divDetail3_ForPrint"));
    ReSetBorder(document.getElementById("divDetail4_ForPrint"));
    ReSetBorder(document.getElementById("divDetail5_ForPrint"));
    ReSetBorder(document.getElementById("divDetail6_ForPrint"));
    ReSetBorder(document.getElementById("divDetail7_ForPrint"));
    ReSetBorder(document.getElementById("divDetail8_ForPrint"));
    ReSetBorder(document.getElementById("divDetail9_ForPrint"));
    ReSetBorder(document.getElementById("divDetail10_ForPrint"));
    ReSetBorder(document.getElementById("divDetail11_ForPrint"));
    //document.getElementById("divHeader_ForPrint").style.fontSize= "14px";
    if(document.getElementById("divCmdBtn") != null)
    document.getElementById("divCmdBtn").style.display = "block";
    
    return false;
    
}

function SetBorder(oTarget)
{
    if(oTarget != null)
    {
        oTarget.style.border = "2px solid";
        oTarget.style.width = "970px";
    }
}

function ReSetBorder(oTarget)
{
    if(oTarget != null)
    {
        oTarget.style.border = "";
        oTarget.style.width = "";
    }
}
   
   
function Validate_FileType(sender, args)
      {
        args.IsValid = CheckForTestFile(sender.controltovalidate);
      }
        
             //Trim the input text
      function Trim(input)
      {
        var lre = /^\s*/; 
        var rre = /\s*$/; 
        input = input.replace(lre, ""); 
        input = input.replace(rre, ""); 
        return input; 
       }
     
       // filter the files before Uploading for text file only  
       function CheckForTestFile(objFU) 
       {
            //var file = document.getElementById('<=fileDocument.ClientID%>');
            var file = document.getElementById(objFU);
            var fileName=file.value;        
            //Checking for file browsed or not 
            if (Trim(fileName) =='' )
            {
                return true;
            }
     
           //Setting the extension array for diff. type of text files
            //var extArray = new Array(".doc,.docx,.pdf,.rtf,.txt,.wpd,.wk4,.xls,.xlsx,.gif,.jpg,.psd,.tif,.mov,.mp4,.mpg,.qt,.swf,.wmv,.zip,.rar");       
            var extArray = new Array(".doc", ".docx", ".pdf", ".rtf", ".txt", ".wpd", ".wk4", ".xls", ".xlsx", ".gif", ".jpg", ".psd", ".tif", ".mov", ".mp4", ".mpg",".qt",".swf",".wmv",".zip",".rar");
           //getting the file name
           while (fileName.indexOf("\\") != -1)
             fileName = fileName.slice(fileName.indexOf("\\") + 1);
     
           //Getting the file extension                     
           var ext = fileName.slice(fileName.indexOf(".")).toLowerCase();
     
           //matching extension with our given extensions.
           for (var i = 0; i < extArray.length; i++) 
           {
             if (extArray[i] == ext) 
             { 
               return true;
             }
           }  
           return false;                
       }      
    
    
function doBeforePaste(control)
{
   maxLength = control.attributes["maxLength"].value;
   if(maxLength)
   {
       event.returnValue = false;
   }
}
function doPaste(control)
{
   maxLength=null;
   if(control.attributes["maxLength"]!=null)
        maxLength = control.attributes["maxLength"].value;  
    
   value = control.value;
   if(maxLength!=null){
        event.returnValue = false;
        maxLength = parseInt(maxLength);
        var o = control.document.selection.createRange();
        var iInsertLength = maxLength - value.length + o.text.length;
        var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
        o.text = sData;
    }
}
function LimitInput(control,maxlenght)
{
    //maxLength = control.attributes["maxLength"].value;
    if(control.value.length > maxLength )
        {
        //control.focus();
        alert('Content exceeds length allowed');
        control.value = control.value.substring(0,maxLength + 1);
        control.focus();
        }
    
}

// Number Format Function
function ApRnd(X, M, N, Z) 
{
    var J, R, S;
    var K = 1;
    if (!M) 
    {
        M = 1;
    }
    if (!N) 
    {
        N = 2;
    }
    if (!Z) 
    {
        Z = 0;
    }
    if (X == null || X == undefined) 
    {
        return SpcsTo(X, M + N + 1);
    }
    J = Math.round(X * Math.pow(10, N + K));
    if (Z == 2) 
    {
        Z = J % 20 == 5 ? 1 : 9;
    }
    S = String(J + Z);
    if (/\D/.test(S)) 
    {
        return SpcsTo(X, M + N + 1);
    }
    R = new RegExp("(.{" + N + "}).{" + K + "}$");
    return PrfxTo(S, M + N + 1, "0").replace(R, ".$1");
}

function ApRnd1(X, M, N) 
{
    return ApRnd(X, M, N, 0);
}

function ApRnd2(X, M, N) 
{
    return ApRnd(X, M, N, 5);
}

function ApRnd3(X, M, N) 
{
    return ApRnd(X, M, N, 2);
}

function Format(obj, precision)
{
    obj.value = ApRnd1(obj.value,0,precision);
}

function Sign(X) 
{
    return X > 0 ? "+" : X < 0 ? "-" : " ";
}

function PrfxTo(S, L, C) 
{
    S += "";
    if (C.length > 0) 
    {
        while (S.length < L) {
            S = C + S;
        }
    }
    return S;
}

function SpcsTo(S, L) 
{
    S += "";
    while (S.length < L) 
    {
        S = " " + S;
    }
    return S;
}

function StrU(X, M, N) 
{
    var St = String(Math.round(X * Math.pow(10, N)));
    if (/\D/.test(St)) {
        return SpcsTo(X, M + N + 1);
    }
    St = PrfxTo(St, M + N, "0");
    var J = St.length - N;
    return St.substring(0, J) + "." + St.substring(J);
}

function StrS(X, M, N) {
    return Sign(X) + StrU(Math.abs(X), M, N);
}

function StrT(X, M, N) {
    return SpcsTo(StrU(X, 1, N), M + N + 2);
}

function StrW(X, M, N) {
    return SpcsTo(StrS(X, 1, N), M + N + 2);
}  
    
 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

   function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  
  // Number/Currency Format Function
function CurrencyFormatted(Amount,noOfCharacterAfterDecimal,FormaterSeperator,RupeeAndPaiseSeperator)
{
    amt = new String(EngCultureFormatted(Amount,noOfCharacterAfterDecimal,FormaterSeperator,RupeeAndPaiseSeperator));
	var i = parseFloat(amt);

	/*************************************/
	
	if(isNaN(i)) { i = 0.00; }
	
	/*************************************/
	
	var minus = '';
	if(i < 0) { minus = '-'; }
	
	/*************************************/
	
	var mul = "1";
	var mul1 = ".";
	var dig = noOfCharacterAfterDecimal;
	while(dig > 0)
	{
	    mul +="0";
	    mul1 +="0";
	    dig -=1;
	}	
	mul1 +="5";
	
	/*************************************/	
	
	i = Math.abs(i);
	i = parseInt((i + parseFloat(mul1)) * parseInt(mul));
	i = i / parseInt(mul);
    
    /*************************************/
    
	s = new String(i);
	if(s.indexOf('.') < 0) 
	{ 
	    s += ".";
	    var digit = noOfCharacterAfterDecimal;
	    while (0 < digit) 
	    {
            s += "0";
            digit -=1;
        }
	}
	if(s.indexOf('.') == (s.length - noOfCharacterAfterDecimal)) { s += '0'; }
	s = minus + s;
	
	s = CommaFormatted(s,noOfCharacterAfterDecimal,FormaterSeperator,RupeeAndPaiseSeperator);
	return s;
}
function CommaFormatted(amount,noOfCharacterAfterDecimal,FormaterSeperator,RupeeAndPaiseSeperator)
{
	var delimiter = FormaterSeperator;
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + RupeeAndPaiseSeperator + d; }
	amount = minus + amount;
	return amount;
}
function EngCultureFormatted(Amount,noOfCharacterAfterDecimal,FormaterSeperator,RupeeAndPaiseSeperator)
{     
    amt = new String(Amount);  
    while(amt.indexOf(' ')>0)
    {
        amt = amt.substr(0,amt.indexOf(' ')) + amt.substr(amt.indexOf(' ')+1,amt.length-amt.indexOf(' '));
    }
    while(amt.indexOf(FormaterSeperator)>0)
    {
        amt = amt.substr(0,amt.indexOf(FormaterSeperator)) + amt.substr(amt.indexOf(FormaterSeperator)+1,amt.length-amt.indexOf(FormaterSeperator));
    }    
    if(RupeeAndPaiseSeperator==",")
        amt = amt.replace(",",".");
	return amt;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////

function SizeTypeEnableDisable(type, radiobuttonid, Index, IsRequestForOffer)
{

    var radioname = "";
    
    if(type==1)
        radioname="rbUnsized";
    else if(type==2)
        radioname="rbSingleSize";
    else if(type==3)
        radioname = "rbSizeRange";

    var SingleValueTextBox = document.getElementById(radiobuttonid.replace(radioname,"txtSingleSizeValue"));
    var SingleValueDropDown = document.getElementById(radiobuttonid.replace(radioname,"ddlProductSizeUnit"));
    var SingleOther = document.getElementById(radiobuttonid.replace(radioname,"txtSingleSizeOther"));

    var FromValueTextBox = document.getElementById(radiobuttonid.replace(radioname,"FromTextBox"));
    var ToValueTextBox = document.getElementById(radiobuttonid.replace(radioname,"ToTextBox"));
    var RangeValueDropDown = document.getElementById(radiobuttonid.replace(radioname,"UnitDropDownList"));
    var RangeOther = document.getElementById(radiobuttonid.replace(radioname,"ctlFromToOther"));
    
    //var rowForSize11 = document.getElementById("rowForSize11_"+Index);
    //var rowForSize12 = document.getElementById("rowForSize12_"+Index);
    
    var rowForSize21 = document.getElementById("rowForSize21_"+Index);
    //var rowForSize22 = document.getElementById("rowForSize22_"+Index);
    //var rowForSize23 = document.getElementById("rowForSize23_"+Index);
    //var rowForSize24 = document.getElementById("rowForSize24_"+Index);
    
    var DivForSize11 = document.getElementById("DivForSize11_"+Index);
    var DivForSize21 = document.getElementById("DivForSize21_"+Index);
    var DivForSize22 = document.getElementById("DivForSize22_"+Index);

    if (type <= 0) {

        DivForSize11.style.display = 'none';
        DivForSize21.style.display = 'none';
        DivForSize22.style.display = 'none';
        return;
    }
    if(SingleValueTextBox!=null)
    {
//        SingleValueTextBox.disabled=true;
//        SingleValueDropDown.disabled=true;
//        SingleOther.disabled=true;

//        FromValueTextBox.disabled=true;
//        ToValueTextBox.disabled=true;
//        RangeValueDropDown.disabled=true;
//        RangeOther.disabled=true;

        
        //rowForSize11.style.display='none';
        //rowForSize12.style.display='none';

       // rowForSize21.style.display='none';
//        rowForSize22.style.display='none';
//        rowForSize23.style.display='none';
//        rowForSize24.style.display='none';
        
        DivForSize11.style.display='none';
        DivForSize21.style.display='none';
        DivForSize22.style.display='none';


        if(type==1)
        {
            SingleValueTextBox.value="";
            SingleValueDropDown.selectedIndex=0;
            SingleOther.value="";
            FromValueTextBox.value="";
            ToValueTextBox.value="";
            RangeValueDropDown.selectedIndex=0;
            RangeOther.value="";
        }
        else if(type==2)
        {
            FromValueTextBox.value="";
            ToValueTextBox.value="";
            RangeValueDropDown.selectedIndex=0;
            RangeOther.value="";

            //SingleValueTextBox.disabled=false;
            //SingleValueDropDown.disabled=false;
            //SingleOther.disabled=false;  
            
            //rowForSize11.style.display='';
            //rowForSize12.style.display='';
            DivForSize11.style.display='';
              

        } 
        else if(type==3)
        {
        
        
            SingleValueTextBox.value="";
            SingleValueDropDown.selectedIndex=0;
            SingleOther.value="";
            
            //FromValueTextBox.disabled=false;
            //ToValueTextBox.disabled=false;
            //RangeValueDropDown.disabled=false;
            //RangeOther.disabled=false;
            
            //rowForSize21.style.display='';
//            rowForSize22.style.display='';
//            rowForSize23.style.display='';
//            rowForSize24.style.display='';
            
             DivForSize21.style.display='';
             DivForSize22.style.display='';
         }

//         if (IsRequestForOffer) {

//             if (SingleValueTextBox.value != '') {
//                 SingleValueTextBox.disabled = true;
//                 SingleValueDropDown.disabled = true;
//                 SingleOther.disabled = true;
//             }
//             else {
//                 SingleValueTextBox.disabled = false;
//                 SingleValueDropDown.disabled = false;
//                 SingleOther.disabled = false;
//             }

//             if (FromValueTextBox.value != '') {
//                 FromValueTextBox.disabled = true;
//                 ToValueTextBox.disabled = true;
//                 RangeValueDropDown.disabled = true;
//                 RangeOther.disabled = true;
//             }
//             else {
//                 FromValueTextBox.disabled = false;
//                 ToValueTextBox.disabled = false;
//                 RangeValueDropDown.disabled = false;
//                 RangeOther.disabled = false;
//             }
//         }
     }
}
/////////////////////////////////////////////////////////////////////////////////////

function SizeTypeEnableDisable_Unpriced(type, radiobuttonid, Index, IsRequestForOffer) {

    var radioname = "";
    
    if (type == 1)
        radioname = "chkUnsized";
    else if (type == 2)
        radioname = "chkSingleSize";
    else if(type==3)
        radioname = "chkSizeRange";


   
    var chkbox = document.getElementById(radiobuttonid);
    if (chkbox.checked == true) {

        var SingleValueTextBox = document.getElementById(radiobuttonid.replace(radioname, "txtSingleSizeValue"));
        var SingleValueDropDown = document.getElementById(radiobuttonid.replace(radioname, "ddlProductSizeUnit"));
        var SingleOther = document.getElementById(radiobuttonid.replace(radioname, "txtSingleSizeOther"));

        var FromValueTextBox = document.getElementById(radiobuttonid.replace(radioname, "FromTextBox"));
        var ToValueTextBox = document.getElementById(radiobuttonid.replace(radioname, "ToTextBox"));
        var RangeValueDropDown = document.getElementById(radiobuttonid.replace(radioname, "UnitDropDownList"));
        var RangeOther = document.getElementById(radiobuttonid.replace(radioname, "ctlFromToOther"));

        //var rowForSize11 = document.getElementById("rowForSize11_"+Index);
        //var rowForSize12 = document.getElementById("rowForSize12_"+Index);

        var rowForSize21 = document.getElementById("rowForSize21_" + Index);
        //var rowForSize22 = document.getElementById("rowForSize22_"+Index);
        //var rowForSize23 = document.getElementById("rowForSize23_"+Index);
        //var rowForSize24 = document.getElementById("rowForSize24_"+Index);

        var DivForSize11 = document.getElementById("DivForSize11_" + Index);
        var DivForSize21 = document.getElementById("DivForSize21_" + Index);
        var DivForSize22 = document.getElementById("DivForSize22_" + Index);

        if (type <= 0) {

            DivForSize11.style.display = 'none';
            DivForSize21.style.display = 'none';
            DivForSize22.style.display = 'none';
            return;
        }

        if (SingleValueTextBox != null) {
            //SingleValueTextBox.disabled = true;
            //SingleValueDropDown.disabled = true;
            //SingleOther.disabled = true;

            //FromValueTextBox.disabled = true;
            //ToValueTextBox.disabled = true;
            //RangeValueDropDown.disabled = true;
            //RangeOther.disabled = true;

            //rowForSize11.style.display='none';
            //rowForSize12.style.display='none';

            // rowForSize21.style.display='none';
            //        rowForSize22.style.display='none';
            //        rowForSize23.style.display='none';
            //        rowForSize24.style.display='none';

            DivForSize11.style.display = 'none';
            DivForSize21.style.display = 'none';
            DivForSize22.style.display = 'none';



            if (type == 1) {
                SingleValueTextBox.value = "";
                SingleValueDropDown.selectedIndex = 0;
                SingleOther.value = "";
                FromValueTextBox.value = "";
                ToValueTextBox.value = "";
                RangeValueDropDown.selectedIndex = 0;
                RangeOther.value = "";
                document.getElementById(radiobuttonid.replace(radioname, "chkSingleSize")).checked = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkSizeRange")).checked = false;
            }
            else if (type == 2) {
                FromValueTextBox.value = "";
                ToValueTextBox.value = "";
                RangeValueDropDown.selectedIndex = 0;
                RangeOther.value = "";

                //SingleValueTextBox.disabled = false;
                //SingleValueDropDown.disabled = false;
                //SingleOther.disabled = false;

                //rowForSize11.style.display='';
                //rowForSize12.style.display='';
                DivForSize11.style.display = '';
                document.getElementById(radiobuttonid.replace(radioname, "chkUnsized")).checked = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkSizeRange")).checked = false;

            }
            else if (type==3)
            {
                SingleValueTextBox.value = "";
                SingleValueDropDown.selectedIndex = 0;
                SingleOther.value = "";

                //FromValueTextBox.disabled = false;
               // ToValueTextBox.disabled = false;
               // RangeValueDropDown.disabled = false;
               // RangeOther.disabled = false;

                //rowForSize21.style.display='';
                //            rowForSize22.style.display='';
                //            rowForSize23.style.display='';
                //            rowForSize24.style.display='';

                DivForSize21.style.display = '';
                DivForSize22.style.display = '';
                document.getElementById(radiobuttonid.replace(radioname, "chkUnsized")).checked = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkSingleSize")).checked = false;
            }
//            if (IsRequestForOffer) {
//                SingleValueTextBox.disabled = true;
//                SingleValueDropDown.disabled = true;
//                SingleOther.disabled = true;
//                FromValueTextBox.disabled = true;
//                ToValueTextBox.disabled = true;
//                RangeValueDropDown.disabled = true;
//                RangeOther.disabled = true;

//            }
        }
    }
    else {

        var SingleValueTextBox = document.getElementById(radiobuttonid.replace(radioname, "txtSingleSizeValue"));
        var SingleValueDropDown = document.getElementById(radiobuttonid.replace(radioname, "ddlProductSizeUnit"));
        var SingleOther = document.getElementById(radiobuttonid.replace(radioname, "txtSingleSizeOther"));

        var FromValueTextBox = document.getElementById(radiobuttonid.replace(radioname, "FromTextBox"));
        var ToValueTextBox = document.getElementById(radiobuttonid.replace(radioname, "ToTextBox"));
        var RangeValueDropDown = document.getElementById(radiobuttonid.replace(radioname, "UnitDropDownList"));
        var RangeOther = document.getElementById(radiobuttonid.replace(radioname, "ctlFromToOther"));

        var rowForSize21 = document.getElementById("rowForSize21_" + Index);

        var DivForSize11 = document.getElementById("DivForSize11_" + Index);
        var DivForSize21 = document.getElementById("DivForSize21_" + Index);
        var DivForSize22 = document.getElementById("DivForSize22_" + Index);
        if (type <= 0) {

            DivForSize11.style.display = 'none';
            DivForSize21.style.display = 'none';
            DivForSize22.style.display = 'none';
            return;
        }

        if (SingleValueTextBox != null) {
            //SingleValueTextBox.disabled = true;
            //SingleValueDropDown.disabled = true;
            //SingleOther.disabled = true;

            //FromValueTextBox.disabled = true;
            //ToValueTextBox.disabled = true;
            //RangeValueDropDown.disabled = true;
           //RangeOther.disabled = true;

            DivForSize11.style.display = 'none';
            DivForSize21.style.display = 'none';
            DivForSize22.style.display = 'none';



            if (type == 1) {
                SingleValueTextBox.value = "";
                SingleValueDropDown.selectedIndex = 0;
                SingleOther.value = "";
                FromValueTextBox.value = "";
                ToValueTextBox.value = "";
                RangeValueDropDown.selectedIndex = 0;
                RangeOther.value = "";
                document.getElementById(radiobuttonid.replace(radioname, "chkSingleSize")).checked = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkSizeRange")).checked = false;
            }
            else if (type == 2) {
                FromValueTextBox.value = "";
                ToValueTextBox.value = "";
                RangeValueDropDown.selectedIndex = 0;
                RangeOther.value = "";

                //SingleValueTextBox.disabled = false;
                //SingleValueDropDown.disabled = false;
                //SingleOther.disabled = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkUnsized")).checked = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkSizeRange")).checked = false;

            }
            else if(type==3)
            {
                SingleValueTextBox.value = "";
                SingleValueDropDown.selectedIndex = 0;
                SingleOther.value = "";

                //FromValueTextBox.disabled = false;
                //ToValueTextBox.disabled = false;
                //RangeValueDropDown.disabled = false;
                //RangeOther.disabled = false;


                document.getElementById(radiobuttonid.replace(radioname, "chkUnsized")).checked = false;
                document.getElementById(radiobuttonid.replace(radioname, "chkSingleSize")).checked = false;
            }
//            if (IsRequestForOffer) {
//                //SingleValueTextBox.disabled = true;
//                //SingleValueDropDown.disabled = true;
//                //SingleOther.disabled = true;
//                //FromValueTextBox.disabled = true;
//                //ToValueTextBox.disabled = true;
//                //RangeValueDropDown.disabled = true;
//                //RangeOther.disabled = true;

//            }
        }
    }
}






////////////////////////////////////////////////////////////////////////////////////////

function EnableDisableIsBulk(control)
{
    divid = document.getElementById("divPackagingDetail1");
    divComments = document.getElementById("divPackagingComments");
    var checkbox;
    if(control.id != null)
        checkbox = document.getElementById(control.id);
    else
        checkbox = document.getElementById(control);

    if(checkbox != null)  
    {  
        if(checkbox.checked)
        {
            var textboxes = divid.getElementsByTagName("input");
            for (var i = 0; i < textboxes.length; i++) 
            {   
                textboxes[i].disabled = true;
            }
            var textareas = divid.getElementsByTagName("textarea");
            for (var i = 0; i < textareas.length; i++) 
            {   
                textareas[i].disabled = true;
            }   
            var selects = divid.getElementsByTagName("select");
            for (var i = 0; i < selects.length; i++) 
            {   
                selects[i].disabled = true;
            }
            textareas = divComments.getElementsByTagName("textarea");
            for (var i = 0; i < textareas.length; i++) 
            {   
                textareas[i].disabled = true;
            }
        }
        else
        {
           var textboxes = divid.getElementsByTagName("input");
            for (var i = 0; i < textboxes.length; i++) 
            {   
                textboxes[i].disabled = false;
            }
            var textareas = divid.getElementsByTagName("textarea");
            for (var i = 0; i < textareas.length; i++) 
            {   
                textareas[i].disabled = false;
            }   
            var selects = divid.getElementsByTagName("select");
            for (var i = 0; i < selects.length; i++) 
            {   
                selects[i].disabled = false;
            }
            textareas = divComments.getElementsByTagName("textarea");
            for (var i = 0; i < textareas.length; i++) 
            {   
                textareas[i].disabled = false;
            }
        }
    }

}

function ToggleInput(check,txtbox) {
    var txt = document.getElementById(txtbox);
    txt.disabled = !(check.checked);
    if (!check.checked)
        txt.value = '';
}
