﻿//========================================================
// 创建自动导入
//Writer:       Cry
//create Date:    2008年3月29日
//parameters:
//returns:
//========================================================
createCueOnDivObj=function(type){
    //每次加载清空记录照片的数组
    if(!type){
        autoPhotoArr=null;
        autoPhotoArr=new Array();
    }
    var contentObj=document.getElementById('contentDiv');
    if(contentObj){
        MessageBox('选择照片','contentDiv');
        var photoFolderListCount=document.getElementById('photoFolderListCount');
        if(photoFolderListCount){
            photoFolderListCount.innerHTML='照片夹列表（共'+folderCount+'个)　　已经选择照片:<span style="color:red;font-size:12px;">'+autoPhotoArr.length+'</span>张';
        }
       
        //恢复照片夹的状态
        var index=0
        while(index<autoPhotoFolderArr.length){
           var photoCheck=document.getElementById('autoPhotoCheck'+autoPhotoFolderArr[index]);
           if(photoCheck){
               photoCheck.checked=true;
           }
           index++;
        }
       
        //恢复照片的选中状态
        var index=0
        while(index<autoPhotoArr.length){
           var photoCheck=document.getElementById('photoCheck'+autoPhotoArr[index].id);
           if(photoCheck){
               photoCheck.checked=true;
           }
           index++;
        }
        return;
    }
    var bodyObj=document.body;
    if(!bodyObj) return;
    
//    //创建白色遮照层
//    var divObj=document.createElement('div');
//    divObj.id='effect';
//    divObj.style.position='absolute';
//    divObj.style.top=0;
//    divObj.style.left=0;
//    divObj.style.width=document.body.offsetWidth;
//    divObj.style.height=document.body.offsetHeight;
//    divObj.style.backgroundColor='#ffffff';
//    if(document.all){
//        divObj.style.filter='Alpha(Opacity=50)';
//    }
//    bodyObj.appendChild(divObj);
//    //提示
//    var cueBodyObj=document.createElement('div');
//    cueBodyObj.id='cue';
//    cueBodyObj.style.position='absolute';
//    cueBodyObj.style.top=divObj.style.posHeight/2-237;
//    cueBodyObj.style.left=divObj.style.posWidth/2-532/2;
//    cueBodyObj.style.backgroundImage='url(../images/cen-tanchu_chucuo_bg.gif)';
//    cueBodyObj.style.width=532;
//    cueBodyObj.style.height=384;
//    bodyObj.appendChild(cueBodyObj);
//    
//    
//    var titleCueL=document.createElement('img');
//    titleCueL.style.position='relative';
//    cueBodyObj.appendChild(titleCueL);
//    titleCueL.src='../images/cen-tanchu_sl.gif';
//    
//    var titleCueC=document.createElement('img');
//    titleCueC.style.position='relative';
//    titleCueC.style.width='522px';
//    titleCueC.style.height='30px';
//    cueBodyObj.appendChild(titleCueC);
//    titleCueC.src='../images/cen-tanchu_bg.gif';
//    
//    var titleCueL=document.createElement('img');
//    titleCueL.style.position='relative';
//    cueBodyObj.appendChild(titleCueL);
//    titleCueL.src='../images/cen-tanchu_sr.gif';
//    
//    var closeDiv=document.createElement('img');
//    closeDiv.style.position='absolute';
//    closeDiv.style.top=5;
//    closeDiv.style.left=500;
//    closeDiv.style.cursor='pointer';
//    closeDiv.onclick=new Function('closeCueOnDivObj(\''+id+'\')');
//    cueBodyObj.appendChild(closeDiv);
//    closeDiv.src='../images/cen-tanchu_biao.gif';
    
    contentObj=document.createElement('div');
    contentObj.id='contentDiv';
    contentObj.style.position='relative';
    contentObj.style.width=530;
    contentObj.style.height=384;
    contentObj.style.backgroundColor='#ffffff'
    //contentObj.style.borderLeft='1px solid #E9C285';
    //contentObj.style.borderRight='1px solid #E9C285';
    bodyObj.appendChild(contentObj);
    
    contentObj.innerHTML=autoPhotoHTML();
    
    autoPhotoFolderAjax();
//    var titleCueL=document.createElement('img');
//    titleCueL.style.position='relative';
//    cueBodyObj.appendChild(titleCueL);
//    titleCueL.src='../images/cen-tanchu_xl.gif';
//    
//    var titleCueL=document.createElement('img');
//    titleCueL.style.position='relative';
//    cueBodyObj.appendChild(titleCueL);
//    titleCueL.src='../images/cen-tanchu_xr.gif';
    MessageBox('选择照片','contentDiv');
    var spanPageNumInfo = document.getElementById('spanPageNumInfo');
    spanPageNumInfo.innerHTML = currentPageNum;
}
//========================================================
// 关闭
//Writer:       Cry
//create Date:    2008年3月29日
//parameters:
//returns:
//========================================================
closeCueOnDivObj=function(id){
    //关闭遮照层
    var bodyObj=document.getElementById(id);
    if(!bodyObj) return;
    var cueObj=document.getElementById('effect');
    if(cueObj){
        bodyObj.removeChild(cueObj);
    }
    //关闭提示层
    var cueBodyObj=document.getElementById('cue');
    if(cueBodyObj){
        bodyObj.removeChild(cueBodyObj);
    }
}
//========================================================
// 创建自动导入图片
//Writer:       Cry
//create Date:    2008年3月29日
//parameters:
//returns:
//========================================================
autoPhotoHTML=function(){
    var html='<div style="width:400px; margin-left:55px;margin-top:10px;height:53px;background-image:url(../images/cen_xuanze_sbg.gif);">';
    html=html+'<img style="float:left;" src="../images/cen_xuanze_sleft.gif" />';
    html=html+'<span style="float:left; padding-top:26px;">您定制的产品页数:<span id="spanPageNumInfo" style="font-weight:bold; color:#5f871b;"></span>页</span>';
    html=html+'<img style="float:right;" src="../images/cen_xuanze_sright.gif" />';
    html=html+'</div>';
    html=html+'<div  style="border-bottom:1px solid #000000;margin-left:15px;margin-top:10px;height:29px;width:495px;text-align:left">';
    html=html+'<div id="photoFolderListCount" style="margin-top:10px;font-size:12px;margin-left:5px;float:left;width:300px;height:20px;"></div>';
    html=html+'<div style="margin-top:10px;margin-right:10px;float:right;width:70px;height:20px;">';
    html=html+'<img style="float:left;cursor:pointer" onclick="autoPhotoFolderAjax(\'del\')" src="../images/cen_xuanze_san1.gif" />';
    html=html+'<div id="pageNum" style="margin-left:6px;float:left;width:9px;height:5px;font-size:12px;">0/0</div>';
    html=html+'<img style="float:right;cursor:pointer" onclick="autoPhotoFolderAjax(\'add\')" src="../images/cen_xuanze_san2.gif" />';
    html=html+'</div></div>';
    return html;
}
//========================================================
// 加载照片夹ajax
//Writer:       Cry
//create Date:    2008年3月29日
//parameters: 
//returns:
//========================================================
var pageFolder=1;      //当前显示的是第几页
var pageFolderCount=0; //共能分几页
var folderCount=0;     //照片夹数量
autoPhotoFolderAjax=function(page){
    if(page=='add'){
        pageFolder++;
        if(pageFolder!=1){
            if(pageFolder>pageFolderCount){
                pageFolder--;
            }
        }
    }
    if(page=='del'){
        pageFolder--;
        if(pageFolder<=0){
           pageFolder=1;
           return;
        }
    }
    var url='/PhookProduct/Ajax/GetPhotoFolder.aspx?pagefolder='+pageFolder;
    enuOnAjax(url,null,autoPhotoFolder,'POST');
}
//========================================================
// 加载照片夹
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
autoPhotoFolder=function(data){
    if(!data) return;
    var contentObj=document.getElementById('contentDiv');
    if(!contentObj) return;
    var strArr=data.split('|');
    if(strArr.length>0){
        var photoFolderDiv=document.getElementById('photoFolderDiv');
        if(!photoFolderDiv){
            photoFolderDiv=document.createElement('div');
            photoFolderDiv.id='photoFolderDiv';
            photoFolderDiv.style.width=470;
            photoFolderDiv.style.height=90;
            photoFolderDiv.style.marginTop=10;
            photoFolderDiv.style.marginLeft=32;
            contentObj.appendChild(photoFolderDiv);
        }
        else{
            photoFolderDiv.innerHTML='';
        }
        var photoFolderId=0;
        for(var i=0 ;i<strArr.length;i++)
        {
            if(i==0){
                var divArr=strArr[i].split('*');
                folderCount=divArr[0];
                pageFolderCount=divArr[1];
                continue;
            }
            if(!strArr[i]) continue;
            var divArr=strArr[i].split('*');
            var divObj=document.createElement('div');
            divObj.style.position='relative';
            divObj.style.styleFloat='left';
            divObj.style.width=60;
            divObj.style.height=90;
            //divObj.style.backgroundColor='#00ffff';
            if(i!=1){
                divObj.style.marginLeft=21;
            }
            else{
                photoFolderId=divArr[0];
            }
            photoFolderDiv.appendChild(divObj);
            //创建图片显示
            var divPhotoFolderObj=document.createElement('div');
            divPhotoFolderObj.className = 'photoFolder50';
            var imgObj=document.createElement('img')
            imgObj.onclick=new Function('autoPhotoAjax(\''+divArr[0]+'\')');
            imgObj.style.cursor='pointer';
            divPhotoFolderObj.appendChild(imgObj);
            
            divObj.appendChild(divPhotoFolderObj);
            imgObj.src=divArr[1];
            //创建图片选择和数量提示层
            var divCountObj=document.createElement('div');
            divCountObj.style.width=60;
            divCountObj.style.height=20;
            divCountObj.style.marginTop=10;
            //divCountObj.style.backgroundColor='#ff00ff';
            divObj.appendChild(divCountObj);
            divCountObj.innerHTML='<input id="autoPhotoCheck'+divArr[0]+'" onclick="autoPhotoAll(\''+divArr[0]+'\');" style="marginLeft:4px;float:left" type="checkbox" name="checked'+divArr[0]+'">';
            
            var countObj=document.createElement('div');
            with(countObj.style){
                position='relative';
                styleFloat='left';
                fontSize=10;
                marginleft=5;
                width=40;
                height=20;
            }
            divCountObj.appendChild(countObj);
            
            var biaoObj=document.createElement('img');
            with(biaoObj.style){
                styleFloat='left';
                marginTop=5;
                marginLeft=10;
            }
            countObj.appendChild(biaoObj);
            biaoObj.src='/images/biao_04.gif';
            var count=document.createElement('div');
            with(count.style){
                styleFloat='left';
                marginTop=5;
                width=15;
                textAlign='center';
                backgroundColor='#E5E4E2';
            }
            count.innerHTML=divArr[2];
            countObj.appendChild(count);
        }
    }
    var pageNum=document.getElementById('pageNum');
    if(pageNum){
        pageNum.innerHTML=pageFolder+'/'+pageFolderCount;
    }
    var photoDivObj=document.getElementById('photoDiv');
    if(!photoDivObj){
        photoDivObj=document.createElement('div')
        photoDivObj.id='photoDiv';
        with(photoDivObj.style){
            width=500;
            height=158;
            border='1px solid #B0B0B0';
            marginTop=15;
            marginLeft=14;
        }
        var html='<div style="margin-top:10px;float:right;width:70px;height:20px;">';
        html=html+'<img style="float:left;cursor:pointer" onclick="autoPhotoFolderAjax(\'del\')" src="../images/cen_xuanze_san1.gif" />';
        html=html+'<div id="pageNum" style="margin-left:6px;float:left;width:9px;height:5px;font-size:12px;">1/4</div>';
        html=html+'<img style="float:right;cursor:pointer" onclick="autoPhotoFolderAjax(\'add\')" src="../images/cen_xuanze_san2.gif" />';
        html=html+'</div>';
        photoDivObj.innerHTML=html;
        contentObj.appendChild(photoDivObj);
    }
    var nextStepObj=document.getElementById('nextStep');
    if(!nextStepObj){
        nextStepObj=document.createElement('div');
        nextStepObj.id='nextStep';
        with(nextStepObj.style){
            styleFloat='right';
            height=20;
            marginTop=5;
            marginRight=10;
            cursor = 'pointer';
        }
        nextStepObj.innerHTML = '<img alt="" src="/images/cen-tanchu_biao1.gif" />选择好了？';
        nextStepObj.innerHTML +='<span onclick="createSeePhoto();" style="color:#fe760a; cursor:pointer; font-weight:bold;">下一步</span>';
        
        contentObj.appendChild(nextStepObj);
    }
    autoPhotoAjax(photoFolderId);
}
//========================================================
// 加载照片ajax
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
var photo=1;      //当前显示照片是第几页
var photoCount=0; //共能分几页
var photoFolderTestId=0;
autoPhotoAjax=function(id,check,page){
    if(page=='add'){
        photo++;
        if(photo!=1){
            if(photo>photoCount){
                photo--;
            }
        }
    }
    if(page=='del'){
        photo--;
        if(photo<=0){
           photo=1;
           return;
        }
    }
    photo=id?1:photo;
    photoFolderTestId = id || photoFolderTestId;
    var url='/PhookProduct/Ajax/GetPhotoFolder.aspx?id='+photoFolderTestId+'&pagefolder='+photo;
    enuOnAjax(url,null,autoPhoto,'POST',check);
    //恢复照片夹的状态
    var index=0
    while(index<autoPhotoFolderArr.length){
       var photoCheck=document.getElementById('autoPhotoCheck'+autoPhotoFolderArr[index]);
       if(photoCheck){
           photoCheck.checked=true;
       }
       index++;
    }
}
//========================================================
// 加载照片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
var autoPhotoArr=new Array(); //记录用户选中的照片
autoPhoto=function(data,check){
    if(!data) return;
    var photoDivObj=document.getElementById('photoDiv');
    if(!photoDivObj) return;
    var html='<div style="background-color:#EBEBEB;float:left;width:500px;"><div style="margin-right:12px;margin-top:4px;float:right;width:70px;height:20px;">';
    html=html+'<img style="float:left;cursor:pointer" onclick="autoPhotoAjax(null,null,\'del\')" src="../images/cen_xuanze_san1.gif" />';
    html=html+'<div id="photoNum" style="margin-left:6px;float:left;width:9px;height:5px;font-size:12px;">1/4</div>';
    html=html+'<img style="float:right;cursor:pointer" onclick="autoPhotoAjax(null,null,\'add\')" src="../images/cen_xuanze_san2.gif" />';
    html=html+'</div></div>';
    photoDivObj.innerHTML=html;
    var strArr=data.split('|');
    if(strArr.length>0){
        for(var i=0 ;i<strArr.length;i++){
            var divArr=strArr[i].split('*');
            if(i==0){
                photoCount=divArr[1];
                continue;
            }
            //全选在最后处理
            if(i==1){
                var allIndex=0
                if(check!=true && check!=false) continue;
                while(allIndex<divArr.length){
                    var photoArr=divArr[allIndex].split('#');
                    if(check==true){
                        var arrIndex=isIdExist(autoPhotoArr,photoArr[0]);
                        //添加用户选中的照片
                        if(arrIndex==-1){
                            autoPhotoArr.push(new classAutoPhoto(photoArr[0],photoArr[1]));
                        }
                    }
                    if(check==false){
                        var arrIndex=isIdExist(autoPhotoArr,photoArr[0]);
                        //删除用户选中的照片
                        if(arrIndex!=-1){
                            autoPhotoArr.splice(arrIndex,1);
                        }
                    }
                    allIndex++;
                }
                continue;
            } 
            if(!strArr[i]) continue;
            //创建容器，容纳图片和复选框
            var divObj=document.createElement('div');
            divObj.id='photoDiv'+divArr[0];
            with(divObj.style){
                position='relative';
                width=54;
                height=54;
                marginTop=5;
                marginLeft=11;
                styleFloat='left';
                border='1px solid #DCDCDC';
            }
            photoDivObj.appendChild(divObj);
            //创建图片
            var imgObj=document.createElement('img');
            //imgObj.onclick=new Function('autoPhotoArrAdd(\''+divArr[0]+'\')');
            imgObj.onclick=new Function('autoPhotoArrAdd(\''+divArr[0]+'\',\''+divArr[1]+'\',true)');
            imgObj.id='photo'+divArr[0];
            with(imgObj.style){
                cursor='pointer';
                marginTop=2;
                marginLeft=2;
            }
            divObj.appendChild(imgObj);
            imgObj.src=divArr[1];
            //创建复选框
            var checkDivObj=document.createElement('div');
            checkDivObj.id='check'+divArr[0];
            with(checkDivObj.style){
                position='absolute';
                top=35;
                left=-2;
            }
            checkDivObj.innerHTML='<input onclick="autoPhotoArrAdd('+divArr[0]+',\''+divArr[1]+'\');" id="photoCheck'+divArr[0]+'" style="float:left" type="checkbox" >';
            divObj.appendChild(checkDivObj);
            if(check==true || check==false){
                if(check){
                    var photoCheck=document.getElementById('photoCheck'+divArr[0]);
                    if(photoCheck){
                        photoCheck.checked=true;
                    }
                }
                else{
                    var photoCheck=document.getElementById('photoCheck'+divArr[0]);
                    if(photoCheck){
                        photoCheck.checked=false;
                    }
                }
            }
            else{
                //普通点击（不是全选点击和反选点击）
                if(i+1==strArr.length){
                    var index=0
                    while(index<autoPhotoArr.length){
                       var photoCheck=document.getElementById('photoCheck'+autoPhotoArr[index].id);
                       if(photoCheck){
                           photoCheck.checked=true;
                       }
                       index++;
                    }
                }
            }
            var photoFolderListCount=document.getElementById('photoFolderListCount');
            if(photoFolderListCount){
                photoFolderListCount.innerHTML='照片夹列表（共'+folderCount+'个)　　已经选择照片:<font style="color:red;font-size:16px;">'+autoPhotoArr.length+'</font>张';
            }
        }
        var photoNum=document.getElementById('photoNum');
        if(photoNum){
            photoNum.innerHTML=photo+'/'+photoCount;
        }
    }
}
//========================================================
// 选择全部照片夹的照片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
autoPhotoFolderArr=new Array(); //记录照片夹的状态
autoPhotoAll=function(folderId){
    var autoPhotoCheck=document.getElementById('autoPhotoCheck'+folderId);
    if(autoPhotoCheck && autoPhotoCheck.checked){
       var arrIndex=isExist(autoPhotoFolderArr,folderId);
       //添加用户选中的照片夹
       if(arrIndex==-1){
           autoPhotoFolderArr.push(folderId);
       }autoPhotoAjax(folderId,true);
    }
    else{
        var arrIndex=isExist(autoPhotoFolderArr,folderId);
        //删除
        if(arrIndex!=-1){
            autoPhotoFolderArr.splice(arrIndex,1);
        }
        autoPhotoAjax(folderId,false);
    }
}
//========================================================
// 单选图片添加事件
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
autoPhotoArrAdd=function(id,src,isChecked){

    var photoCheck=document.getElementById('photoCheck'+id);
    if(photoCheck && isChecked){
        photoCheck.checked=photoCheck.checked?false:true;
    }
    if(photoCheck && photoCheck.checked){
        var arrIndex=isIdExist(autoPhotoArr,id);
        //添加用户选中的照片
        if(arrIndex=-1){
            autoPhotoArr.push(new classAutoPhoto(id,src));
        }
    }
    else{
        var arrIndex=isIdExist(autoPhotoArr,id);
        if(arrIndex!=-1){
            autoPhotoArr.splice(arrIndex,1);
        }
    }
    var photoFolderListCount=document.getElementById('photoFolderListCount');
    if(photoFolderListCount){
        photoFolderListCount.innerHTML='照片夹列表（共'+folderCount+'个)　　已经选择照片:<font style="color:red;font-size:16px;">'+autoPhotoArr.length+'</font>张';
    }
}
//========================================================
// 判断某元素时候在某数组中
//Writer:       Cry
//create Date:    2008年3月31日
//parameters:某数组，某元素 
//returns: 如果存在返回索引，否则返回-1
//========================================================
isExist=function(arr,element){
    for(var i=0;i<arr.length;i++){
        if(arr[i]==element) return i;
    }
    return -1;
}
isIdExist=function(arr,element){
    for(var i=0;i<arr.length;i++){
        if(arr[i].id==element) return i;
    }
    return -1;
}
//========================================================
// 自动导入图片对象
//Writer:       Cry
//create Date:    2008年3月31日
//parameters:某数组，某元素 
//returns: 如果存在返回索引，否则返回-1
//========================================================
function classAutoPhoto(id,src){
    this.id=id;
    this.src=src;
}

