function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox


function openbox(formtitle, fadin)
{
  var box = document.getElementById('box'); 
  document.getElementById('filter').style.display='block';

  var btitle = document.getElementById('boxtitle');
  btitle.innerHTML = formtitle;
  
  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }  	
}


// Close the lightbox

function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
}
function closebox1()
{
   document.getElementById('box1').style.display='none';
   document.getElementById('filter1').style.display='none';
}  

function openbox1(formtitle, fadin)
{
  var box1 = document.getElementById('box1'); 
  document.getElementById('filter1').style.display='block';

  var btitle = document.getElementById('boxtitle1');
  btitle.innerHTML = formtitle;
  
  if(fadin)
  {
	 gradient("box1", 0);
	 fadein("box1");
  }
  else
  { 	
    box1.style.display='block';
  }  	
}
function closebox4()
{
	document.getElementById("box4").style.display='none';
}
function checkform(p)
{
	var j=0;	
	var loopcount = document.getElementById("loopcount").value;
	var lcount = parseFloat(loopcount)+parseFloat(p);
	
	for(var i=p+1;i<=lcount;i++) {
	if(document.getElementById("quantity"+i).value=="")
	{
	j=j+1;
	}
	}
	if (loopcount==j)
	{
	alert("You must enter atleast one quantity");
	return false;
	}
return true;
}


