﻿/// <reference name="MicrosoftAjax.js" />
/*
    ishoot ajax history
    date : 2009.12.02
    
*/



//history
Sys.Application.add_navigate(fn_addNavigate);


function fn_addNavigate(sender, args) {
    //alert(sender);
    
    //Sys.Application.remove_navigate;
    var value = args._state["PageInfo"];    
    if(value != undefined && value != "" && value != "undefined"){
        //alert("add_navigate : " + value);
        var values = value.split(":");
        //alert(values[0]);
        if(values[0] == "list"){
            //alert("fn_addNavigate : " + value);
            //*
            var values2 = values[1].split("|");
            if(values2[0] != undefined && values2[0] != "" && values2[0] != "undefined" && values2[1] != undefined && values2[1] != "" && values2[1] != "undefined"){
                var shooterId = values2[0];
                var page = values2[1];
                //alert(shooterId + "/" + page);
                try{
                    fn_getShootList_after2(shooterId, page);
                }catch(e){
                    //alert(e);
                    //fn_addLoad()                
                    //Sys.Application.add_navigate(fn_addNavigate);
                    //wait(1000);
                    //fn_addNavigate(sender, args);
                    //fn_getShootList_after2(shooterId, page);
                    //alert ("code:" + e.number +"\r\ndesc:" + e.description);

                }
            }
        }else if(values[0] == "view"){
            var values2 = values[1].split("|");
            if(values2[0] != undefined && values2[0] != "" && values2[0] != "undefined" && values2[1] != undefined && values2[1] != "" && values2[1] != "undefined"){
                var shootuid = values2[0];
                var type = values2[1];
                //alert(shootuid + "/" + page);
                try{
                    
                    fn_getShooting(shootuid, type);            
                    $get("shootList_list").style.display = "none";
                    $get("shootList_Detail").style.display = "block";
                }catch(e){
                    //alert(e);
                    //fn_addLoad()                
                    //Sys.Application.add_navigate(fn_addNavigate);
                    //wait(1000);
                    //fn_addNavigate(sender, args);
                    //fn_getShootList_after2(shooterId, page);
                    //alert ("code:" + e.number +"\r\ndesc:" + e.description);

                }
            }
        }else if(values[0] == "reply"){
            var values2 = values[1].split("|");
            if(values2[0] != undefined && values2[0] != "" && values2[0] != "undefined"){
                var page = values2[0];                
                //alert(shootuid + "/" + page);
                try{
                    
                    fn_getShootingReplyList2(page);            
                    $get("shootList_list").style.display = "block";
                    $get("shootList_Detail").style.display = "none";
                }catch(e){
                }
            }
        }
        //*/
        //alert(values[1]);
        
        Sys.Debug.trace("Navigated to state " + value);
    }
    
}

//load 
Sys.Application.add_load(fn_addLoad);

function fn_addLoad(){
    //Sys.Application.add_navigate(fn_addNavigate);
}


//페이지 이동시 기억할것
function fn_setHistoryToPage(page){
    //alert("fn_setHistoryToPage : " + page);
    /*
    var value = "list:" + _libraryType + "|" + _shootingSortType + "|"+ _sortType + "|" + _viewType;
        value += "|" + _shootingType + "|" + _partyUID
        value += "|" + _shootingDirectionType + "|" + _shootStateCodeType;
        value += "|" + _authorizeCodeType;
        value += "|" + _mediaType + "|" + _string + "|" + _stringTag;
        value += "|" + page;
        value += "|" + _shooterId;
    */
    //슛상세 reset
    fn_shootDetailReset();
        
        
    var value = "list:" + _shooterId + "|" + page;  
    //alert(value);
    //var value = page;  
    //alert("setHistory : " + value);
    if(page != ""){
        Sys.Application.addHistoryPoint({PageInfo: value} , "PageInfo:"+ value);
        Sys.Debug.trace("History point added: " + value);
        //fn_pageing(page);
    }
}

//슛상세보기로 갈경우 값기억할것들
function fn_setHistoryToShootDetail(uid, shootType){
    var value = "view:" + uid + "|" + shootType;
    if(uid != ""){
        //alert(value);
        Sys.Application.addHistoryPoint({PageInfo: value} , "PageInfo:"+ value);
        Sys.Debug.trace("History point added: " + value);
    }
}

//슈팅이야기에서 페이징
function fn_setHistoryToShootReply(page){
    var value = "reply:" + page;
    if(page != ""){
        //alert(value);
        Sys.Application.addHistoryPoint({PageInfo: value} , "PageInfo:"+ value);
        Sys.Debug.trace("History point added: " + value);
    }    
}


    
function wait(msecs){

    var start = new Date().getTime();
    var cur = start;
    while(cur - start < msecs){
        cur = new Date().getTime();
    }
} 