enuOnAjax=function(url,data,callback,RTS,parameter){
        var http_request = window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	    function httpSuccess(r){
		    try {
			    return !r.status && location.protocol=="file:" || ( r.status >= 200 && r.status < 300 ) || r.status == 304
		    } catch(e){}
		    return false;
	    }
        function onreadystatechange(){
			if(http_request.readyState==4){
			    if(httpSuccess(http_request))if(callback)callback(http_request.responseText,parameter);
                if( async )http_request = null;
            }
        }
        //if(!window.ActiveXObject){ RTS="";}
		RTS = RTS || 'GET';
		var async=callback?true:false;
        // 打开连接
        http_request.open(RTS, url, async);
        // 如果是post，则设置请求头
        if(RTS=='POST')http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        if(async)http_request.onreadystatechange = onreadystatechange;
        // 发送请求
        http_request.send(data);
		if(!async){
		    var text=http_request.responseText;
		    http_request=null;
            return text;
		}
		return null;
}

//========================================================
// 创建查看选择好的图片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
createSeePhoto=function(){
    var bodyObj=document.body;
    if(!bodyObj) return;
    var contentObj=document.createElement('div');
    contentObj.id='seePhotoDiv';
    contentObj.style.position='relative';
    contentObj.style.width=530;
    contentObj.style.height=384;
    contentObj.style.backgroundColor='#ffffff'
    //contentObj.style.borderLeft='1px solid #E9C285';
    //contentObj.style.borderRight='1px solid #E9C285';
    bodyObj.appendChild(contentObj);
    
    contentObj.innerHTML=seePhotoHTML();
    
    MessageBox('选择照片','seePhotoDiv');
    
    loadSeePhoto();
}
//========================================================
// 创建查看基本html
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
seePhotoHTML=function(){
    var html='<img style="margin-left:55px;margin-top:10px;" src="../images/cen_xuanze_sleft.gif" />';
    html=html+'<img style="margin-top:10px;height:53px;width:368;" src="../images/cen_xuanze_sbg.gif" />';
    html=html+'<img style="margin-top:10px;" src="../images/cen_xuanze_sright.gif" />';
    html=html+'<div  style="border-bottom:1px solid #000000;margin-left:15px;margin-top:10px;height:29px;width:495px;text-align:left">';
    html=html+'<div id="seePhotoCount" style="margin-top:10px;font-size:12px;margin-left:5px;float:left;width:300px;height:20px;"></div>';
    html=html+'<div style="margin-top:10px;margin-right:10px;float:right;width:70px;height:20px;">';
    html=html+'<img style="float:left;cursor:pointer" onclick="seePhotoFormFeed(\'del\')"   src="../images/cen_xuanze_san1.gif" />';
    html=html+'<div id="seePhotoNum" style="margin-left:6px;float:left;width:9px;height:5px;font-size:12px;">1/4</div>';
    html=html+'<img style="float:right;cursor:pointer" onclick="seePhotoFormFeed(\'add\')"   src="../images/cen_xuanze_san2.gif" />';
    html=html+'</div>';
    html=html+'</div>';

    return html;
}
//========================================================
// 计算分页
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
accountSeePhotoMaxPage=function(){
    seePhotoMaxPage=autoPhotoArr.length/seePhotoOnePageCount;
    var seePhotoMaxPageArr=seePhotoMaxPage.toString().split('.');
    if(seePhotoMaxPageArr[1]){
        seePhotoMaxPage=parseInt(seePhotoMaxPage)+1;
    }
}
//========================================================
// 加载查看照片的中元素
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
var seePhotoPage=1;          //当前是第几页
var seePhotoOnePageCount=28; //每页显示的数量
var seePhotoMaxPage=1
loadSeePhoto=function(){
    var seePhotoDiv=document.getElementById('seePhotoDiv');
    if(!seePhotoDiv) return;
    var seePhotoCount=document.getElementById('seePhotoCount');
    if(seePhotoCount){
        seePhotoCount.innerHTML='您共选择了<span style="color:red;font-size:12px;">'+autoPhotoArr.length+'</span>张照片';
    }
    //计算分页
    accountSeePhotoMaxPage();
    var seeContentPhoto=document.getElementById('seeContentPhoto');
    if(!seeContentPhoto){
        seeContentPhoto=document.createElement('div');
        seeContentPhoto.id='seeContentPhoto';
        with(seeContentPhoto.style){
            styleFloat='left';
            width=500;
            height=263;
            marginLeft=7;
            borderBottom='1px solid #B0B0B0';
        }
        seePhotoDiv.appendChild(seeContentPhoto);
    }
    var nextseePhotoStep=document.getElementById('nextseePhotoStep');
    if(!nextseePhotoStep){
        nextseePhotoStep=document.createElement('img');
        nextseePhotoStep.id='nextseePhotoStep';
        nextseePhotoStep.onclick=new Function('createCueOnDivObj(\'back\')');
        with(nextseePhotoStep.style){
            styleFloat='left';
            marginLeft=30;
            marginTop=5;
            cursor='pointer';
        }
        seePhotoDiv.appendChild(nextseePhotoStep);
        
        nextseePhotoStep.src='../images/cen_xuanze_san3.gif';
    }
    
    //导入照片按钮层
    var finishseePhotoStep=document.getElementById('finishseePhotoStep');
    if(!finishseePhotoStep){
        finishseePhotoStep=document.createElement('div');
        finishseePhotoStep.id='finishseePhotoStep';
        with(finishseePhotoStep.style){
            styleFloat='right';
            marginRight=10;
            marginTop=5;
        }
        seePhotoDiv.appendChild(finishseePhotoStep);
        finishseePhotoStep.innerHTML = '<img alt="" src="/images/cen-tanchu_biao1.gif" />选择完成！';
        finishseePhotoStep.innerHTML +='<span onclick="submitImageList();" style="color:#fe760a; cursor:pointer; font-weight:bold;">导入照片</span>';
        
    }
    
    
    //加载内页
    seePagePhoto();
}
//========================================================
// 获取当前页第1张图片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
getBeginNum=function(page,pageCount) {
    return pageCount * (page - 1) + 1;
}
//========================================================
// 获取当前页最后1张图片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
getEndNum=function(beginNum,allPhoto,pageCount){
        if (beginNum + pageCount > allPhoto)
        {
            return allPhoto;
        }
        else
        {
            return beginNum + pageCount - 1;
        }
}
//========================================================
// 加载图片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
seePagePhoto=function(){
    var seeContentPhoto=document.getElementById('seeContentPhoto');
    if(!seeContentPhoto) return 
    seeContentPhoto.innerHTML='';
     //获取开始值
    var seeIndex=getBeginNum(seePhotoPage,seePhotoOnePageCount)
    //获取结束值
    var endIndex=getEndNum(seeIndex,autoPhotoArr.length,seePhotoOnePageCount);
    while(seeIndex<=endIndex){
        //创建容器，容纳图片和复选框
        var divObj=document.createElement('div');
        divObj.id='photoDiv'+autoPhotoArr[seeIndex-1].id;
        with(divObj.style){
            position='relative';
            width=54;
            height=54;
            marginTop=8;
            marginLeft=11;
            styleFloat='left';
            border='1px solid #DCDCDC';
        }
        seeContentPhoto.appendChild(divObj);
        //创建图片
        var imgObj=document.createElement('img');
       
        imgObj.id='photo'+autoPhotoArr[seeIndex-1].id;
        with(imgObj.style){
            marginTop=2;
            marginLeft=2;
        }
        divObj.appendChild(imgObj);
        imgObj.src=autoPhotoArr[seeIndex-1].src;
        var delImgObj=document.createElement('img');
        delImgObj.id='delImg'+autoPhotoArr[seeIndex-1].id;
        delImgObj.onclick=new Function('delAutoPhoto(\''+autoPhotoArr[seeIndex-1].id+'\')');
        with(delImgObj.style){
            cursor='pointer';
            position='absolute';
            top=43;
            left=43;
        }
        divObj.appendChild(delImgObj);
        delImgObj.src='../images/cen_xuanze_sbiao.gif';
        
        seeIndex++;       
    }
    var seePhotoNum=document.getElementById('seePhotoNum');
    if(seePhotoNum){
         seePhotoNum.innerHTML=seePhotoPage+'/'+seePhotoMaxPage;
    }
}
//========================================================
// 换页
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
seePhotoFormFeed=function(type){
    if(type=='del'){
        if(seePhotoPage==1) return;
        seePhotoPage--;
        seePagePhoto();
    }
    if(type=='add'){
        if(seePhotoPage+1>seePhotoMaxPage) return;
        
        seePhotoPage++;
        seePagePhoto();
    }
}
//========================================================
// 删除已经选择的图片
//Writer:       Cry
//create Date:    2008年3月31日
//parameters: 
//returns:
//========================================================
delAutoPhoto=function(id){
     var arrIndex=isIdExist(autoPhotoArr,id);
     //删除用户选中的照片
     if(arrIndex!=-1){
         autoPhotoArr.splice(arrIndex,1);
     }
     //重新计算分页
     accountSeePhotoMaxPage();
     //加载新照片
     seePagePhoto();
     //刷新总的照片数量
     var seePhotoCount=document.getElementById('seePhotoCount');
     if(seePhotoCount){
         seePhotoCount.innerHTML='您共选择了<font style="color:red;font-size:16px;">'+autoPhotoArr.length+'</font>张照片';
     }
}

