﻿var global_Caizhi = "0";
var global_scene = "0";

var global_ColorName = "0"; /*颜色*/
var gloabl_FrmPrice = "5"; /*框条价格*/


var pname; //作品名称

/*当前框条ID*/
var Cur_fid = "3";

var Cur_Mat1ID = "0";
var Cur_Mat1Name = "";
var Cur_Mat2ID = "0";
var Cur_Mat2Name = "";
var Cur_Mat3ID = "0";
var Cur_Mat3Name = "";
var level = 0;
var strMatsrc = "";

var j = jQuery.noConflict();

var global_Colorid = "0";

var global_Caizhi = "0";

var gloabl_Price = "0";

var gloabl_matwidth = 0;

/*全局家艺画心价*/


/*全局框条价格*/

var gloabl_Frame_Price = 0;

/*全局卡纸价格*/

var gloabl_Mat1_Price = 0;

var gloabl_Mat2_Price = 0;

var gloabl_Mat3_Price = 0;

/*玻璃价*/

var gloabl_5uart_glass_Price = 0;

var sucImgHeight = "0";

var gloabl_5uart_glassID = "2";

var mprice = 40;



/*当前框条ID*/
//var Cur_fid = "0";

var global_pid = "0";

var global_iniPrice = ""; //初始产品的家艺价   

var global_iniMarket = ""; //初始产品的市场价

var global_iniProSize = ""; //初始产品的尺寸

var BBK = 0;

var allWidth = "";

var allHeight = "";

var CWidth = 0; //比较时图片的宽度

var CHeight = 0; //比较时图片的高度

var isflag = 0; //标记

var MatSelect1Flag = 0;

var MatSelect2Flag = 0;

var MatSelect3Flag = 0;

var Cur_level = 1;

var SaveNum = 0;
/*当前图片地址*/
var global_imgurl = "";

var imgHtml = "";

var gloabl_Area = 0;

var globl_Url = "";

//var userUrl = window.location.toString();
var pid = QueryString("pid");



//var tempParameters = Parameters[3].split("love");

var zflag = "";

try{
	zflag=QueryString("zflag");
}
catch(err)
{}

try {

    //global_pid = QueryString("pid");
    global_pid = pid;
}
catch (err) {

}

var globl_pname = QueryString("title");

try {

    //global_pid = QueryString("pid");
    globl_pname = globl_pname;
  
    j("#pname").html(globl_pname);

}
catch (err) {

}
var global_specid = "";


var global_editer = "besture";

function GoBackMain() {
    if (global_editer == "besture")
    { window.location.href = "/list.aspx"; }
    else {
        window.location.href = "/" + global_editer + ".aspx";
    }

}

j(document).ready(function() {

    if (global_editer == "besture") {
        j("#headerleft").append(" <img id='indexlogo' width='217' height='38' alt='艺佰在线配框系统' class='logoleft' style='cursor:pointer;' onclick='GoBackMain();' />");
        j("#headerleft").append("<img id='indexTpic'  width='128' alt='优质 便利 快捷' class='logoright' />");
        j("#headerright").append(" <img id='indexppic'  width='250' height='17' alt='帮助热线' />");
        j(".right_adv").append("<img id='indexadvpic'/>");

        j("#indexlogo").attr("src", "/images/logo_03.jpg");
        j("#indexTpic").attr("src", "/images/lo-1_06.jpg");
        j("#indexppic").attr("src", "/images/lo-2_09.jpg");
        j("#indexadvpic").attr("src", "/images/ad_28.jpg");
    }

    getMatColor('0xffffff', '白', '1', '0');
    PageLoad();

    FrmPageChange('1', global_Caizhi, global_ColorName, gloabl_FrmPrice);

    gloabl_Mat1_Price = mprice;

    j("#spanFrame").html("黑色框条");


    setTimeout(Loading_Flash, 5000);


})

function Loading_Flash() {
    
    j("#spSaveNum").html(SaveNum);
    if (Number(SaveNum) > 1) {
        j("#comparespan").hide();
        j("#goCompare").show();
    }
    else {
        j("#comparespan").show();
        j("#goCompare").hide();
    }
    j("#matType_content1").html("  <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase=' http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='900' height='195' id='matPanelLast' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='/matPanelLast.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#f3f3f3' /><embed src='/matPanelLast.swf' quality='high' bgcolor='#f3f3f3' width='900' height='195' name='matPanelLast' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage=' http://www.macromedia.com/go/getflashplayer' /></object>");

    j("#con_two_4").html(" <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='900' height='195' id='wallColorPanel' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='/wallColorPanel.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='/wallColorPanel.swf' quality='high' bgcolor='#ffffff' width='900' height='195' name='wallColorPanel' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>");

   // j("#SceneLeft").css("background-image", "url('/images/loading.gif')");
   // j("#SceneLeft").css("background-image", "url('/photo/sence/big/2010527225222798.jpg')");
    InitScenes();
    InitPagers();
}






