		function initItemList(){};
		/** declare the globe valuables 
		*		for storing the last selected index value
		**/
		var lastClassSelectedIndex		= 0;
		var lastBrandSelectedIndex 	= 0;
		var lastFamilySelectedIndex 	= 0;
		var lastModelSelectedIndex 	= 0;
		var itemList 						= [];		
		
		/** overwrite the super's init fucntion 	
		*		exec the follow when the form onload
		**/
		function mmcinit()
		{
		
			var cform = document.forms.searchForm;
			lastClassSelectedIndex = cform.p_class.selectedIndex;
			for (i=0;i<cform.elements.length;i++) 
			{
 				if (cform.elements[i].name == 'brand') 
 					lastBrandSelectedIndex = cform.elements[i].selectedIndex;
 				if (cform.elements[i].name == 'family')	
 					lastFamilySelectedIndex = cform.elements[i].selectedIndex;
 				if (cform.elements[i].name == 'model')
 					lastModelSelectedIndex = cform.elements[i].selectedIndex;
			}
			if (self.location == top.location) {
				top.location.href="http://www.mbtech.com.au";
			}
			initItemList();
		}
		
		/** fire this function when the 
		*'class' combo box onchange 
		**/
		function reloadOnChangeClass()
		{
			
			var cform = document.forms.searchForm;
			if (cform.p_class.selectedIndex == 0)
			{
				
				alert("Please choose a valid product Class.");
				cform.p_class.selectedIndex = lastClassSelectedIndex;
				cform.p_class.focus();
				return false;
			}
			else
			{
			
				for (i=0;i<cform.elements.length;i++) 
				{
	 				if (cform.isFirstByBrand.value != "True")
	 				{
		 				if (cform.elements[i].name == 'brand') cform.elements[i].value = '';
		 			}
					if (cform.elements[i].name == 'family') cform.elements[i].value = '';
	 				if (cform.elements[i].name == 'model') cform.elements[i].value = '';
				}
				cform.cmd.value = "reload";
				doSubmit();
			}
		}

		/** fire this function when the 
		*'Brand' combo box onchange 
		**/
		function reloadOnChangeBrand()
		{
			var cform = document.forms.searchForm;
			if(cform.brand.selectedIndex == 0)
			{
				alert("Please choose a valid product Brand.");
				cform.brand.selectedIndex = lastBrandSelectedIndex;
				cform.brand.focus();
				return false;
			}
			else
			{
				for (i=0;i<cform.elements.length;i++) 
				{
					if (cform.isFirstByBrand.value == "True") cform.p_class.value = '';
	 				if (cform.elements[i].name == 'family') cform.elements[i].value = '';
	 				if (cform.elements[i].name == 'model') cform.elements[i].value = '';
				}
				cform.cmd.value = "reload";
				doSubmit();
			}
		}
		
		/** fire this function when the 
		*'Family' combo box onchange 
		**/
		function reloadOnChangeFamily()
		{
			var cform = document.forms.searchForm;
			if(cform.family.selectedIndex == 0)
			{
				alert("Please choose a valid product Family.");
				cform.family.selectedIndex = lastFamilySelectedIndex;
				cform.family.focus();
				return false;
			}
			else
			{
				for (i=0;i<cform.elements.length;i++) 
				{
	 				if (cform.elements[i].name == 'model') cform.elements[i].value = '';
				}
				cform.cmd.value = "reload";
				doSubmit();
			}
		}

		function reloadOnChangeModel()
		{
			var cform = document.forms.searchForm;
			if(cform.model.selectedIndex == 0)
			{
				alert("Please choose a valid product Model.");
				cform.model.selectedIndex = lastModelSelectedIndex;
				cform.model.focus();
				return false;
			}
			else
			{
				cform.cmd.value = "search";
				doSubmit();
			}
		}
		
		function doSubmit()
		{
			var cform = document.forms.searchForm;
			PlsWaitDialog.show();
			
			cform.submit();
		}
		


		function doAddCart(index, qty)
		{
			
			if(!isWholeNumber(qty))
			{
				alert("Quantity must be an integer number!");
			}
			else if (!isWholeNumber(index) || index > itemList.length )
			{
				alert("System Error, action aborted, please try again.");
			}
			else
			{
				var cartf 						= document.forms.addtocart;	
				var vo 							= itemList[index];
				cartf.item_id		.value	= vo.item_id		;
				cartf.cart_id		.value	= vo.cart_id		;
				cartf.class_id    .value   = vo.class_id     ;
				cartf.class_desc  .value   = vo.class_desc   ;
				cartf.family_id   .value   = vo.family_id    ;
				cartf.family_desc .value   = vo.family_desc  ;
				cartf.brand_id    .value   = vo.brand_id     ;
				cartf.brand_desc  .value   = vo.brand_desc   ;
				cartf.model       .value   = vo.model        ;
				cartf.part_no     .value   = vo.part_no      ;
				cartf.warranty    .value   = vo.warranty     ;
				cartf.qty         .value   = qty          	;
				cartf.instmemqty  .value   = vo.instmemqty   ;
				cartf.cmkitqty    .value   = vo.cmkitqty     ;
				cartf.pcs_count   .value   = vo.pcs_count    ;
				cartf.cmxcode     .value   = vo.cmxcode      ;
				cartf.cmicode     .value   = vo.cmicode      ;
				cartf.cmsize      .value   = vo.cmsize       ;
				cartf.cm_mb       .value   = vo.cm_mb        ;
				cartf.cm_desc     .value   = vo.cm_desc      ;
				cartf.ext_desc    .value   = vo.ext_desc     ;
				cartf.ex_price    .value   = vo.ex_price     ;
				cartf.unit_price  .value   = vo.unit_price   ;
				cartf.total_price .value   = vo.total_price  ;
				cartf.client_notes.value   = vo.client_notes ;
				cartf.mbt_notes   .value   = vo.mbt_notes    ;
				cartf.created_on	.value	= vo.created_on	;
				cartf.created_by	.value	= vo.created_by	;
				cartf.amended_on	.value	= vo.amended_on	;
				cartf.amended_by	.value	= vo.amended_by	;
				cartf.submit();
			}
			//alert("Sorry, shopping cart is not ready");
		}

		function showDetailedNotes(){
			/**
			alert
			("before:"
			+document.getElementById("xnotes").innerHTML+"\n"
			+document.getElementById("xnotes").style.visibility+"\n"
			+document.getElementById("xnotes").style.display+"\n"
			);
			**/
			
			if (document.getElementById("xnotes").style.visibility!='visible')
			{
					
					document.getElementById("xnotes").style.visibility = 'visible';
					document.getElementById("xnotes").style.display = "block";
			}else
			{
				document.getElementById("xnotes").style.visibility = 'hidden';
				document.getElementById("xnotes").style.display = "none";
			}
			
		}
		