//========================================================
// 将选择的照片自动导入到作品中
//Writer:       ZjFree
//create Date:    2008年4月2日
//parameters: 
//returns:
//========================================================
var strIds = '';
submitImageList=function(){
	if(autoPhotoArr.length == 0){
		alert('请选择照片');
		return;
	}
	strIds = '';
	for(var i=0; i<autoPhotoArr.length; i++){
		strIds += ((i==0)?'':',') + autoPhotoArr[i].id;
	}
	MessageBox_Close();
	
	showLoading('正在自动将选择的照片导入作品，请稍候...');
	var strType = (isPhook ? 'auto_create_phook_product' : 'auto_create_product');
	ajax({type:strType,photoIdList:strIds,productId:currentProductId,pageNum:currentPageNum},autoCreateProductFinish);
}

//========================================================
// 自动导入的结果
//Writer:       ZjFree
//create Date:    2008年4月2日
//parameters: 
//returns:
//========================================================
function autoCreateProductFinish(o)
{
	MessageBox_Close();
	if(o.isError)
	{
		alert(o.error);
		return;
	}
	goEditor('/PhookEditer/default.aspx?pid=' + o.data);
}


// 选择照片
var currentProductId;
var isPhook = false;
function selectPhotos(productId,isPhookProduct)
{
	currentProductId = productId;
	isPhook = isPhookProduct;
	if(currentUserId == 0)
	{
		MessageBox('未登陆','divMsgNoLogin');
		var aTestPhookProduct = document.getElementById('aTestPhookProduct');
		aTestPhookProduct.style.display = (isPhook ? 'inline' : 'none');
		return;
	}
	
	showLoading('正在获取当前用户的照片数');
	
	// 检测当前用户的照片数量
	ajax({type:'get_current_user_photo_count'},getCurrentUserPhotoCountBack);
	
}