function PageLoad() {
    
    j.ajax({
        type: "get",
        url: "/AspxAction/PageLoad.aspx",
        data: "editer="+global_editer+"&" + Math.random(),
        success: function(msg) {
            j("#Material_three_1").html(msg);

        }
    })

    j.ajax({
        type: "get",
        url: "/AspxAction/GetCount.aspx",
        data: "&" + Math.random(),
        //data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&matid=" + Cur_Mat1ID + "&matid2=" + Cur_Mat2ID + "&matid3=" + Cur_Mat3ID + "&specid=" + global_specid + "&" + Math.random(),
        success: function(msg) {
            j("#spSaveNum").html(msg);
        }
    })

}

function MatShow(page) {
    MatShowInit(page);
    MatPageCodeShowInit(page);
}

function MatShowInit(page) {
    j.ajax({
        type: "get",
        url: "/AspxAction/MatPage.aspx",
        data: "page=" + page + "&editer=" + global_editer+ "&" + Math.random(),
        success: function(msg) {
            j(".Material2").html(msg);
        }
    })
}

function MatPageCodeShowInit(page) {
    j.ajax({
        type: "get",
        url: "/AspxAction/MatPageCode.aspx",
        data: "page=" + page + "&editer="+global_editer+"&" + Math.random(),
        success: function(msg) {
            var msgtemp = msg.split('|');
            var prvepage = msgtemp[0];
            if (prvepage == "-1") {
                j("#LeftMatArrow").html("<img src=\"/images/jizuo1_78.gif\" alt=\"prev\" />");
            }
            else {
                j("#LeftMatArrow").html("<img src=\"/images/jizuo1-1_78.gif\" onclick=\"MatShow('" + prvepage + "')\" alt=\"prev\" />");
            }
            var nextpage = msgtemp[1];
            if (nextpage == "-1") {
                j("#RightMatArrow").html("<img src=\"/images/jizuo2_81.gif\" alt=\"next\" />");
            }
            else {
                j("#RightMatArrow").html("<img src=\"/images/jizuo2-1_81.gif\" onclick=\"MatShow('" + nextpage + "')\" alt=\"next\" />");
            }
        }
    })
}

function FrmPageChange(page, caizhiid, colorname, price) {
    
    //function FrmPageChange(page, caizhiid) {
    FrmShowInit(page, caizhiid, colorname, price);
    FrmPageCodeShowInit(page, caizhiid, colorname, price);
}


function FrmShowInit(page, caizhiid, colorname, price) {
    //function FrmShowInit(page, caizhiid) {
    j.ajax({
        type: "get",
        url: "/AspxAction/FrmPage.aspx",
        data: "page=" + page + "&caizhiid=" + caizhiid + "&cname=" + colorname + "&priceid=" + price + "&editer=" + global_editer + "&" + Math.random(),
        success: function(msg) {
            j(".thumblist").html(msg);
        }
    })
}
function FrmPageCodeShowInit(page, caizhiid,colorname,price) {
    j.ajax({
        type: "get",
        url: "/AspxAction/FrmPageCode.aspx",
        data: "page=" + page + "&caizhiid=" + caizhiid + "&cname=" + colorname + "&priceid=" + price + "&editer=" + global_editer + "&" + Math.random(),
        success: function(msg) {
            var msgtemp = msg.split('|');
            var prvepage = msgtemp[0];
            if (prvepage == "-1") {
                j("#LeftArrow").html("<img src=\"/images/jizuo1_78.gif\" alt=\"prev\" />");
            }
            else {
                j("#LeftArrow").html("<img src=\"/images/jizuo1-1_78.gif\" onclick=\"FrmPageChange('" + prvepage + "','" + caizhiid + "','"+colorname+"','"+price+"')\" alt=\"prev\" />");
            }
            var nextpage = msgtemp[1];
            if (nextpage == "-1") {
                j("#RightArrow").html("<img src=\"/images/jizuo2_81.gif\" alt=\"next\" />");
            }
            else {
                j("#RightArrow").html("<img src=\"/images/jizuo2-1_81.gif\" onclick=\"FrmPageChange('" + nextpage + "','" + caizhiid + "','"+colorname+"','"+price+ "')\" alt=\"next\" />");
            }
        }
    })
}


/*
====导航选择======
参数 index
1.选择框条  Nav_1
2.选择卡纸  Nav_2
3.选择玻璃  Nav_3
4.墙面颜色  Nav_4
5.选择场景  Nav_5
ActionContent ID = printGuideContentbox
*/
function NavSel(index) {
    NavInit(index);
    setSceneTab(index);
    if (index == "1") {
        JQSetTab(1, 6);
    }
    else if (index == "2") {
    
        JQSetTab(2, 6);
    }
    else if (index == "3") {
        JQSetTab(3, 6);
    }
    else if (index == "4") {
        JQSetTab(4, 6);
    }
    else if (index == "5") {

        JQSetTab(5, 6);
    }
    else if (index == "6") {

        JQSetTab(6, 6);
    }
}




