var msgstr = ""; 
function displayAlert(mod) {
	if (mod!="") {
		if (mod=="basket")		
			msgstr = "Please select an item below."; 
		else if (mod=="showroom")			
			msgstr = "Please select a product item before clicking\nthe \"Inquire Now\" , \"Add to Inquiry Basket\"\n buttons."; 
	}


	if (document.inqform.length>0) {
		for (var i=0;i<document.inqform.length;i++) {
			var e = document.inqform.elements[i];
			if(e.type == "checkbox") {
				if(e.checked == true) {
					return true;
				}
			}
		}
	  	  alert(msgstr);
	     return false;	
	} else {
		inqform.blur();
	}	 
}

function all(form,name,flag)
{
  if(name != 'all')
  {
     for ( var i=0; i < eval("form.length"); i++ ) 
     {
	      var box = eval("form.elements[i]"); 
          var ename=eval("form.elements[i].name");
		  if(ename == name)
	      {
			 box.checked=flag;
		  }
     }
  }
  else
  {
     for ( var i=0; i < eval("form.length"); i++ ) 
	  {
	      var box = eval("form.elements[i]"); 
          var etype=eval("form.elements[i].type");
		  if(etype == 'checkbox')
	      {
			 box.checked=flag;
		  }
     }

  }
 
}



function action(url,mod) {
	if (displayAlert(mod)) {
		document.inqform.method="post";
		document.inqform.action=url ;
		document.inqform.submit();
	}	
}
function comparable(mod)
{
	if (displayAlert(mod)) {	
	   var inputholdervalue="";
		for (var i=0; i<document.inqform.id.length; i++) 
		{
			if (document.inqform.id[i].checked) {
				found = true;
				if (inputholdervalue != "") {
					inputholdervalue = inputholdervalue + "|" + document.inqform.id[i].value;
				} else {
					inputholdervalue = document.inqform.id[i].value;
				}
			}
		}
		document.inqform.method="post";
    	 document.inqform.action="/GeneralManager?action=GetComparableAttributes&inputholder="+inputholdervalue;
		 document.inqform.submit();
	}	 
}

// **** for document stuff ** //
function fillHolder(form,holder,sid,genman) {
var valholder=""; 
if (displayAlert('basket'))
{
  if (holder.length>0)
  {
	for (var i=0; i<holder.length; i++) 
		{
			if (holder[i].checked)
			 {
				found = true;
				if (valholder != "") 
				  {	valholder = valholder + "|" + holder[i].value; }
				else { valholder = holder[i].value;	}
			}
		}	
  }else { valholder = holder.value;}				
   form.method="post";
   form.action=genman+"?action=EditDocument&turnType=RFI&section=Document&supplier_id="+sid+"&itemHolder="+valholder;
   form.submit();	
 }
}


// **** for document stuff ** //


function inquireredirect(id)
{
  window.location.href="/GeneralManager?action=EditGSOLDocument&turnType=RFI&itemHolder="+id;
}

function sampleredirect(id)
{
  //window.location.href="/GeneralManager?action=EditGSOLDocument&turntype=RFS&itemHolder="+id;
  window.location.href="/GeneralManager?action=EditGSOLDocument&turntype=RFS";
}

function sortThis(reverseOrNot, sorter) 
{
               document.inqform.doSort.value="true";
              document.inqform.reverse_sort.value=reverseOrNot;
              document.inqform.sorter.value=sorter;
			  if(document.inqform.productid != null)
			  document.inqform.productid.name='point_id';
              document.inqform.submit();
}

function paginate(page,pageParameterName) 
{
	var pageNumObj = document.getElementsByName(pageParameterName)[0];
	pageNumObj.value=page;
//	if(document.inqform.productid != null)
//	document.inqform.productid.name='point_id';
	document.inqform.submit();
}

function clickMore(flag) {
	     if(document.inqform.noviewmore != null)
	     {
		   document.inqform.noviewmore.value=flag;
  		   document.inqform.noviewmore.name='viewmore';
		 }
		 else
	     {
 	        document.inqform.viewmore.value=flag;
		 }
	     document.inqform.page.value="1";
 		 document.inqform.submit();
  }

  function viewwithimage(flag) {
              if(flag == 'true')
              document.inqform.noimg.value="true";
			  if(flag == 'false')
              document.inqform.noimg.value="false";
  			  if(document.inqform.productid != null)
			  document.inqform.productid.name='id';
              document.inqform.submit();
      }