function openbox4(no_rows)
{
	var qtr_str='';
	var qnttotal=0;
	var ptotal=0;
	var subttotal=0;
	var loopcount = document.getElementById("loopcount").value;
	var qtr_str='';
	var j=1;
	qtr_str=qtr_str+'<table width="500" border="0" align="center"> <tr class="viewheadingone"> <td colspan="6">View Order</td> </tr>';
  	qtr_str=qtr_str+'<tr class="viewheadtext"><td width="30">SNo</td> <td width="125">Item code </td> <td width="210">Item Description </td>';
	qtr_str=qtr_str+'<td width="40">Price</td><td width="40">Qty</td> <td width="55">Total</td> </tr> <tr>';
	qtr_str=qtr_str+'<td colspan="6">';
	for(var i=1;i<=loopcount;i++) {
		if(document.getElementById("qty"+i).value!="")
		{
		ptotal=parseFloat(document.getElementById("price"+i).value)*parseFloat(document.getElementById("qty"+i).value);
		qtr_str = qtr_str + '<table><tr class="viewtext1"><td width="30">'+j+'</td><td width="125">'+(document.getElementById("item"+i).value)+'</td><td width="210">'+(document.getElementById("desc"+i).value)+'</td><td width="40">$'+(document.getElementById("price"+i).value)+'</td><td width="40">'+(document.getElementById("qty"+i).value)+'</td><td width="55" align="right">$'+ptotal+'</td></tr></table>';
		j=j+1;
		qnttotal=qnttotal+parseFloat(document.getElementById("qty"+i).value);
		subttotal=subttotal+ptotal;
		}
	}
	qtr_str=qtr_str+'</td> </tr> <tr> <td colspan="6"><table width="500" border="0" class="viewtext2"> <tr>';
    qtr_str=qtr_str+'<td width="30">&nbsp;</td> <td width="125">&nbsp;</td><td width="210">&nbsp;</td>';
	qtr_str=qtr_str+'<td width="40">Total : </td><td width="40">'+qnttotal+'</td><td width="55">$'+subttotal+'</td>';
	qtr_str=qtr_str+'</tr></table></td></tr><tr><td width="30">&nbsp;</td><td width="125">&nbsp;</td>';
	qtr_str=qtr_str+'<td width="210">&nbsp;</td><td width="55"><input name="button" type="submit" id="button" value="Close" onclick="closebox4();"/>';
  	qtr_str=qtr_str+'</td></tr></table>';
	document.getElementById("box4").innerHTML=qtr_str;
  	document.getElementById("box4").style.display='block';
}
function rowOverEffect(obj){
	obj.style.backgroundColor = "#cf97a4";
	obj.style.cursor = "pointer";
	//obj.style="background-color:#FFFFFF; cursor:pointer";
}
function rowOutEffect(obj2,cl){	
	obj2.style.backgroundColor = cl;
}
function fill_hidden(id,val,avail,idd) {
	document.getElementById("qty"+idd).value = document.getElementById("quantity"+id).value;
	document.getElementById('sorder').setAttribute('disabled', 'disabled');
	document.getElementById('sorder').removeAttribute('onClick');
	if (avail>6)
	{
		if (val<6)
		{	var valuesub = document.getElementById("quantity"+id).value;
			var pricesub = document.getElementById("div"+id).innerHTML;
			var subttotal=(document.getElementById("totalamount").innerHTML.substring(1));
			subttotal=subttotal-pricesub;
			var subt="$"+subttotal;
			var gsubttotal=(document.getElementById("amount_gtotal").innerHTML.substring(1));
			gsubttotal=gsubttotal-pricesub;
			var gsubt="$"+gsubttotal;
			document.getElementById("quantity"+id).value='';			
			document.getElementById("div"+id).innerHTML='';
			document.getElementById("totalamount").innerHTML=subt;
			document.getElementById("amount_gtotal").innerHTML=gsubt;
			document.getElementById("totalitems").innerHTML=(parseFloat(document.getElementById("totalitems").innerHTML)-valuesub); 			document.getElementById("items_gtotal").innerHTML=(parseFloat(document.getElementById("items_gtotal").innerHTML)-valuesub);
			alert("You should select greater than 6 quantities!");
			
		}	
	}
	if (avail<6)
	{
		if (val<avail)
		{	
			var valuesub = document.getElementById("quantity"+id).value;
			var pricesub = document.getElementById("div"+id).innerHTML;
			var subttotal=(document.getElementById("totalamount").innerHTML.substring(1));
			subttotal=subttotal-pricesub;
			var subt="$"+subttotal;
			var gsubttotal=(document.getElementById("amount_gtotal").innerHTML.substring(1));
			gsubttotal=gsubttotal-pricesub;
			var gsubt="$"+gsubttotal;
			document.getElementById("quantity"+id).value='';			
			document.getElementById("div"+id).innerHTML='';
			document.getElementById("totalamount").innerHTML=subt;
			document.getElementById("amount_gtotal").innerHTML=gsubt;
			document.getElementById("totalitems").innerHTML=(parseFloat(document.getElementById("totalitems").innerHTML)-valuesub); 			document.getElementById("items_gtotal").innerHTML=(parseFloat(document.getElementById("items_gtotal").innerHTML)-valuesub);
			alert("You should select "+avail+" quantities!");			
		}
		
	}
	
}
function checkpass() 
{
  if(document.getElementById("rpassword").value!=document.getElementById("rconfirmpassword").value)
  {
   alert("Password and Confirm password must be same");
   document.getElementById("rconfirmpassword").focus();
   document.getElementById("rconfirmpassword").value="";
   document.getElementById("rconfirmpassword").style.backgroundColor='#FEC2CB';
   return false;
   }  
}
function checkFrm(form)
  {
    if(form.clientname.value == "") {
      alert("Error: Please enter company name!");
      form.clientname.focus();
	  form.clientname.style.backgroundColor='#f4ece9';
      return false;
    }
    
    if(form.email.value == "") {
      alert("Error: Please enter Email address!");
      form.email.focus();
	  form.email.style.backgroundColor='#f4ece9';
      return false;
    }

    rel = /^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
      if(!rel.test(form.email.value)) {
	  alert ("Error: Please enter valid Email address!");
	  form.email.focus();
	  form.email.style.backgroundColor='#f4ece9';
      return false;
	}
	
	if(form.message.value == "") {
      alert("Error: Please enter message!");
      form.message.focus();
	  form.message.style.backgroundColor='#f4ece9';
      return false;
    }

    return true; 
  }
  function checkpass() 
	{
  if(document.getElementById("rpassword").value!=document.getElementById("rconfirmpassword").value)
  {
   alert("Password and Confirm password must be same");
   document.getElementById("rconfirmpassword").focus();
   document.getElementById("rconfirmpassword").value="";
   document.getElementById("rconfirmpassword").style.backgroundColor='#FEC2CB';
   return false;
   }  
}
function rowOverEffect(obj){
	obj.style.backgroundColor = "#fea27a";
	obj.style.cursor = "pointer";
	//obj.style="background-color:#FFFFFF; cursor:pointer";
}
function rowOutEffect(obj2,cl){	
	obj2.style.backgroundColor = cl;
}