function setSceneTab(index) {
    if (index == "5" || index=="6") {
        
        j("#middlebody").css("display", "none");
        j("#SceneMiddlebody").css("display", "");
        j("#SceneLeft").css("background", "url('/images/loading.gif') no-repeat center center");
        if (index == "5") {
            j.ajax({
                type: "get",
                url: "/AspxAction/InitData.aspx",
                data: "flag=5" + "&editer=" + global_editer + "&" + Math.random(), // 5表示场景
                success: function(msg) {
                    if (msg == "") {
                        j("#SceneLeft").css({ "text-align": "center" });
                    }
                    else {
                        j("#SceneLeft").css("background", "url('" + msg + "') no-repeat center center"); 
                    }
                }
            })
        }
        if (index == "6") {
            j.ajax({
                type: "get",
                url: "/AspxAction/InitData.aspx",
                data: "flag=6" + "&editer=" + global_editer + "&" + Math.random(), // 5表示场景
                success: function(msg) {
                    if (msg == "") {
                        j("#SceneLeft").css({ "text-align": "center" });
                    }
                    else {
                        j("#SceneLeft").css("background-image", "url('" + msg + "')");
                    }
                }
            })
        }
        j("#imgSence").attr("src", global_imgurl);
        j("#imgSence").attr("width", parseFloat(CWidth / 1.8));
        j("#imgSence").attr("height", parseFloat(CHeight / 1.8));

        j("#imgSence").resizable({
            handles: "se",
            knobHandles: true,
            aspectRatio: true,
            autoHide: true
        }).parent().draggable({
            cursor: "move"
        });
        
        
        //j("#draggable").draggable();
//        j("#regable").resizable({

//            aspectRatio: CWidth / CHeight
//        });

    }
    else {
        j("#middlebody").css("display", "");
        j("#SceneMiddlebody").css("display", "none");
        j("#picCreate").html(imgHtml);
    }
}

function NavInit(index) {
    for (var i = 1; i <= 6; i++) {
        if (i != Number(index)) {
            //j("#Nav_" + i).html("<img src=\"/images/kuang2_49.gif\" />");

            j("#Nav_" + i).css("background-image", "url(/images/kuang2_49.gif)");
            j("#Nav_" + i).css("color", "white");
        }
        else {
            //j("#Nav_" + index).html("<img src=\"/images/kuang1_47.gif\" />");
            j("#Nav_" + i).css("background-image", "url(/images/kuang1_47.gif)");
            j("#Nav_" + i).css("color", "black");
        }
    }
}

function JQSetTab(cur, count) {
    for (var i = 1; i <= count; i++) {
        if (cur == i) {
            j("#con_two_" + i).css("display", "");
        }
        else {
            j("#con_two_" + i).css("display", "none");
        }

    }

    j("#picCreate").show();
    j(".middleright").show();
    j("#middleDown").show();
    //    j(".middlebody").css("background-image", "none");
    // document.getElementById('example1').style.backgroundColor =color;
    //    j(".middlebody").css("background-color", "white");
    if (cur == 2) {
        //  MatShow("1");
        //        if (MatSelect1Flag == 0) {
        //            getMatColor('0xffffff', '白', '1', '0');
        //        }

       

    }
    if (cur == 4) {
        
    }
    if (cur == 5) {
       
        //j("#picCreate").hide();
        //        j("#picCreate").html("<a href='" + global_imgurl + "'><img src='" + global_imgurl + "' width='" + CWidth + "' height='" + CHeight + "'></a>");
        j("#picCreate").html("");

        //global_imgurl = msgs[1];
        j(".middleright").hide();
        j("#middleDown").hide();


    }
}

function FrmSelect(frmid, fname, fprize) {
    j("#picCreate").html("   <img id='picCreate2' src='/images/loading.gif' alt='besture' width='120' height='15' style=' text-align:center; vertical-align:middle; margin:0; height:15px; width:120px; padding:150px 0 0 0;'/>");
    j("#spanFrame").html(fname);
    Cur_fid = frmid;
    gloabl_Frame_Price = fprize;
    if (isflag == 0) {
        PhotoChangeNormal();
    }
    else {
        PhotoChange();
    }
//    j("#tbframe_" + frmid).css({ "border": "solid 2px #500e12" });
//    j("#td_" + frmid).css("display", "block"); 
}

function MatSpecSelect(_matid, mname, mprice) {
    if (Cur_fid == 0) {
        alert("请先选择框条");
        return;
    }
    level == "1";

    Cur_Mat1ID = _matid;
    gloabl_Mat1_Price = mprice;
    j("#spMat1").html(mname);

    PhotoChange();
}


function MatSelect(_matid, mname, mprice) {
    j("#picCreate").html("   <img id='picCreate2' src='/images/loading.gif' alt='besture' width='120' height='15' style=' text-align:center; vertical-align:middle; margin:0; height:15px; width:120px; padding:150px 0 0 0;'/>");
    isflag = 1;
    if (Cur_fid == 0) {
        alert("请先选择框条");
        return;
    }
    if (level == "1") {
        Cur_Mat1ID = _matid;
        
        gloabl_Mat1_Price = mprice;
        j("#spMat1").html(mname);
    }
    else if (level == "2") {
        Cur_Mat2ID = _matid;
        gloabl_Mat2_Price = mprice;
        j("#spMat2").html(mname);
    }
    else if (level == "3") {
        Cur_Mat3ID = _matid;
        gloabl_Mat3_Price = mprice;
        j("#spMat3").html(mname);
    }
    //PhotoChange();
    //    if (strsrc != null) {
    //        strMatsrc = strsrc;
    //    }

    //j("#imgMat" + level).html("<img  src=" + strMatsrc + " />");
    PhotoChange();
}

