﻿ window.onload = function(){
            var imgs = $("img[name='altImg']");
            imgs.each(function(i,item){
                  $(item).click(
                     function(){
                        for(var j=0;j<imgs.length;j++){
                            imgs[j].parentNode.parentNode.className="";
                        }
                        $(".img img")[0].src="../"+templates[i];
                        document.getElementById("photoTitle").innerHTML = tempnotes[i];
                        $("#hidvideo").val(fcs[i]);
                        $("#hidfileid").val(fids[i]);
                        item.parentNode.parentNode.className="on";
                        checkVideo();
                     }
                  );
            });
            
            checkVideo();
}
        
 


function openPicDialog(){
     win_pic.show();
}

function closePicDialog(){
      win_pic.hide();
}

function closePic(){
    $.modalbox.close();
}

function openPic(){
    document.getElementById("window_pic").src = $(".img img")[0].src;
    document.getElementById("detailTxt").innerHTML  = document.getElementById("photoTitle").innerHTML;
    tb_show(document.getElementById("photoTitle").innerHTML,document.getElementById("window_pic").src,"gallery");
//    $.modalbox.show({
//                modal: true,
//                content:  document.getElementById("dpic").innerHTML,
//                draggable: false,
//                showTitle: false,
//                showCancel: false, 
//                showOk: false,
//                width: 700,
//                height:480,
//                scroll:"no"

//            });
}


function openNotlogin(path){
   if(path=="en/")
        alert("You are not login,please login first.");
    else
        alert("您还没登陆。");
}


function showTip(path){
    if(path=="en/")
        alert("Add success!");
    else
        alert("添加成功！");
}

function showError(path){
    if(path=="en/")
        alert("You have added this design!");
    else
        alert("您已经添加过该作品了。");
}

function checkVideo(){
    if($("#hidvideo").val()=="2"){
        $("#video").show();
    }
    else{
        $("#video").hide();
    }
}

function viewVideo(){
    openNew('videoplayer.aspx?id='+$("#hidfileid").val()+"&width=525",document.getElementById("photoTitle").innerHTML);
}

var request = {
    QueryString: function(name, url) {
        url = url || location.href;
        var r = new RegExp("(\\?|#|&)" + name + "=([^&#]*)(&|#|$)", "i");
        var m = url.match(r);
        return (!m ? "" : m[2]);
    },
    Form: function(name) {
        return $(name).val();
    }
};
//打开一个新ajax窗口
function openNew(url, title, loadcallback) {
    var width = request.QueryString("width", url);
    var height = request.QueryString("height", url); 
    var dragable = request.QueryString("dragable", url); 
    url = url.indexOf("?")>0?url+"&" + Math.random():url+"?"+Math.random();   
    var win = new ajaxWin({
        url: url,
        height: height,
        width: width,
        title: title,
        loadcallback:loadcallback,
        dragable:dragable
    });
    win.open();    
}



