/*function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Sorry, right click is diabled.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;*/
//  End -->

/*** 实现跳转的函数*/

function Back(layout,cat, brand)
{
	document.form.action="products.php?type="+layout+"&cat_id="+cat+"&brand="+brand+"&status=back";
    document.form.target="";
    document.form.submit();
}

/*** 实现跳转的函数*/
function gotoPage(cat,totalPages_Rs1)
{
	//alert(parseInt(gotopage.value));alert(gotopage.value);
	if(parseInt(gotopage.value) != gotopage.value)
	{
		alert('Please Enter Positive Integer For Page Number !');
		return false;
	}
	var page = eval(gotopage.value-1);
	var totalpage = eval(totalPages_Rs1);
	
	if(page>totalpage)
	{
		alert('Please Input Valid Page Number, Maximum Page Number is '+(totalpage+1));
		return false;
	}
	document.location = "products.php?cat_id="+cat+"&layout="+layout+"&pageNum_Rs1="+page;
}

function chkAll(frm, arr, mark)
{
	for (i = 0; i <= frm.elements.length; i++)
	{
		try
		{
			if(frm.elements[i].name == arr)
			{
				frm.elements[i].checked = mark;
			}
		}
		catch(er)
		{}
	}
	/*for (i = 0; i <= frm.elements.length; i++)
	{
		try
		{
			if(frm.elements[i].name == arr2)
			{
				frm.elements[i].checked = mark;
			}
		}
		catch(er)
		{}
	}*/
}

var ELE_NAME_ARRAY = new Array('basket[]');	
var MY_WEB_SERVER = "http://my.alibaba.com";
function inquiryNow(pageNum_Rs1,id,cat_id)
{
    var checkedNum = getCheckedNum();
	//alert(checkedNum);
	//alert(document.form.chkProductIds[0].value);
    var basketItemNum = parseInt(document.form.basketItemNum.value);
	//alert(basketItemNum);
    var urlString = document.location+""; 
	//alert(basketItemNum);
	if(checkedNum == 0)
	{
      if(basketItemNum == 0)
	  {
          alert("No item(s) selected.")
          return;    	
      }
	  else
	  {
          document.form.action="inquiry.php?req_page=basket.init&pageNum_Rs1="+pageNum_Rs1+"&id="+id+"&cat_id="+cat_id;
          //document.form.target="_blank";
          document.form.submit();    	
      }
    }
    if(checkedNum > 0) {
        document.form.action="inquiry.php?req_page=feedback.init";
        document.form.target="_blank";
        document.form.submit();		
    }
}
function addBasket(pageNum_Rs1,cat_id,layout)
{
    var basketItemMax = parseInt(document.form.basketItemMax.value);
	//alert(basketItemMax);
    var basketItemNum = parseInt(document.form.basketItemNum.value);
	//alert(basketItemNum);
	var num = getCheckedNum();
    var urlString = document.location+"";
    if(num == 0)
	{
        alert("No item(s) selected.")
        return;
    }
    if(basketItemMax < (basketItemNum + num))
	{
        var alertMessage = "Your Inquiry Basket is full. It can store a maximum of " + basketItemMax + " inquiries.";
        alert(alertMessage);
        return;
    }
	//document.form.basketItemNum.value = (basketItemNum + num);
    //basketItemNum = parseInt(document.form.basketItemNum.value);
	//alert(window.location.href);
	/*if(cat=="" && brand=="" & pageNum_Rs1=="" && type!="")
	{
    	document.form1.action="products.php?type="+type;
	}
	else if(layout=="" && pageNum_Rs1!="" && cat=="")
	{
    	document.form1.action="products.php?pageNum_Rs1="+pageNum_Rs1;
	}
	else if(layout!="" && pageNum_Rs1=="" && cat=="")
	{
    	document.form1.action="products.php?layout="+layout;
	}
	else if(layout=="" && pageNum_Rs1!="" && cat!="")
	{
    	document.form1.action="products.php?pageNum_Rs1="+pageNum_Rs1+"&cat="+cat;
	}
	else if(layout!="" && pageNum_Rs1=="" && cat!="")
	{
    	document.form1.action="products.php?layout="+layout+"&cat="+cat;
	}
	else if(layout!="" && pageNum_Rs1!="" && cat=="")
	{
    	document.form1.action="products.php?layout="+layout+"&pageNum_Rsl="+pageNum_Rsl;
	}
	else
	{
    	document.form1.action="products.php?pageNum_Rs1="+pageNum_Rs1+"&layout="+layout+"&cat="+cat;
	}*/
	document.form.action="products.php?pageNum_Rs1="+pageNum_Rs1+"&cat_id="+cat_id+"&layout="+layout;
	//pageNum_Rs1="+pageNum_Rs1+"&type="+type+"&cat="+cat+"&brand="+brand;
    document.form.target="";
    document.form.submit();
}
function getCheckedNum()
{

  return getCheckedRecordNum(document.form,ELE_NAME_ARRAY);
}
/////////part2 - started/*
function setCheckedFlag(formObj,eleNameArr,checkedFlag)
{
  for(var i=0;i<formObj.elements.length;i++)
  {  
     var ele = formObj.elements[i];
     for(var j=0;j<eleNameArr.length;j++)
	 {
       if(ele.name == eleNameArr[j])
	   {
          ele.checked = checkedFlag;
          break;
       }	
     }
  }
}
function getCheckedRecordNum(formObj,eleNameArr)
{

  var checkedNum = 0;
  for(var i=0; i<formObj.elements.length; i++)
  {
     var ele = formObj.elements[i];
     for(var j=0;j<eleNameArr.length;j++)
	 {
       if(ele.name == eleNameArr[j] && ele.checked)
	   {
          checkedNum ++;
          break;
       }	
     }	
  }
  return checkedNum;
}
function MM_findObj(n, d)
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function inquiryNow_details(id)
{
    var checkedNum = getCheckedNum();
    var basketItemNum = parseInt(document.form.basketItemNum.value);
    var urlString = document.location+""; 
	if(checkedNum == 0)
	{
      if(basketItemNum == 0)
	  {
          alert("No item(s) selected.")
          return;    	
      }
	  else
	  {
          document.form.action="inquiry.php?req_page=basket.init&pageNum_Rs1="+pageNum_Rs1+"&id="+id;
          document.form.submit();    	
      }
    }
    if(checkedNum > 0) {
        document.form.action="inquiry.php?req_page=feedback.init";
        document.form.target="_blank";
        document.form.submit();		
    }
}
/*function addBasket_details(id,cat_id)
{
    var basketItemMax = parseInt(document.form.basketItemMax.value);
    var basketItemNum = parseInt(document.form.basketItemNum.value);
    var urlString = document.location+"";
	var num = getCheckedNum();
    if(num == 0)
	{
        alert("No item(s) selected.")
        return;
    }
    if(basketItemMax < (basketItemNum + num))
	{
        var alertMessage = "Your Inquiry Basket is full. It can store a maximum of " + basketItemMax + " inquiries.";
        alert(alertMessage);
        return;
    }
	//document.form.basketItemNum.value = (basketItemNum + num);
    //basketItemNum = parseInt(document.form.basketItemNum.value);
	//alert(window.location.href);
	document.form.action="product_detail.php?id="+id+"&cat_id="+cat_id;
    document.form.target="";
    document.form.submit();
}*/