function SceneSelect(src) {
   // j("#SceneLeft").html("   <img id='picCreate2' src='/images/loading.gif' alt='besture' width='120' height='15' style=' text-align:center; vertical-align:middle; margin:0; height:15px; width:120px; padding:150px 0 0 0;'/>");
    j("#SceneLeft").css("background", "url(" + src + ") no-repeat center center;");
    //    j("#SceneLeft").html("");
//    var img = new Image();
//    j("#SceneLeft").css("background-image", "none");
//    j("#SceneLeft").empty();
//    j("#SceneLeft").html = "<p>图片加载中...</p>";
//    img.onload = function() { j("#SceneLeft").append(img); };
//    img.onerror = function() { obj.innerHTML = "图片加载失败！" };

//    img.src = src; //img.src一定要写在img.onload之后，否则在IE中会出现问题
//    var w=img.width;
//    var h=img.height;
//    
//     if (w > 800 || h > 450) {
//     var  a = w / 800; 
//     var b = h / 450;
//        if (b > a) a = b;
//        w = w / a; h = h / a;
//    }
//    if (w > 0 && h > 0) {
//        img.width = w+"px";
//        img.height = h+"px";
//    }
//    img.style.height = "400px";
//    img.style.width = "800px";
    
   // resizeImage1(img, 800, 450); //重新去缩放图片
}


/*更改当前激活卡纸层*/
function ChangCurMatLevel(_level) {
    level = _level;
    j(".matDIV").each(function(index) {
        if ((level - index) != 1) {
            j(this).addClass("selectedDIV");
        }
        else {
            if (j(this).hasClass("selectedDIV")) {
                j(this).removeClass("selectedDIV");
            }
        }
    })
}

function SelPrice(p_cid) {
    j("#Price_" + p_cid + " a").css("background-color", "yellow");
    j("#Price_" + p_cid).prevAll().children().css("background-color", "white");
    j("#Price_" + p_cid).nextAll().children().css("background-color", "white");
    gloabl_FrmPrice = p_cid;
    FrmPageChange('1', '0', '0', gloabl_FrmPrice);
}
function FrmSelColor(cname, obj) {
//    j("#Color_" + obj + " a").css("background-color", "yellow");
//    j("#Color_" + obj).prevAll().children().css("background-color", "white");
    //    j("#Color_" + obj).nextAll().children().css("background-color", "white");
    j("#Material_three_2 li a").css("background-color", "white");
    j("#Color_" + obj + " a").css("background-color", "yellow");
    global_ColorName = cname;
    FrmPageChange('1','0' ,global_ColorName,'5');
}


function SelCaizhi(c_cid) {
    j("#Caizhi_" + c_cid + " a").css("background-color", "yellow");
    j("#Caizhi_" + c_cid).prevAll().children().css("background-color", "white");
    j("#Caizhi_" + c_cid).nextAll().children().css("background-color", "white");
    global_Caizhi = c_cid;
    FrmPageChange('1', global_Caizhi, '0', '5');
}

/*更改框条左侧搜索条件*/
function setTab(name, cursel, n) {
    
    for (i = 1; i <= n; i++) {
        var menu = document.getElementById(name + i);
        var con = document.getElementById("Material_" + name + "_" + i);
        menu.className = i == cursel ? "frm_tab_selected" : "frm_tab_select";
        //  con.style.display = i == cursel ? "block" : "none";
    }

    if (cursel == "3") {
        document.getElementById("Material_three_1").style.display = "none";
        document.getElementById("Material_three_2").style.display = "none";
        document.getElementById("Material_three_3").style.display = "block";
    }
    if (cursel == "2") {
        j("#Material_three_2").append("<img src='/images/loading_left.gif'/>");
        GetFrmColor();
        document.getElementById("Material_three_1").style.display = "none";
        document.getElementById("Material_three_2").style.display = "block";
        document.getElementById("Material_three_3").style.display = "none";
    }
    if (cursel == "1") {
        PageLoad();
        document.getElementById("Material_three_1").style.display = "block";
        document.getElementById("Material_three_2").style.display = "none";
        document.getElementById("Material_three_3").style.display = "none";
    }
}

/*卡纸层数选择*/
j(function() {
    j("#chooseCount a").each(function() {
        j(this).bind("click",
                function() {
                    j(this).prevAll().removeClass("selected");
                    j(this).nextAll().removeClass("selected");
                    j(this).addClass("selected");
                }
            )
    })
})



function PhotoChangeNormal() {
    //debugger;
   
    j("#picCreate").html("   <img id='picCreate2' src='/images/loading.gif' alt='besture' width='120' height='15' style=' text-align:center; vertical-align:middle; margin:0; height:15px; width:120px; padding:150px 0 0 0;'/>");
    j.ajax({

        type: "get",
        url: "/AspxAction/CreatePic.aspx",
        data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&color1=" + Cur_Mat1ID + "&color2=" + Cur_Mat2ID + "&color3=" + Cur_Mat3ID + "&mat1width=" + j("#firstcutwidth").val() + "&mat2width=" + j("#secondcutwidth").val() + "&mat3width=" + j("#thirdcutwidth").val() + "&specid=" + global_specid + "&level=" + Cur_level + "&flag=0&editer=" + global_editer+"&zflag="+zflag+ "&" + Math.random(),
        //data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&matid=" + Cur_Mat1ID + "&matid2=" + Cur_Mat2ID + "&matid3=" + Cur_Mat3ID + "&specid=" + global_specid + "&" + Math.random(),
        success: function(msg) {
            AginInitInfo(msg);
        }
    })
}