// 获取当前用户的照片数量回调函数
function getCurrentUserPhotoCountBack(o)
{
	MessageBox_Close();
	if(!o.isError)
	{
		if(o.data > 0)
		{
			// 显示选择导入方式
			MessageBox('照片导入方式选择','divMsgSelectInputType');
		}
		else
		{
			noAutoImportPhoto();
		}
	}
	else
	{
		alert(o.error);
	}
}

//　选择导入方式
function selectInputPhotoImportType()
{
	var isAuto = document.getElementById('inputPhotoImportType1').checked;
	MessageBox_Close();
	if(isAuto)
	{
		if(isPhook)
		{
		    //createAutoCover();
			AutoProductPhotoInit(currentProductId,currentPageNum,formatMoney(currentPrice),true);
		}
		else
		{
			createCueOnDivObj();
		}
	}
	else
	{
		noAutoImportPhoto();
	}	
}

// 不自动导入
function noAutoImportPhoto()
{
	if(isPhook)
	{
		goEditor('/PhookEditer/default.aspx?kid=' + currentProductId + (currentPageNum?('&pagenum=' + currentPageNum):''));
	}
	else
	{
		showLoading('正在生成作品，请稍候...');
		ajax({type:'auto_create_product',photoIdList:strIds,productId:currentProductId,pfeid:pfeId,size:cSize},autoCreateProductFinish);
	}	
}

