﻿	function contact(setting)
	{
		var curIntType=setting.IntType|| "Product";
		var Host=setting.Host || "www.packaging-machinery007.com";

		if(curIntType==null)
		{
			return;
		}
		var type;
		var tempArray=this.getObjectValue();
		if(tempArray.length>10)
		{
	        this.alertError();
		}
		switch(curIntType)
		{
			case "Product":
			case "ProductGallery":
				type=3;
				if(tempArray.length<=0)
				{
					alert("Please select a product.");
					window.document.forms[0].onsubmit=function(){ return false;}
					return;
				}
				break;
			case "Supplier":
				type=4;
				if(tempArray.length<=0)
				{
					alert("Please select a suplier.");
					window.document.forms[0].onsubmit=function(){ return false;}
					return;
				}
				break;
			case "SellingLeads":
			case "SellingLeadsGallery":
				type=2;
				if(tempArray.length<=0)
				{
					alert("Please select a selling leads.");
					window.document.forms[0].onsubmit=function(){ return false;}
					return;
				}
				break;
			case "BuyLeads":
			    type=1;
			    if(tempArray.length<=0)
			    {
			        alert("Please select a buying Leads.");
			        window.document.forms[0].onsubmit=function(){ return false;}
					return;
			    }
			    break;
			default:
				window.document.forms[0].onsubmit=function(){ return false;}
				return;
		}
		
		var loc=Host+ "/sendmail/sendlist_P.asp?id="+tempArray.join(",");
		//window.location.href = loc;//本页面附加
		window.open(loc,"_blank"); //打开新页面
	}
	contact.prototype.getObjectValue=function()
	{
		var objList = document.getElementsByName("chkSelect");
		var tempArray = new Array();
		var tempObj;
		for(var i=0;i<objList.length;i++)
		{
			tempObj = objList[i];
			if(tempObj.checked)
			{
				tempArray.push(tempObj.value);
			}
		}
		return tempArray;
	}
    contact.prototype.alertError=function()
    {
        switch(this.curIntType)
		{
	        case "Product":
//		    case "ProductGallery":
//			     alert("Please select no more than ten products.");
//			     break;
//		    case "Supplier":
//			     alert("Please select no more than ten suppliers.");
//			     break;
//		    case "SellingLeads":
//		    case "SellingLeadsGallery":
//                 alert("Please select no more than ten selling leads.");
//                 break;
//            case "BuyLeads":
//                 alert("Please select no more than ten buying leads. ");
//                 break;
//            default:
//                 alert("Please select no more than ten products.");
//                 break;
	     }
    }