function PhotoChange() {
    //debugger;
    j("#picCreate").html("   <img id='picCreate2' src='/images/loading.gif' alt='besture' width='120' height='15' style=' text-align:center; vertical-align:middle; margin:0; height:15px; width:120px; padding:150px 0 0 0;'/>");
    j.ajax({

        type: "get",
        url: "/AspxAction/CreatePic.aspx",
        data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&matid=" + Cur_Mat1ID + "&matid2=" + Cur_Mat2ID + "&matid3=" + Cur_Mat3ID + "&mat1width=" + j("#firstcutwidth").val() + "&mat2width=" + j("#secondcutwidth").val() + "&mat3width=" + j("#thirdcutwidth").val() + "&specid=" + global_specid + "&level=" + Cur_level + "&zflag=" + zflag + "&editer=" + global_editer + Math.random(),
        //data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&matid=" + Cur_Mat1ID + "&matid2=" + Cur_Mat2ID + "&matid3=" + Cur_Mat3ID + "&specid=" + global_specid + "&" + Math.random(),
        success: function(msg) {
            AginInitInfo(msg);
        }
    })
}


function AginInitInfo(msg) {

    var msgs = msg.split("|");

    if (global_editer != "besture") {
        j("#headerleft").html(" <img id='indexlogo' width='217' class='logoleft' height='38' style='cursor:pointer;' onclick='GoBackMain();' /><img id='indexTpic'  width='128'  class='logoright' />");
        j("#headerright").html(" <img id='indexppic'  width='250' alt='帮助热线' />");
        j(".right_adv").html("<img id='indexadvpic'/>");
        
        j("#indexlogo").attr("src", "/user/upload/" + msgs[13]);
        j("#indexTpic").attr("src", "/user/upload/" + msgs[14]);
        j("#indexppic").attr("src", "/user/upload/" + msgs[15]);
        j("#indexadvpic").attr("src", "/user/upload/" + msgs[16]);
    }

    j("#picCreate").hide();
    j("#picCreate").html(msgs[0]);
    j("#picCreate").show("slow");
    
    imgHtml = msgs[0];
    
    global_imgurl = msgs[1];
    j("#big").attr('href', msgs[1]);
    j("#SucSize").html(msgs[2]/10 + "×" + msgs[3]/10);
    allWidth = msgs[2];
    allHeight = msgs[3];
    CWidth = msgs[4];
    CHeight = msgs[5];
    global_iniPrice = msgs[7];
    name = msgs[6];
    j("#pname").html(name);
    LoadPrice();
    
    j("#decorate_imageArea").css("width", msgs[8]);
    j("#decorate_imageArea").css("height", msgs[9]);
    gloabl_Frame_Price = msgs[10];
    SaveNum = msgs[11];

    j("#hidPids").val(msgs[12]);


    
    
    //global_pid = msgs[12];

}

/*获取URL中的参数值*/
function QueryString(fieldName) {
    var urlString = document.location.search;
    if (urlString != null) {
        var typeQu = fieldName + "=";
        var urlEnd = urlString.indexOf(typeQu);
        if (urlEnd != -1) {
            var paramsUrl = urlString.substring(urlEnd + typeQu.length);
            var isEnd = paramsUrl.indexOf('&');
            if (isEnd != -1) {
                return paramsUrl.substring(0, isEnd);
            }
            else {
                return paramsUrl;
            }
        }
        else {
            return null;
        }
    }
    else {
        return null;
    }
}

function ContentUpdateBackColor(c) {
    j("#decorate_imageArea").css("background-color", c);
}

function glassSel(flag) {
    if (flag == 1) {
        j("#spGlass").html("有机玻璃");


    }
    else {
        j("#spGlass").html("普通玻璃");
    }

    gloabl_5uart_glass_Price = parseFloat((allWidth * allHeight) * (j("#Radio" + flag).val())).toFixed(2);
    LoadPrice();
}