// 体验一下
function testPhookProduct()
{
	goEditor('/PhookEditer/default.aspx?kid=' + currentProductId + (currentPageNum?('&pagenum=' + currentPageNum):''));
}

// 转向编辑器
function goEditor(url)
{
	if(photoFolderId && photoFolderId != 0)
	{
		url += '&pfid=' + photoFolderId;
	}
	if(isFree && isFree == 1)
	{
		url +='&isFree=1';
	}
	if(jid)
	{
		url +='&jid=' + jid;
	}
	if(phookProductThemeName)
	{
		url +='&themeName=' + phookProductThemeName;
	}
	if(phookProductTagName)
	{
		url +='&tagName=' + phookProductTagName;
	}
	if (pfeId)
	{
		url += '&pfeid=' + pfeId;
	}
	if (cSize)
	{
		url += '&size=' + cSize
	}
	window.navigate(url);
}

// 加载中...
function showLoading(str)
{
	var spanLoading = document.getElementById('spanLoading');
	spanLoading.innerHTML = str;
	MessageBox_NoClose('加载中...','divLoading');
}

// 显示主题规格选择
var currentPhookProductList;
function showPhookProductFormatSelect(o)
{	
	currentPhookProductList = o;
	// 获取价格单
	showLoading('正在加载数据...');
	ajax({type:'get_product_format_price_list'},getProductFormatPriceListBack);
}

