﻿// JScript File





//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function donothing()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function SelectAllCheckboxes(spanChk)
{
    // Added as ASPX uses SPAN for checkbox
    var oItem = spanChk.children;
    var theBox= (spanChk.type=="checkbox") ? spanChk : spanChk.children.item[0];
    xState=theBox.checked;
    elm=theBox.form.elements;

    for(i=0;i<elm.length;i++)
     if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
     {
       if(elm[i].checked!=xState)
         elm[i].click();
     }
}


 function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal)
 {
  re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon
  elm = document.forms[0].elements[i]
  
  for(i = 0; i < elm.length; i++)
  {
   if (elm.type == 'checkbox')
   {
    if (re.test(elm.name))
     elm.checked = checkVal
   }
  }
 }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function DisableTextBox(CheckBox,TextBoxName)
{
    if(document.getElementById)
    {
        var obj = document.getElementById(TextBoxName);
        if (CheckBox.checked == true)
        {
            obj.value='';
            obj.disabled = true;
        }
        else { obj.disabled = false; }
    }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Allows only numeric values to be entered into the Textbox
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function AllowNumeric(textbox)
{
    if(textbox.value.indexOf('.') != -1)
    {
        //ascii code for '.'
        if(event.keyCode == 46){return false;}
        else{return true;}
    }
}

function AllowNumeric(textbox,numbertype)
{
   var bool = true;
   switch(numbertype)
    {
        //Whole Number 
        case 1:
            if(event.keyCode >= 48 && event.keyCode <= 57) {bool = true;}
            else{bool = false;}
        break;

        //Decimal
        case 2:
           if((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 46) {bool = true;}
           else{bool = false;}
           
           if(bool)
           {
                if(textbox.value.indexOf('.') != -1)
                {
                    //ascii code for '.'
                    if(event.keyCode == 46){bool = false;}
                    else { bool = true; }
                }
                else{bool=true;}
            }
        break;   
   }
   
   return bool;
} 


function AllowNumeric(textbox,numbertype,numberofdecimals)
{
   var bool = true;
   switch(numbertype)
    {
        //Whole Number 
        case 1:
            if(event.keyCode >= 48 && event.keyCode <= 57) {bool = true;}
            else{bool = false;}
        break;

        //Decimal
        case 2:
           if((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 46) {bool = true;}
           else{bool = false;}
           
           if(bool)
           {
                if(textbox.value.indexOf('.') != -1)
                {
                    //ascii code for '.'
                    if(event.keyCode == 46){bool = false;}
                    else if (numberofdecimals > 0)
                    {
                        var indexofDecimal = textbox.value.indexOf('.');
                        var textLength = textbox.value.length;
                        
                        //alert(indexofDecimal + ' ' + textLength);
                        
                        if (textLength - indexofDecimal <= 2) { bool = true; }
                        else { bool = false; }
                    }
                    else { bool = true; }
                }
                else{bool=true;}
            }
        break;   
   }
   
   return bool;
} 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Quantity box will be re-set to 0 if user left it blank
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function QuantityValidation(textbox)
{
    if(textbox.value == "")
    {
        textbox.value = "0";
    } 
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function TextCase(textbox,texttype)
{
    if(event.keyCode >= 65 && event.keyCode <= 90)
    {
        switch(texttype)
        {
            case "LowerCase":
                textbox.value = textbox.value.toLowerCase();
            break;
            case "UpperCase":
                textbox.value = textbox.value.toUpperCase();
            break;
        }
    }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function NewWindow(URL, Target, width, height, toolbar) 
{ 
    if (Target == "") { Target = "_blank"; }
    if (width == 0) { width = 800; }
    if (height == 0) { height = 600; }
    
    window.open(URL,Target,"width=" + width + ",height=" + height + ",toolbar=" + toolbar); 
    //var a = window.setTimeout("document.form1.submit();",500); 
} 


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Load Page Into Parent Window
// Version 1.0
// Last Updated: May 18, 2000
// Code maintained at: http://www.moock.org/webdesign/javascript/
// Copy permission granted any use provided this notice is unaltered.
// Written by Colin Moock.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function loadinparent(url, closeSelf)
{
	self.opener.location = url;
	if(closeSelf) self.close();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