function AddCompare() {
    
    var pid = global_pid;

    var pname = j("#pname").html();
    var pimgurl = global_imgurl;
    /*价格 == 画心价格|框条价格|卡纸价格|玻璃价格|总价*/
    var pids = j("#hidPids").val();
    var tempComparePid = pimgurl;
    if (contains(pids, tempComparePid, true)) {
        alert("该产品已加入对比");
        return;
    }
    if (pids == "") {
        j("#hidPids").val("," + tempComparePid + ",");
    }
    else {
        tempComparePid = j("#hidPids").val() + tempComparePid + ",";
        j("#hidPids").val(tempComparePid);
    }





    var kaprice = Number(gloabl_Mat1_Price) + Number(gloabl_Mat2_Price) + Number(gloabl_Mat3_Price);
    
    /*总价*/
    var totalprice = Number(global_iniPrice) + Number(gloabl_Frame_Price) + Number(kaprice) + Number(gloabl_5uart_glass_Price);

    var pprice = Number(global_iniPrice) + "|" + Number(gloabl_Frame_Price) + "|" + Number(kaprice) + "|" + Number(gloabl_5uart_glass_Price) + "|" + totalprice


    var objOther = gloabl_5uart_glassID;
    var spec = global_specid;
    var specid = global_specid;
    /*完全尺寸*/
    var fspec = j("#SucSize").html().replace('×', '_');



    j.ajax({
        type: "get",
        url: "/AspxAction/AddCompare.aspx",
        //data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&matid=" + Cur_Mat1ID + "&matid2=" + Cur_Mat2ID + "&matid3=" + Cur_Mat3ID + "&pname=" + pname + "&pimgurl=" + pimgurl + "&pprice=" + pprice + "&" + Math.random(),
        data: "pid=" + pid + "&pname=" + pname + "&pimgurl=" + pimgurl + "&pprice=" + pprice + "&cwidth=" + CWidth + "&cheight=" + CHeight + "&" + Math.random(),
        success: function(msg) {
            if (Number(msg) > 0) {
                ymPrompt.alert({ title: '操作成功', message: '<div style=\'padding-left:0px;text-align:left;margin-left:0px;margin-top:30px;Color:#000000;\'>加入成功！</div>' });
                j("#spSaveNum").html(msg);
                if (Number(msg) > 1) {
                    j("#comparespan").hide();
                    j("#goCompare").show();
                }
                else {
                    j("#comparespan").show();
                    j("#goCompare").hide();
                }
            }
        }
    })
}

function goCompare() {
    //    ymPrompt.win({ id: 'compare', title: '艺佰配框系统作品比较', page: '../../Compare.aspx', cover: true, width: 680, height: 615 });
    ymPrompt.win({ message: '/Compare.aspx', width: 710, height: 615, title: '艺佰配框系统作品比较', iframe: true });
}

function contains(string, substr, isIgnoreCase) {
    if (isIgnoreCase) {
        string = string.toLowerCase();
        substr = substr.toLowerCase();
    }
    var startChar = substr.substring(0, 1);
    var strLen = substr.length;
    for (var j = 0; j < string.length - strLen + 1; j++) {
        if (string.charAt(j) == startChar)//如果匹配起始字符,开始查找
        {
            if (string.substring(j, j + strLen) == substr)//如果从j开始的字符与str匹配，那ok
            {
                return true;
            }
        }
    }
    return false;
}

/*计算成品的总价*/
function TotalCount() {
    var totalprice = parseFloat(global_iniPrice) + parseFloat(gloabl_Frame_Price) + parseFloat(gloabl_Mat1_Price) + parseFloat(gloabl_Mat2_Price) + parseFloat(gloabl_Mat3_Price) + parseFloat(gloabl_5uart_glass_Price);
    return totalprice.toFixed(2);
}

function LoadPrice() {
    
    var totalprice = TotalCount();
    //更改市场价
    //gloabl_5uartMarket_Price = (temp[1]*1.2).toFixed("2")
    var Marketprice = totalprice * 1.5;
    //Marketprice = Math.Round(Marketprice, 2);
    Marketprice = Math.round(Marketprice * 100) / 100;
    j("#market").html(Marketprice);
    //更改家艺价
    j("#ourprice").html(totalprice);
}

/* 改变背景色*/
function selColor(color) {
    j(".middlebody").css("background-image", "none");
    // document.getElementById('example1').style.backgroundColor =color;
    j(".middlebody").css("background-color", color);
    //   setGradient('example1', '#FFF7E7', '#000', 0);
}


