﻿// JScript File

////////Search options///////////
function IsBlank()
{
    var argStr = document.getElementById("ctl00_txtSearch").value;
	var s = new String(argStr);
	var cnt=0;
	len = s.length;
	
	for(i=0;i<len;i++)
	{
		intCh = GetAsciiCode(s.charAt(i));
		if(intCh==32)
		{
			cnt++;
		}
	}
	if ((cnt==len)||(cnt==0&&len==0))
	{
	    alert("Please Enter text in search box !");
	    return false;
	}
	else
	{
	    return true;
	}
}

function DefaultEnterKeyPress(evt,bt)
{
      var evt = evt ? evt : window.event;
      var bt = document.getElementById(bt);
      if (bt)
      {
          if (evt.keyCode == 13)
          {
                bt.click();
                return false;
          }
      }
}
///////Search options///////////
    function EnterKeyPressHome(evt,bt)
    {
      var evt = evt ? evt : window.event;
      var bt = document.getElementById(bt);
      if (bt)
      {
          if (evt.keyCode == 13)
          {
                bt.click();
                return false;
          }
      }
    }
    function trim(str)
    {
        result=str.replace(/(^ +| +$)/, "");
	    return result;
    }	
    function validateBasket()
    {
        var optExtra=new Array();
        
        optExtra[0]=document.getElementById('grdBasket_ctl02_txtQty');    
        
        for (i=0;i<=21;i++)
        {
            if(trim(optExtra[i].value)=="")
            {   

                    alert("You must enter Qty");
                    optExtra[i].focus();
                    return false;
            }
            
                var s1=trim(optExtra[i].value);
			    var numberexp=/^[0-9]{1,16}$/;
			    if (s1.match(numberexp))
			    {	  }
			    else
			    {
				    alert("Please enter correct Qty");
				    optExtra[i].focus();
				    return false;
			    }        
        }
        
        return true;
    }

    function validateBasketQty(id)
    {
       // alert(id)
        qty=document.getElementById(id);    
        
            if(trim(qty.value)=="")
            {   

                    alert("You must enter Qty");
                    qty.focus();
                    return false;
            }
            
                var s1=trim(qty.value);
			    var numberexp=/^[0-9]{1,16}$/;
			    if (s1.match(numberexp))
			    {	  }
			    else
			    {
				    alert("Please enter correct Qty");
				    qty.focus();
				    return false;
			    }        
        
        return true;
    }
    
//function to get height of window and set height of middle part of page

function SetPageHeight(ctrl) 
{
  var myWidth = 0, myHeight = 0;
  var sidemenuHeight = 0;
  var newHeight = 0;
  var val=262;
  
  sidemenuHeight = document.getElementById(ctrl).offsetHeight;
    
  //get window height
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    
     } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight - 18;
    val=243;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    
  }
  
  newHeight = parseInt(myHeight - val);
 
  //set height of middle part 
  if(myHeight > (sidemenuHeight + val))
  {
    //alert('setting height to ' + newHeight);
    document.getElementById(ctrl).style.height = newHeight + "px" ;
    }
}