// 获取产品价格列表
var productFormatPriceList;
function getProductFormatPriceListBack(o)
{
	MessageBox_Close();
	if(!o.isError)
	{
		productFormatPriceList = o.data;
	}
	
	MessageBox('请选择规格','divMsgSelectProductFormat');
	var tbProductHC_H = document.getElementById('tbProductHC_H');
	var tbProductHC_F = document.getElementById('tbProductHC_F');
	var tbProductHC_S = document.getElementById('tbProductHC_S');
	tbProductHC_H.style.display = 'none';
	tbProductHC_F.style.display = 'none';
	tbProductHC_S.style.display = 'none';
	
	switch(currentPhookProductList.type)
	{
		case 'hc_hs':
			tbProductHC_H.style.display = 'block';
			break;
		case 'hc_fs':
			tbProductHC_F.style.display = 'block';
			break;
		case 'hc_ss':
			tbProductHC_S.style.display = 'block';
			break;
	}
	// 验证主题产品的可用性
	
	// 获取价格
	getProductPrice();
	var divMsgSelectProductFormat = document.getElementById('divMsgSelectProductFormat');
	var inputs = divMsgSelectProductFormat.getElementsByTagName('input');
	for(var i=0; i<inputs.length; i++)
	{
		if(inputs[i].type == 'radio')
		{
			inputs[i].onclick = getProductPrice;
		}
	}
}

// 验证主题产品的可用性
function checkPhookProduct()
{
	
}