/*常用卡纸 flash传颜色值过来 flag如果是0就是普通配卡纸，如果不是就是特殊 indexflag0代表选的是0123那边，1代表选择的是当前卡纸层就下面那个*/
function getMatColor(color, mname, MatLevel, indexflag) {
    
    isflag = 0;
level = MatLevel;
if (indexflag == 0) {
    Cur_level = MatLevel;
}
if (Cur_fid == 0) {
    alert("请先选择框条");
    return;
}
if (level == "0") {
    j("#spMat1").html("未选择");
    j("#spMat2").html("未选择");
    j("#spMat3").html("未选择");
}
if (level == "1") {
    gloabl_Mat1_Price = mprice;
    if (color != "") {
        Cur_Mat1ID = color;
        Cur_Mat1Name = mname;
        j("#spMat1").html(mname);
    }

    if (indexflag == 0) {
        gloabl_Mat2_Price = 0;
        j("#spMat2").html("未选择");
        gloabl_Mat3_Price = 0;
        j("#spMat3").html("未选择");
    }
    else {
        if (Cur_Mat1ID == 0) {
            Cur_Mat1ID = "0xFFFFFF";
            Cur_Mat1Name = "白色";
        }
    }
}
else if (level == "2") {

if (color != "") {
    Cur_Mat2ID = color;
    Cur_Mat2Name = mname;
    j("#spMat2").html(mname);
}

    gloabl_Mat2_Price = mprice;
    if (indexflag == 0) {
        gloabl_Mat3_Price =0;
        j("#spMat3").html("未选择");
    }
    else {
        if (Cur_Mat1ID == 0) {
            Cur_Mat1ID = "0xFFFFFF";
            Cur_Mat1Name = "白色";
        }
        if (Cur_Mat2ID == 0) {
            Cur_Mat2ID = "0xFFFFFF";
            Cur_Mat2Name = "白色";
        }
    }
}
else if (level == "3") {


if (color != "") {
    Cur_Mat3ID = color;
    Cur_Mat3Name = mname;
    j("#spMat3").html(mname);
}
else {
    if (Cur_Mat1ID == 0) {
        Cur_Mat1ID = "0xFFFFFF";
        Cur_Mat1Name = "白色";
    }
    if (Cur_Mat2ID == 0) {
        Cur_Mat2ID = "0xFFFFFF";
        Cur_Mat2Name = "白色";
    }
    if (Cur_Mat3ID == 0) {
        Cur_Mat3ID = "0xFFFFFF";
        Cur_Mat3Name = "白色";
    }
}
    gloabl_Mat3_Price = mprice;
}

//var obj_new = values[0].replace("0x", "#");
j("#picCreate").html("   <img id='picCreate2' src='/images/loading.gif' alt='besture' width='120' height='15' style=' text-align:center; vertical-align:middle; margin:0; height:15px; width:120px; padding:150px 0 0 0;'/>");
j.ajax({
    type: "get",
    url: "/AspxAction/CreatePic.aspx",
    data: "pid=" + global_pid + "&frmid=" + Cur_fid + "&color1=" + Cur_Mat1ID + "&color2=" + Cur_Mat2ID + "&color3=" + Cur_Mat3ID + "&mat1width=" + j("#firstcutwidth").val() + "&mat2width=" + j("#secondcutwidth").val() + "&mat3width=" + j("#thirdcutwidth").val() + "&specid=" + global_specid + "&level=" + Cur_level + "&flag=0&editer=" + global_editer + "&zflag=" + zflag + "&" + Math.random(),
    success: function(msg) {
    
        AginInitInfo(msg);
    }
})
}

/*特殊卡纸*/
function MatType_Change(type) {
    if (type == 1) {
        isflag = 0;
        j("#matType_content2").css("display", "none");
        document.getElementById('mat_type1').className = 'mat_type_selected';
        j("#matType_content1").css("display", "block");
        document.getElementById('mat_type2').className = 'mat_type_select';
    }
    else {
        isflag = 1;
        j("#matType_content1").css("display", "none");
        document.getElementById('mat_type2').className = 'mat_type_selected';
        j("#matType_content2").css("display", "block");
        document.getElementById('mat_type1').className = 'mat_type_select';
        MatShow("1");
    }

}


/*场景展示*/
function InitScenes() {
    j.ajax({
        type: "get",
        url: "/AspxAction/PageLoadScenes.aspx",
        data: "editer="+global_editer+"&" + Math.random(),
        success: function(msg) {
            j("#scenes").html(msg);
        }
    })
    ScenesPageChange('1', global_scene);
}
function ScenesPageChange(page, sceneId) {
    ScenesShowInit(page, sceneId);
    ScenesPageCodeShowInit(page, sceneId);
}

function ScenesShowInit(page, sceneId) {
    j.ajax({
        type: "get",
        url: "/AspxAction/ScenesPage.aspx",
        data: "page=" + page + "&sceneId=" + sceneId + "&editer=" + global_editer + "&" + Math.random(),
        success: function(msg) {
            j(".Scenesthumblist").html(msg);
        }
    })
}
function ScenesPageCodeShowInit(page, sceneId) {
    j.ajax({
        type: "get",
        url: "/AspxAction/ScenesPageCode.aspx",
        data: "page=" + page + "&sceneId=" + sceneId + "&editer=" + global_editer + "&" + Math.random(),
        success: function(msg) {
            var msgtemp = msg.split('|');
            var prvepage = msgtemp[0];
            if (prvepage == "-1") {
                j("#LeftSceneArrow").html("<img src=\"/images/jizuo1_78.gif\" alt=\"prev\" />");
            }
            else {
                j("#LeftSceneArrow").html("<img src=\"/images/jizuo1-1_78.gif\" onclick=\"ScenesPageChange('" + prvepage + "','" + sceneId + "')\" alt=\"prev\" />");
            }
            var nextpage = msgtemp[1];
            if (nextpage == "-1") {
                j("#RightSceneArrow").html("<img src=\"/images/jizuo2_81.gif\" alt=\"next\" />");
            }
            else {
                j("#RightSceneArrow").html("<img src=\"/images/jizuo2-1_81.gif\" onclick=\"ScenesPageChange('" + nextpage + "','" + sceneId + "')\" alt=\"next\" />");
            }
        }
    })
}


/*墙纸展示*/
function InitPagers() {
    
    j.ajax({
        type: "get",
        url: "/AspxAction/PageLoadPaper.aspx",
        data: "editer="+global_editer+"&" + Math.random(),
        success: function(msg) {
            
            j("#papers").html(msg);
        }
    })
    PagersPageChange('1', global_scene);
}
function PagersPageChange(page, PaperId) {
    PagersShowInit(page, PaperId);
    PapersPageCodeShowInit(page, PaperId);
}

