// JavaScript Document
//////////////// Paging functions
function ChangePageSize(ele,URL)
{	//alert(URL+ele.value);
	window.location=URL+ele.value;
}

RecordOldCss=""
CheckBoxObj=""
function movenext()
{
	document.form1.page.value=parseInt(document.form1.page.value)+1;
	document.form1.submit();

}

function movepre()
{
	document.form1.page.value=parseInt(document.form1.page.value)-1;
	document.form1.submit();
}

function movepage(pageno)
{
	document.form1.page.value=parseInt(pageno);
	document.form1.submit();
}
PagingOldCss=""
function highlightPage(el)
{
	PagingOldCss=el.className;
	el.className="page_high_bg"
}

function lowlightPage(el)
{
	if(PagingOldCss!="")
	{
		el.className=PagingOldCss;
	}
	else
	{
		el.className="";
	}
}

MenuOldCss=""
function highlightMenu(el)
{
	MenuOldCss=el.className;
	el.className="linkbg_hover"
}

function lowlightMenu(el)
{
	if(MenuOldCss!="")
	{
		el.className=MenuOldCss;
	}
	else
	{
		el.className="";
	}
}

RecordOldCss=""
function highlightRecord(el)
{
	RecordOldCss=el.className;
	el.className="record_high_bg"
}

function lowlightRecord(el)
{
	if(RecordOldCss!="")
	{
		el.className=RecordOldCss;
	}
	else
	{
		el.className="";
	}
}


OldCss=""
function highlightTD(el)
{
	OldCss=document.getElementById(el).className;
	if(OldCss==""){	document.getElementById(el).className="leftmenu_hover" }
}

function lowlightTD(el)
{
	if(OldCss!="")
	{
		document.getElementById(el).className=OldCss;
	}
	else
	{
		document.getElementById(el).className="";
	}
}

function CheckValidValue(eObj)
{
	var mystring = new String(eObj.value);
	var regexp="'";
	var answer=mystring.match(regexp);
	if(answer==null)
	{
		return true;
	}
	else
	{
		alert("Single quote ( ' ) is restrcted. Please reamove Single quote");
		eObj.focus();
		return false;
	}
}

//////////////////Search Function/////////////
var ROOTDIRWEB;
ROOTDIRWEB="http://d806564.u37.infinology.net/";
function leftsearch()
{
var mcat;
var scat;
var action="left";
mcat = document.form1.mcategory.value;
scat = document.form1.subcat.value;

if(mcat == "nothing" || scat == "nothing")
	{
      alert("Please Select Brand and Printer");
    }
else
{
	window.location = ROOTDIRWEB+"searchresult.php?mcategory="+mcat+"&subcat="+scat+"&action="+action

}
	
}

function middlesearch()
{
var total;
var mdevice;
var devicesubcat;
var action="middle";
//mdevice = document.form1.mdevice.value;
total = document.form1.devicesubcat.value;
devicesubcat = total.substr(0,5);
mdevice = total.substr(6);
//alert(devicesubcat);
//alert(mdevice);
//return
if(mdevice == "nothing" || devicesubcat == "" || document.form1.devicesubcat.value=="nothing")
	{
        alert("Please Select Printer");	
    }
else
   {
	window.location=ROOTDIRWEB+"searchresult.php?mdevice="+mdevice+"&devicesubcat="+devicesubcat+"&action="+action

   }

}

function productchange()
{
  var ProductID;
  var action="middle_productchange";
  ProductID=document.form1.product.value;
window.location = ROOTDIRWEB+"redirection.php?ProductID="+ProductID+"&action="+action
}

 function productbuynow(ProductID)
{
 tmp = document.form1.Quantity.value;
 var result = CheckAvailQty(ProductID,tmp);
	if(result == false)
	{
	//alert("Sorry! The requested Quantity is not available.Cuurent available stock is " + result)
	return
	}

 if(document.form1.Quantity.value=="")
 {alert("Please Enter Quantity");document.form1.Quantity.focus();return;}
 if(isnumeric(document.form1.Quantity.value)==false)
	{
		alert("Please Enter Numeric value for Quantity");
        document.form1.Quantity.focus();
		return ;
	}
  var action="middle_productbuy";
  var Quantity=document.form1.Quantity.value;
window.location = ROOTDIRWEB+"redirection.php?ProductID="+ProductID+"&action="+action+"&quantity="+Quantity
}
  function brandbuynow(ProductID)
{
  var action="right_brandbuy";
  var Quantity=1;
  window.location = ROOTDIRWEB+"redirection.php?ProductID="+ProductID+"&action="+action+"&quantity="+Quantity
}

var checkflag=0;
function submitForm(form,chkid)
{
	cmd='document.'+form+'.'+chkid+'.length';	
	chkLen=eval(cmd);
	
	
	var i;		
		if(chkLen)
		{
			if(chkLen==1)
			{
				if(eval('document.'+form+'.'+chkid+'.checked') == true)
				checkflag=1;
			}
			else
			{ 
				for(i=0;i<chkLen;i++)	
				{
					if(eval('document.'+form+'.'+chkid+'['+i+'].checked') == true)	
					{
						checkflag=1;
					}
				}
			}
		}
		else
		{
			if(eval('document.'+form+'.'+chkid+'.checked'))
			{
				checkflag=1;
			}
		}
	if(checkflag==1)
	{
			var cnf=confirm('Are you sure you want to delete this record?');
			if(cnf)
					{ eval('document.'+form+'.submit()'); }
	}
	else
	{
		alert("Select atleast one checkbox");
		return false;
	}


}