// 计算产品价格
var currentPhookProduct;
var currentPageNum = 0;
var currentPrice = 0;
var isFree = 0;
var jid = 0;
function getProductPrice()
{
	var productFormatId;
	var pageNum;
	var price = 0;
	currentPhookProduct = 0;
	currentPageNum = 0;
	var spanPhookProductPrice = document.getElementById('spanPhookProductPrice');
	var rdH1 = document.getElementById('rdH1');
	var rdH2 = document.getElementById('rdH2');
	var rdH3 = document.getElementById('rdH3');
	var rdH4 = document.getElementById('rdH4');
	var rdH5 = document.getElementById('rdH5');
	var rdF1 = document.getElementById('rdF1');
	var rdF2 = document.getElementById('rdF2');
	var rdF3 = document.getElementById('rdF3');
	var rdF4 = document.getElementById('rdF4');
	var rdS1 = document.getElementById('rdS1');
	var rdS2 = document.getElementById('rdS2');
	var rdS3 = document.getElementById('rdS3');
	var rdS4 = document.getElementById('rdS4');
	var imgH1 = document.getElementById('imgH1');
	var imgH2 = document.getElementById('imgH2');
	var imgH3 = document.getElementById('imgH3');
	var imgH4 = document.getElementById('imgH4');
	var imgH5 = document.getElementById('imgH5');
	var imgF1 = document.getElementById('imgF1');
	var imgF2 = document.getElementById('imgF2');
	var imgF3 = document.getElementById('imgF3');
	var imgF4 = document.getElementById('imgF4');
	var imgS1 = document.getElementById('imgS1');
	var imgS2 = document.getElementById('imgS2');
	var imgS3 = document.getElementById('imgS3');
	var imgS4 = document.getElementById('imgS4');
	imgH1.src = imgH1.src.replace('hc1','hc2');
	imgH2.src = imgH2.src.replace('hc1','hc2');
	imgH3.src = imgH3.src.replace('hc1','hc2');
	imgH4.src = imgH4.src.replace('hc1','hc2');
	imgH5.src = imgH5.src.replace('hc1','hc2');
	imgF1.src = imgF1.src.replace('hc1','hc2');
	imgF2.src = imgF2.src.replace('hc1','hc2');
	imgF3.src = imgF3.src.replace('hc1','hc2');
	imgF4.src = imgF4.src.replace('hc1','hc2');
	imgS1.src = imgS1.src.replace('hc1','hc2');
	imgS2.src = imgS2.src.replace('hc1','hc2');
	imgS3.src = imgS3.src.replace('hc1','hc2');
	imgS4.src = imgS4.src.replace('hc1','hc2');
	var rdPageNum12 = document.getElementById('rdPageNum12');
	var rdPageNum16 = document.getElementById('rdPageNum16');
	var rdPageNum24 = document.getElementById('rdPageNum24');
	var rdPageNum32 = document.getElementById('rdPageNum32');
	var rdPageNum36 = document.getElementById('rdPageNum36');
	var rdPageNum40 = document.getElementById('rdPageNum40');
	//imgid
	var imgId12 = document.getElementById('id12');
	var imgId16 = document.getElementById('id16');
    var imgId24 = document.getElementById('id24');
    var imgId32 = document.getElementById('id32');
    var imgId36 = document.getElementById('id36');
    var imgId40 = document.getElementById('id40');
	
	switch(currentPhookProductList.type)
	{
		case 'hc_hs':
			if(rdH1.checked)
			{
				productFormatId = 111;
				imgH1.src = imgH1.src.replace('hc2','hc1');
			}
			else if(rdH2.checked)
			{
				productFormatId = 112;
				imgH2.src = imgH2.src.replace('hc2','hc1');
			}
			else if(rdH3.checked)
			{
				productFormatId = 113;
				imgH3.src = imgH3.src.replace('hc2','hc1');
			}
			else if(rdH4.checked)
			{
				productFormatId = 114;
				imgH4.src = imgH4.src.replace('hc2','hc1');
			}
			else if(rdH5.checked)
			{
				productFormatId = 115;
				imgH5.src = imgH5.src.replace('hc2','hc1');
			}
			break;
		case 'hc_fs':
			if(rdF1.checked)
			{
				productFormatId = 121;
				imgF1.src = imgF1.src.replace('hc2','hc1');
			}
			else if(rdF2.checked)
			{
				productFormatId = 122;
				imgF2.src = imgF2.src.replace('hc2','hc1');
			}
			else if(rdF3.checked)
			{
				productFormatId = 123;
				imgF3.src = imgF3.src.replace('hc2','hc1');
			}
			else if(rdF4.checked)
			{
				productFormatId = 124;
				imgF4.src = imgF4.src.replace('hc2','hc1');
			}
			break;
		case 'hc_ss':
			if(rdS1.checked)
			{
				productFormatId = 131;
				imgS1.src = imgS1.src.replace('hc2','hc1');
			}
			else if(rdS2.checked)
			{
				productFormatId = 132;
				imgS2.src = imgS2.src.replace('hc2','hc1');
			}
			else if(rdS3.checked)
			{
				productFormatId = 133;
				imgS3.src = imgS3.src.replace('hc2','hc1');
			}
			else if(rdS4.checked)
			{
				productFormatId = 134;
				imgS4.src = imgS4.src.replace('hc2','hc1');
			}
			break;
	}
	
	// 获取可用页数
	rdPageNum12.disabled = true;
	rdPageNum16.disabled = true;
	rdPageNum24.disabled = true;
	rdPageNum32.disabled = true;
	rdPageNum36.disabled = true;
	rdPageNum40.disabled = true;
	for(var i=0; i<productFormatPriceList.length; i++)
	{
		if(productFormatPriceList[i].productFormatId == productFormatId)
		{
			switch(productFormatPriceList[i].pageNum)
			{
				case 12:
					rdPageNum12.disabled = (productFormatPriceList[i].price == 0);
					break;
				case 16:
					rdPageNum16.disabled = (productFormatPriceList[i].price == 0);
					break;
				case 24:
					rdPageNum24.disabled = (productFormatPriceList[i].price == 0);
					break;
				case 32:
					rdPageNum32.disabled = (productFormatPriceList[i].price == 0);
					break;
                case 36:
					rdPageNum36.disabled = (productFormatPriceList[i].price == 0);
					break;
				case 40:
					rdPageNum40.disabled = (productFormatPriceList[i].price == 0);
					break;
			}
		}
	}
	if((rdPageNum12.disabled && rdPageNum12.checked) || 
	(rdPageNum16.disabled && rdPageNum16.checked) || 
	(rdPageNum24.disabled && rdPageNum24.checked) || 
	(rdPageNum32.disabled && rdPageNum32.checked) || 
	(rdPageNum36.disabled && rdPageNum36.checked) ||
	(rdPageNum40.disabled && rdPageNum40.checked))
	{
		rdPageNum12.checked = false;
		rdPageNum16.checked = false;
		rdPageNum24.checked = false;
		rdPageNum32.checked = false;
		rdPageNum36.checked = false;
		rdPageNum40.checked = false;
		if(!rdPageNum12.disabled)
		{
			rdPageNum12.checked = true;
		}
		if(!rdPageNum16.disabled)
		{
			rdPageNum16.checked = true;
		}
		else if(!rdPageNum24.disabled)
		{
			rdPageNum24.checked = true;
		}
		else if(!rdPageNum32.disabled)
		{
			rdPageNum32.checked = true;
		}
		else if(!rdPageNum36.disabled)
		{
			rdPageNum36.checked = true;
		}
		else if(!rdPageNum40.disabled)
		{
			rdPageNum40.checked = true;
		}
	}
	
//	if(rdPageNum16.checked)
//	{
//		pageNum = 16;
//	}
//	else if(rdPageNum24.checked)
//	{
//		pageNum = 24;
//	}
//	else if(rdPageNum32.checked)
//	{
//		pageNum = 32;
//	}
//	else if(rdPageNum36.checked)
//	{
//		pageNum = 36;
//	}
//	else if(rdPageNum40.checked)
//	{
//		pageNum = 40;
//	}
    if(rdPageNum12.checked)
    {
        pageNum = 12;
		imgId12.src='/Images/PhookProduct/page1_12.jpg';
    }
    else
    {
        imgId12.src='/Images/PhookProduct/page2_12.jpg';
    }
    if(rdPageNum12.disabled)
    {
        imgId12.src='/Images/PhookProduct/page3_12.jpg';
    }
    if(rdPageNum16.checked)
    {
        pageNum = 16;
		imgId16.src='/Images/PhookProduct/page1_16.jpg';
    }
    else
    {
        imgId16.src='/Images/PhookProduct/page2_16.jpg';
    }
    if(rdPageNum16.disabled)
    {
        imgId16.src='/Images/PhookProduct/page3_16.jpg';
    }
    
    if(rdPageNum24.checked)
    {
        pageNum = 24;
		imgId24.src='/Images/PhookProduct/page1_24.jpg';
    }
    else
    {
        imgId24.src='/Images/PhookProduct/page2_24.jpg';
    }
    if(rdPageNum24.disabled)
    {
        imgId24.src='/Images/PhookProduct/page3_24.jpg';
    }
    if(rdPageNum32.checked)
    {
        pageNum = 32;
		imgId32.src='/Images/PhookProduct/page1_32.jpg';
    }
    else
    {
        imgId32.src='/Images/PhookProduct/page2_32.jpg';
    }
    if(rdPageNum32.disabled)
    {
        imgId32.src='/Images/PhookProduct/page3_32.jpg';
    }
    if(rdPageNum36.checked)
    {
        pageNum = 36;
		imgId36.src='/Images/PhookProduct/page1_36.jpg';
    }
    else
    {
        imgId36.src='/Images/PhookProduct/page2_36.jpg';
    }
    if(rdPageNum36.disabled)
    {
        imgId36.src='/Images/PhookProduct/page3_36.jpg';
    }
    if(rdPageNum40.checked)
    {
        pageNum = 40;
		imgId40.src='/Images/PhookProduct/page1_40.jpg';
    }
    else
    {
        imgId40.src='/Images/PhookProduct/page2_40.jpg';
    }
    if(rdPageNum40.disabled)
    {
        imgId40.src='/Images/PhookProduct/page3_40.jpg';
    }
    
	
	// 获取产品价格
	for(var i=0; i<productFormatPriceList.length; i++)
	{
		if(productFormatPriceList[i].productFormatId == productFormatId && productFormatPriceList[i].pageNum == pageNum)
		{
			price = productFormatPriceList[i].price;
			break;
		}
	}
	
	// 获取当前主题产品
	for(var i=0; i<currentPhookProductList.productList.length; i++)
	{
		if(currentPhookProductList.productList[i].productFormatId == productFormatId)
		{
			currentPhookProduct = currentPhookProductList.productList[i].id;
			break;
		}
	}
	currentPageNum = pageNum;
	
	if(price == 0)
	{
		spanPhookProductPrice.innerHTML = '获取价格失败!';
		return;
	}
	else
	{
		spanPhookProductPrice.innerHTML = '￥' + formatMoney(price);
	}
}

// 格式化金额
function formatMoney(money)
{
    var j = Math.round(money*100);
    j = j/100;
	return (j.toString().indexOf('.') != -1) ? j : j + '.00';
}

// 开始定制按钮
function btnSelectPhookProduct()
{
	var spanPhookProductPrice = document.getElementById('spanPhookProductPrice');
	if(isNaN(spanPhookProductPrice.innerHTML.replace(/￥/g,'')))
	{
		alert('获取价格失败！');
		return;
	}
	if(currentPhookProduct == 0)
	{
		alert('未选择正确的主题产品');
		return;
	}
	currentPrice = parseFloat(spanPhookProductPrice.innerHTML.replace(/￥/g,''));
	MessageBox_Close();
	selectPhotos(currentPhookProduct,true);
}