function PagersShowInit(page, PaperId) {
    j.ajax({
        type: "get",
        url: "/AspxAction/PapersPage.aspx",
        data: "page=" + page + "&PaperId=" + PaperId + "&editer=" + global_editer + "&" + Math.random(),
        success: function(msg) {
            
            j(".Papersthumblist").html(msg);
        }
    })
}
function PapersPageCodeShowInit(page, PaperId) {
    j.ajax({
        type: "get",
        url: "/AspxAction/PapersPageCode.aspx",
        data: "page=" + page + "&PaperId=" + PaperId + "&editer=" + global_editer + "&" + Math.random(),
        success: function(msg) {
            
            var msgtemp = msg.split('|');
            var prvepage = msgtemp[0];
            if (prvepage == "-1") {
                j("#LeftPaperArrow").html("<img src=\"/images/jizuo1_78.gif\" alt=\"prev\" />");
            }
            else {
                j("#LeftPaperArrow").html("<img src=\"/images/jizuo1-1_78.gif\" onclick=\"PagersPageChange('" + prvepage + "','" + PaperId + "')\" alt=\"prev\" />");
            }
            var nextpage = msgtemp[1];
            if (nextpage == "-1") {
                j("#RightPaperArrow").html("<img src=\"/images/jizuo2_81.gif\" alt=\"next\" />");
            }
            else {
                j("#RightPaperArrow").html("<img src=\"/images/jizuo2-1_81.gif\" onclick=\"PagersPageChange('" + nextpage + "','" + PaperId + "')\" alt=\"next\" />");
            }
        }
    })
}



function ViewDetailRoom(obj) {
    ymPrompt.win({ message: '/ViewZoom.htm?flag=' + global_imgurl, width: 723, height: 610, title: '图片放大缩小', iframe: true });
}

function SelectColor(obj) {
  
    var obj_new= obj.replace("0x","#");
    j(".middlebody").css("background-image", "none");

    j(".middlebody").css("background-color", obj_new);
}

function GetFrmColor() {
    j.ajax({
        type: "get",
        url: "/AspxAction/GetFrmColor.aspx",
        data: "editer="+global_editer+"&" + Math.random(),
        success: function(msg) {
            j("#Material_three_2").html(msg);
        }
    })
}

function changePrice(obj) {
    document.getElementById('tbframe_'+obj).className = 'frameselected';
    document.getElementById('td_' + obj).style.display = 'block';
    document.getElementById('td_'+obj).style.border = 'solid 1px #CAC3B6';
}
function hiddenPrice(obj) {
    document.getElementById('tbframe_'+obj).className = 'framenotselected';
    document.getElementById('td_'+obj).style.display = 'none';
}

function openFrameDetail(obj) {
    ymPrompt.win({ message: '/FrameDetail.aspx?id=' +obj , width: 523, height: 350, title: '框条详细信息', iframe: true });
}

function resizeImage(obj, MaxW, MaxH) {
    var imageObject = obj;
    if (imageObject == undefined) {
        return;
    }
    var state = imageObject.readyState;
    if (state != 'complete') {
        setTimeout("resizeImage(" + imageObject + "," + MaxW + "," + MaxH + ")", 50);
        return;
    }
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW = oldImage.width; var dH = oldImage.height;
    if (dW > MaxW || dH > MaxH) {
        a = dW / MaxW; b = dH / MaxH;
        if (b > a) a = b;
        dW = dW / a; dH = dH / a;
    }
    if (dW > 0 && dH > 0) {
        imageObject.width = dW;
        imageObject.height = dH;
    }
}
// 图片自动缩小，宽高一项为指定尺寸，另一项偏大
function resizeImg(obj, MaxW, MaxH) {
    var imageObject = obj;
    var state = imageObject.readyState;
    if (state != 'complete') {
        setTimeout("resizeImage(" + imageObject + "," + MaxW + "," + MaxH + ")", 50);
        return;
    }
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW = oldImage.width;
    var dH = oldImage.height;
    if (dW > MaxW || dH > MaxH) {
        a = dW / MaxW; b = dH / MaxH;
        if (b < a) a = b;
        dW = dW / a; dH = dH / a;
    }
    if (dW > 0 && dH > 0) {
        imageObject.width = dW;
        imageObject.height = dH;
    }
}



/*选择需配卡纸层数*/
function MatLevelSelect(_level) {
     level = _level;
    MatLevelNowSelect = Number(level);
    PhotoChange();
    //得到卡纸显示DIV
    var ltemp = 1;
    j(".matDIV").each(function(index) {
        /*index从0起始*/
        if (level > index) {
            j(this).css("display", "");
            /*高度显示当前卡纸*/
            if ((level - index) == 1) {
                j(this).addClass("selectedDIV");
            }
            else {
                if (j(this).hasClass("selectedDIV")) {
                    j(this).removeClass("selectedDIV");
                }
            }
        }
        else {
            j(this).css("display", "none");
        }
    });
}

