function AddGiftGroupAll(candidateObjName, selectedObjName) {
    var strID = GetSelectedID(selectedObjName);
    var candidateObj = o(candidateObjName);
    var selectedObj = o(selectedObjName);
    for (var i = 0; i < candidateObj.length; i++) {
        if (strID.indexOf("|" + candidateObj.options[i].value + "|") == -1) {
            selectedObj.options[selectedObj.length] = new Option(candidateObj.options[i].text, candidateObj.options[i].value);
         }
    }
}
function AddGiftGroupSingle(candidateObjName, selectedObjName) {
    var strID = GetSelectedID(selectedObjName);
    var candidateObj = o(candidateObjName);
    var selectedObj = o(selectedObjName);
    for (var i = 0; i < candidateObj.length; i++) {
        if (candidateObj.options[i].selected && strID.indexOf("|" + candidateObj.options[i].value + "|") == -1) {
            selectedObj.options[selectedObj.length] = new Option(candidateObj.options[i].text, candidateObj.options[i].value);
        }
    }
}
//增加一条礼品组
function AddGiftGroup(name,count,idList,nameList,photoList,giftPackID){
    var countObj=o("GiftGroupCount");
    var parentObj=o("GiftGroup");
    var span = document.createElement("span");
    with (span) {
        id = "GiftGroup" + countObj.value;
        className="themeActivityBlock";
    }
    parentObj.appendChild(span);   
    alert(ReadContent(name,count,idList,nameList,photoList,countObj.value,giftPackID));
    span.innerHTML =ReadContent(name,count,idList,nameList,photoList,countObj.value,giftPackID) ;	
    o("GiftGroupCount").value=1+parseInt(countObj.value);
}
//修改一条礼品组
function UpdateGiftGroup(name,count,idList,nameList,photoList,id,giftPackID){
    var span = o("GiftGroup"+id);
    span.innerHTML =ReadContent(name,count,idList,nameList,photoList,id,giftPackID) ;	
}
//删除一条礼品组
function DeleteGiftGroup(id){
    var obj = o("GiftGroup" + id);
    obj.parentNode.removeChild(obj); 
}
//提交检查
function CheckSubmit() {
    CheckProductHandler("ctl00_ContentPlaceHolder_Product", "RelationProduct");
    Page_ClientValidate();
}
//读取内容
function ReadContent(name,count,idList,nameList,photoList,id,giftPackID){
    var result="<input type=\"button\" class=\"button\" onclick=\"childPop('GiftGroupAdd.aspx?Action=Update&ID="+id+"&GiftPackID="+giftPackID+"',650,600,'修改礼品组','GiftGroupAdd')\" value=\"修改产品组\"  style=\"width:80px\" />";
    result+="<input type=\"button\" class=\"button\" onclick=\"DeleteGiftGroup("+id+")\" value=\"删除礼品组\"  style=\"width:80px\" />";
    result+="<input name=\"GiftGroupValue"+id+"\" id=\"GiftGroupValue"+id+"\"  type=\"hidden\"  value=\""+name+"|"+count+"|"+idList +"\"/>";
	result+="<ul>";
	result+="<li class=\"left\">名称：</li>";
	result+="<li class=\"right\">"+name+"</li>";
	result+="</ul>";	
	result+="<ul>";
	result+="<li class=\"left\">购买数量：</li>";
	result+="<li class=\"right\">"+count +"</li>";
	result+="</ul>";	
	result+="<ul>";
	result+="<li class=\"left\">商品：</li>";
	result+="<li class=\"right\">";
	if(nameList!=""){
	    for(var i=0;i<nameList.split(",").length;i++)	{
	        result+="<div class=\"giftGroupPhoto\"><img  src=\""+photoList.split(",")[i]+"\" alt=\"\" onload=\"photoLoad(this,60,60)\" title=\""+nameList.split(",")[i]+"\"/><br />"+nameList.split(",")[i]+"</div>";
	    }
	}
    result+="</li>";
	result+="</ul>";
	result+="<input name=\"GiftGroupNameValue"+id+"\" id=\"GiftGroupNameValue"+id+"\"  type=\"hidden\"  value=\""+nameList +"\"/>";
	return result;
}
//读取一条礼品组数据
function ReadGiftGroup(id,giftPackID){
    var giftGroupValue=E.J( "#GiftGroupValue"+id, E.J.dialog.inndoc["GiftPackAdd"+giftPackID]).val();     
    var giftGroupNameValue=E.J( "#GiftGroupNameValue"+id, E.J.dialog.inndoc["GiftPackAdd"+giftPackID]).val(); 
    var valueArray=giftGroupValue.split("|");
    var nameArray=giftGroupNameValue.split(",");
    o("ctl00_ContentPlaceHolder_Name").value=valueArray[0];
    o("ctl00_ContentPlaceHolder_Count").value=valueArray[1]; 
    var productObj=o("ctl00_ContentPlaceHolder_Product");
    for (var i = 0; i < valueArray[2].split(",").length; i++) {
        var id=valueArray[2].split(",")[i];
        productObj.add(new Option(nameArray[i], id));
    }  
}