function addtofavorite()
{
	if( window.sidebar && window.sidebar.addPanel)
	{
		//Gecko (Netscape 6 etc.) - add to Sidebar
		window.sidebar.addPanel( this.title, this.href, '');
	}
	else if( window.external && navigator.platform == 'Win32')
	{
		//IE Win32 - checking for AddFavorite produces errors for no good
		//reason, so I use a platform detect.
		//adds the current page page as a favourite; if this is unwanted,
		//simply write the desired page in here instead of 'location.href'
		window.external.AddFavorite(location.href, document.title);
	}
	else if( window.opera && window.print )
	{
		//Opera 6+ - add as sidebar panel to Hotlist
		return true;
	}
	else if( document.layers )
	{
		//NS4 & Escape - tell them how to add a bookmark quickly (adds current page, not target page)
		window.alert( 'Please click OK then press Ctrl+D to create a bookmark' );
	}
	else
	{
		//other browsers - tell them to add a bookmark (adds current page, not target page)
		window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
	}
	return false;
}

function mailtofriend()
{
    window.open("email.php",'_blank' ,'width=630,height=500,toolbar=no,scrollbars=yes,resizable=no,status=no,toolbar=no,menubar=no,location=no');
}

/*function check()
{
    if(document.form.cat.value=="")
	{
		alert("Please select a category.");
		return false;
	}
	else
	{
		return true;
	}
}*/

function gotoPage(totalPages_Rs1)
{
	//alert(parseInt(gotopage.value));alert(gotopage.value);
	if(parseInt(gotopage.value) <= 0)
	{
		alert('Please Enter Positive Integer For Page Number !');
		return false;
	}
	var page = eval(gotopage.value-1);
	var totalpage = eval(totalPages_Rs1);
	
	if(page>totalpage)
	{
		alert('Please Input Valid Page Number, Maximum Page Number is '+(totalpage+1));
		return false;
	}
	document.location = "products.php?pageNum_Rs1="+pageNum_Rs1+"&cat_id="+cat_id+"&layout="+layout;
}