// 自助设计
function selectPageNumForDIY(id,productFormatId)
{
	currentPhookProduct = id;
	// 获取价格单
	showLoading('正在加载数据...');
	ajax({type:'get_product_format_every_page_price',productFormatId:productFormatId},getProductFormatEveryPagePriceBack);

}

function getProductFormatEveryPagePriceBack(o)
{
	MessageBox_Close();
	var strZero = '￥' + formatMoney(0);
	var spanDiyPrice16 = document.getElementById('spanDiyPrice16');
	var spanDiyPrice24 = document.getElementById('spanDiyPrice24');
	var spanDiyPrice32 = document.getElementById('spanDiyPrice32');
	var spanDiyPrice36 = document.getElementById('spanDiyPrice36');
	var spanDiyPrice40 = document.getElementById('spanDiyPrice40');
	spanDiyPrice16.innerHTML = strZero;
	spanDiyPrice24.innerHTML = strZero;
	spanDiyPrice32.innerHTML = strZero;
	spanDiyPrice36.innerHTML = strZero;
	spanDiyPrice40.innerHTML = strZero;
	if(!o.isError)
	{
		for(var i=0; i<o.data.length; i++)
		{
			switch(o.data[i].pageNum)
			{
				case 16:
					spanDiyPrice16.innerHTML = '￥' + formatMoney(o.data[i].price);
					break
				case 24:
					spanDiyPrice24.innerHTML = '￥' + formatMoney(o.data[i].price);
					break
				case 32:
					spanDiyPrice32.innerHTML = '￥' + formatMoney(o.data[i].price);
					break
				case 40:
					spanDiyPrice40.innerHTML = '￥' + formatMoney(o.data[i].price);
					break
			}
		}
		MessageBox('选择页数','divMsgSelectPageCountForDIY');
		var divMsgSelectPageCountForDIY = document.getElementById('divMsgSelectPageCountForDIY');
		var inputs = divMsgSelectPageCountForDIY.getElementsByTagName('input');

		var rdDiy1 = document.getElementById('rdDiy1');
		var rdDiy2 = document.getElementById('rdDiy2');
		var rdDiy3 = document.getElementById('rdDiy3');
		var rdDiy4 = document.getElementById('rdDiy4');
		var spanDiyPrice16 = document.getElementById('spanDiyPrice16');
		var spanDiyPrice24 = document.getElementById('spanDiyPrice24');
		var spanDiyPrice32 = document.getElementById('spanDiyPrice32');
		var spanDiyPrice40 = document.getElementById('spanDiyPrice40');
		rdDiy1.disabled = false;
		rdDiy2.disabled = false;
		rdDiy3.disabled = false;
		rdDiy4.disabled = false;
		rdDiy2.checked = true;
		if(spanDiyPrice16.innerHTML == strZero)
		{
			rdDiy1.checked = false;
			rdDiy1.disabled = true;
		}
		if(spanDiyPrice24.innerHTML == strZero)
		{
			rdDiy2.checked = false;
			rdDiy2.disabled = true;
		}
		if(spanDiyPrice32.innerHTML == strZero)
		{
			rdDiy3.checked = false;
			rdDiy3.disabled = true;
		}
		if(spanDiyPrice40.innerHTML == strZero)
		{
			rdDiy4.checked = false;
			rdDiy4.disabled = true;
		}
		if(rdDiy2.disabled)
		{
			if(!rdDiy1.disabled)
			{
				rdDiy1.checked = true;
			}
			else if(!rdDiy3.disabled)
			{
				rdDiy3.checked = true;
			}
			else if(!rdDiy4.disabled)
			{
				rdDiy4.checked = true;
			}
		}
		rdDiySelect();

		for(var i=0; i<inputs.length; i++)
		{
			if(inputs[i].type == 'radio')
			{
				inputs[i].onclick = rdDiySelect;
			}
		}
	}
}

// 选择时效果
function rdDiySelect()
{
	var rdDiy1 = document.getElementById('rdDiy1');
	var rdDiy2 = document.getElementById('rdDiy2');
	var rdDiy3 = document.getElementById('rdDiy3');
	var rdDiy4 = document.getElementById('rdDiy4');
	var spanDiyPrice16 = document.getElementById('spanDiyPrice16');
	var spanDiyPrice24 = document.getElementById('spanDiyPrice24');
	var spanDiyPrice32 = document.getElementById('spanDiyPrice32');
	var spanDiyPrice40 = document.getElementById('spanDiyPrice40');
	
	spanDiyPrice16.style.color = '#666666';
	spanDiyPrice24.style.color = '#666666';
	spanDiyPrice32.style.color = '#666666';
	spanDiyPrice40.style.color = '#666666';
	if(rdDiy1.checked)spanDiyPrice16.style.color = '#fc7700';
	if(rdDiy2.checked)spanDiyPrice24.style.color = '#fc7700';
	if(rdDiy3.checked)spanDiyPrice32.style.color = '#fc7700';
	if(rdDiy4.checked)spanDiyPrice40.style.color = '#fc7700';
}

// 选择自住设计
function btnSelectDIY()
{
	var price = 0;
	var rdDiy1 = document.getElementById('rdDiy1');
	var rdDiy2 = document.getElementById('rdDiy2');
	var rdDiy3 = document.getElementById('rdDiy3');
	var rdDiy4 = document.getElementById('rdDiy4');
	var spanDiyPrice16 = document.getElementById('spanDiyPrice16');
	var spanDiyPrice24 = document.getElementById('spanDiyPrice24');
	var spanDiyPrice32 = document.getElementById('spanDiyPrice32');
	var spanDiyPrice40 = document.getElementById('spanDiyPrice40');
	if(rdDiy1.checked)
	{
		currentPageNum = 16;
		price = parseInt(spanDiyPrice16.innerHTML.replace(/￥/g,''));
	}
	if(rdDiy2.checked)
	{
		currentPageNum = 24;
		price = parseInt(spanDiyPrice24.innerHTML.replace(/￥/g,''));
	}
	if(rdDiy3.checked)
	{
		currentPageNum = 32;
		price = parseInt(spanDiyPrice32.innerHTML.replace(/￥/g,''));
	}
	if(rdDiy4.checked)
	{
		currentPageNum = 40;
		price = parseInt(spanDiyPrice40.innerHTML.replace(/￥/g,''));
	}
	if(price == 0)
	{
		alert('主题产品价格获取失败！');
		return;
	}
	if(currentPhookProduct == 0)
	{
		alert('未选择正确的主题产品');
		return;
	}
	currentPrice = price;
	MessageBox_Close();
	selectPhotos(currentPhookProduct,true);
}
