﻿// JScript ファイル
var startCat;
var startDetailCat = "";
var startDetailMaker = "";


var nyuukaDates = new Array();
var yoyakuDates = new Array();

var tblMaker;
var tblCat;
var catHtml = "";
var makerHtml = "";

function startPrep()
{
    setCategory();
    setProdPos();
   setCategoryUnder(); 
    showCart(); 
   tokubetu = 0; 
    setNyuukaDates();
    setYoyakuDates();
}
function setProdPos()
{
    var w = YAHOO.util.Dom.getViewportWidth();
    var h = YAHOO.util.Dom.getViewportHeight();
    var hw = w /2;
    var gh = h - 210;
    var wh = h - 20;
    $("gridCont").style.height = gh + "px";
    $("wrapper").style.height = wh + "px";
    $("prodSelector").style.height = gh + "px";
    if(startCat != "moku")
    {
        if($("selectMaker") != null)
        {
            $("selectMaker").style.height = (h - 350).toString() + "px";
        }
        if($("selectCategory") != null)
        {
            $("selectCategory").style.height = (h - 350).toString() + "px";
        }
    }
    if(w > 900)
    {
        $("wrapper").style.width = (w - 50).toString() + "px";
        $("header").style.width = (w - 50).toString() + "px";
        $("prodMenu").style.width = (w - 97).toString() + "px";
        $("prodGrid").style.width = (w - 97).toString() + "px";
        $("showProdDiv").style.width = (w - 97).toString() + "px";
    }
    else
    {
        $("wrapper").style.width = "807px";
        $("header").style.width = "800px"
        $("prodMenu").style.width = "760px";
        $("prodGrid").style.width = "760px";
        $("showProdDiv").style.width = "760px";
    }
    setGridContWidth();
}

function setCategoryUnder()
{
    var html = "";
    var count = prodsCat.length;
    $("underCat").style.width = (130 * count).toString() + "px";
    for(var i = 0; i < count; i++)
    {
        var catName = prodsCat[i][0];
        var catSt = prodsCat[i][2];
        html += "<a href=\"productsGrid.aspx?" + catSt + "=0\">" + catName + "</a>";
    }
    Element.update("underCat", html);
}

function setGridContWidth()
{
    var w = YAHOO.util.Dom.getViewportWidth();
    var w1;
    var w2;
    if(w > 900)
    {
        w1 = w - 290;
        w2 = w - 97;
    }
    else
    {
        w1 = 570;
        w2 = 760;
    }
    if(startCat != "search")
    {
        $("gridCont").style.width = w1 + "px";
    }
    else
    {
        $("gridCont").style.width = w2 + "px";
    }
}

window.onload = startPrep;
window.onresize = setProdPos;

function setCatStart(catId)
{
    getCategories();
    startCat = catId;
    setTimeout("getCatStart()", 100);
}

function setCatDetailStart(catId, catno)
{
    startCat = catno;
    startDetailCat = catId;
    $("prodSelector").style.display = "block";
    setGridContWidth();
    pageNo = 0;
    setTimeout("getCatDetailStart()", 100);
}

function setMakerDetailStart(catId, maker)
{
    startCat = catId;
    startDetailMaker = maker;
    $("prodSelector").style.display = "block";
    setGridContWidth();
    pageNo = 0;
    setTimeout("getMakerDetailStart()", 100);

}

function setStartYoyakuData(mMonth, cat)
{
        if(cat == "fig" || cat == "mini" || cat == "gasya" || cat == "syoku")
        {
                startCat = cat;
                $("prodSelector").style.display = "block";
                setGridContWidth();
                pageNo = 0;
                startMMonth = mMonth;   
                setTimeout("getStartYoyakuData()", 100);   
        }    
}

function getStartYoyakuData()
{
        if(startCat == "fig" || startCat == "gasya")
       { 
            fillSelector();
       } 
        var start = new Date();
        var myDate = new Date();
        myDate.setMonth(start.getMonth() + startMMonth);
        var y = myDate.getFullYear();
        var m = myDate.getMonth() + 1;
        var stP;
        if(startMMonth == 5)
        {
            stP = y.toString() + "年" + m.toString() + "月以降予約";
        }
        else
        {
            stP = y.toString() + "年" + m.toString() + "月予約";;
        }
       var title = getSelectedTitle() + "　（" + stP + "）";
       Element.update("selectTitle",  title);
       showStartSelector(); 
        getSelectedData("yoyaku", 0, startMMonth, "0", "0");
}

function setStartNyuukaData(mMonth, cat)
{
        if(cat == "fig" || cat == "mini" || cat == "gasya" || cat == "syoku")
        {
                startCat = cat;
                $("prodSelector").style.display = "block";
                setGridContWidth();
                pageNo = 0;
                startMMonth = mMonth;   
                setTimeout("getStartNyuukaData()", 100);   
        }    
}

function getStartNyuukaData()
{
        if(startCat == "fig" || startCat == "gasya")
       { 
            fillSelector();
       } 
        var start = new Date();
        var myDate = new Date();
        myDate.setMonth(start.getMonth() - startMMonth);
        var y = myDate.getFullYear();
        var m = myDate.getMonth() + 1;
        var stP;
        if(startMMonth == 0)
        {
            stP = y.toString() + "年" + m.toString() + "月入荷済み";
        }
        else
        {
            stP = y.toString() + "年" + m.toString() + "月入荷";;
        }
       var title = getSelectedTitle() + "　（" + stP + "）";
       Element.update("selectTitle",  title);
       showStartSelector(); 
        getSelectedData("nyuuka", startMMonth, 0,  "0", "0");
}

function getCatDetailStart()
{
    getSelectedData("cat", 0, 0, "0", startDetailCat);
    fillSelector();
}

function getMakerDetailStart()
{
    getSelectedData("maker", 0, 0, startDetailMaker, "0");
    fillSelector();
}



function setSearchStart(key, cat)
{
    startCat = "search";
    getSearchedData(key, cat);
}




function setNyuukaDates()
{
    var start = new Date();
    var m = start.getMonth() + 1;
    var y = start.getFullYear(); 
    for(var i = 0; i < 6; i++)
    {
       if(m == 0)
       {
            m = 12;
           y -= 1;  
       }   
        var stP;
        if(i == 0)
        {
            stP = y.toString() + "年" + m.toString() + "月入荷済み";
        }
        else
        {
            stP = y.toString() + "年" + m.toString() + "月入荷";
        }
        var st = "<a href=\"#\" onclick=\"selectNyuuka_change(" + i + ", '" + stP + "')\">" + stP + "</a>";
        nyuukaDates[i] = st;
       m--; 
    }
}

function setYoyakuDates()
{
    var start = new Date();
    var y = start.getFullYear();
    var m = start.getMonth() + 1; 
    for(var i = 0; i < 6; i++)
    {
        if(m == 13)
       {
            m = 1;
            y++;
        }    
        var stP;
        if(i == 5)
        {
            stP = y.toString() + "年" + m.toString() + "月以降予約";
        }
        else
        {
            stP = y.toString() + "年" + m.toString() + "月予約";
        }
        var st = "<a href=\"#\" onclick=\"selectYoyaku_change(" + i + ", '" + stP + "')\">" + stP + "</a>";
        yoyakuDates[i] = st;
       m++; 
    }
}

function getStartTitle()
{
    var title = "";
    switch (startCat)
    {
        case "fig":
            title = "フィギュア　（今月入荷済み）";
            break;
         case "doll":
            title = "ドール　（今月入荷済み）";
            break;  
        case "moku":
            title = "木製模型　（木製建築模型）";
            break;
        case "gasya":
            title = "ガチャガチャ・ガシャポン　（今月入荷済み）";
            break;
        case "syoku":
            title = "トレーディングフィギュア・食玩　（今月入荷済み）";
            break;
        case "mini":
            title = "ミニカー・車・バイク・飛行機　（今月入荷済み）";
            break;
        case "pra":
            title = "プラモデル　（今月入荷済み）";
            break;  
            
    }
    return title;
}

function getCatStart()
{
    $("prodSelector").style.display = "block";
    setGridContWidth();
    fillSelector();
    pageNo = 0;
   setTimeout("getFirstSelectData()", 500); 
}

function getFirstSelectData()
{
    var dataEnd = 14;
    if(slideMode == 2)
    {
        dataEnd = 19;
    }
    ProductsGridCode.ReturnFirstSelectData(startCat, dataEnd, getCatStart_callback);
}

function getCatStart_callback(res)
{
    Element.update("selectTitle", getStartTitle());
    if(res.error != null)
    {
        alert(res.error);
        var html = "<span style=\"font-size: 16px;\">データがありません。</span>";
        Element.update("gridCont", html);
        prodCount = 0;
    }
    else
    {
        showStartSelector()
        prodDs = res.value;
        dataCount = prodDs.Tables[0].Rows.length;
        if(dataCount > 0)
        {
            prodCount = prodDs.Tables[0].Rows[0].ProdCount;
            setDetail();
        }
        else
        {
            prodCount = 0;
            var html = "";
            if(startCat != "moku")
            {
                html = "<span style=\"font-size: 16px;\">今月入荷分のデータがありません。先月入荷分を表示します.........</span>";
                Element.update("gridCont", html);
                setTimeout("showPreMonthData()", 1000);
            }
            else
            {
                html = "<span style=\"font-size: 16px;\">データがありません。</span>";
                Element.update("gridCont", html);
            }
            
        }
    }
}

function showPreMonthData()
{
    var myDate = new Date();
    myDate.setMonth(myDate.getMonth() - 1);
    var y = myDate.getFullYear();
    var m = myDate.getMonth() + 1;
    var sTitle = y.toString() + "年" + m.toString() + "月入荷";
    selectNyuuka_change(1, sTitle)
}

function fillSelector()
{
    getCatMaker();
}


function getCatMaker()
{
    ProductsGridCode.ReturnCatMaker(startCat, getCatMaker_callback);
}



function getCatMaker_callback(res)
{
    if(res.error != null)
    {
        alert(res.error);
    }
    else
    {
        tblMaker = res.value.Tables[0];
        tblCat = res.value.Tables[1];
        setCategoryList();
        setMakerList();
    }
}

function setCategoryList()
{
    var count = tblCat.Rows.length;
    var catCount = count;
   var html = ""; 
   if(count > 0)
   {
       var h = YAHOO.util.Dom.getViewportHeight() - 300;
       if(startCat == "moku")
       {
            html = "<select id=\"selectCategory\" size=\"" + count.toString() + "\" onchange=\"selectCat_change()\">";
       }
       else
       {
            html = "<select id=\"selectCategory\" size=\"10\" style=\"height: " + h.toString() + "px;\" onchange=\"selectCat_change()\">";
       }
       for(var i = 0; i < count; i++)
       {
            var cNo = tblCat.Rows[i].Cat_ID;
            var wNew = tblCat.Rows[i].IsNewProd;
			var cName = tblCat.Rows[i].Category;
			cName = cName.replace("(", "（");
			cName = cName.replace(")", "）");
			cName = cName.replace(".", "");
			cName = cName.replace("&", "＆");
			cName = cName.replace("'", "");
			if(wNew == 1)
			{
			    html += "<option value=\"N" + cNo.toString() + "\" style=\"color: yellow;\">" + cName + "New</option>";
			    catCount++;
			}
			html += "<option value=\"" + cNo.toString() + "\">" + cName + "</option>";
       }
       html += "</select>";
       if(startCat == "moku" && catCount > count)
       {
            html = html.replace("<select id=\"selectCategory\" size=\"" + count.toString() + "\" onchange=\"selectCat_change()\">", "<select id=\"selectCategory\" size=\"" + catCount.toString() + "\" onchange=\"selectCat_change()\">");
       }

   }
    catHtml = html;
     if(startDetailCat != "")
    {
         var cName = returnCatName(startDetailCat);
         var title = getSelectedTitle() + "　（" + cName + "）";
         Element.update("selectTitle", title);
         if(startCat != "moku")
        {
            showCatList();
        }
        else
        {
            showStartSelector();
         }  
    } 
   
}


function setMakerList()
{
    var count = tblMaker.Rows.length;
    var makerCount = count;
    var html = ""; 
    if(count > 0)
    {
        var h = YAHOO.util.Dom.getViewportHeight() - 350;
        if(startCat == "moku")
        {
            html = "<select id=\"selectMaker\" size=\"" + count.toString() + "\" onchange=\"selectMaker_change()\">";
        }
        else
        {
            html = "<select id=\"selectMaker\" size=\"2\" style=\"height: " + h.toString() + "px;\" onchange=\"selectMaker_change()\">";
        }
        for(var i = 0; i < count; i++)
        {
             var wNew = tblMaker.Rows[i].IsNewProd;
			 var cName = tblMaker.Rows[i].M_Name;
			 cName = cName.replace("(", "（");
			 cName = cName.replace(")", "）");
			 cName = cName.replace(".", "");
			 cName = cName.replace("&", "＆");
			 cName = cName.replace("'", "");
			 var cNo = tblMaker.Rows[i].Maker_ID;
			 if(wNew == 1)
			 {
			    html += "<option value=\"N" + cNo.toString() + "\" style=\"color: yellow;\">" + cName + "New</option>";
			    makerCount++;
			 }
			 html += "<option value=\"" + cNo.toString() + "\">" + cName + "</option>";
        }
        html += "</select>"; 
        if(startCat == "moku" && makerCount > count)
        {
            html = html.replace("<select id=\"selectMaker\" size=\"" + count.toString() + "\" onchange=\"selectMaker_change()\">", "<select id=\"selectMaker\" size=\"" + makerCount.toString() + "\" onchange=\"selectMaker_change()\">");
        }

       
    }
    makerHtml = html;
   
    if(startDetailMaker != "")
    {
        var cName = returnMakerName(startDetailMaker);
        var title = getSelectedTitle() + "　（" + cName + "）";
        Element.update("selectTitle", title);
        if(startCat != "moku")
        {
            showMakerList();
        }
        else
        {
            showStartSelector();
         }
    } 
}

function showMakerList()
{
    var html = "<span style=\"cursor:pointer;\" onclick=\"makerSearch()\">メーカーリスト</span><input id=\"txtMakerSearch\" type=\"text\" style=\"width: 85px;\" onkeydown=\"makerHandlenavi()\">";
    html += makerHtml;
    html +="<a href=\"#\" class=\"setA\" onclick=\"showCatList()\">ジャンルリスト</a>";
    if(startCat != "moku")
    {
        html +="<a href=\"#\" class=\"setA\" onclick=\"showStartSelector()\">入荷・予約</a>";
    } 
    Element.update("prodSelector", html);
    if(makerHtml != "")
   {  
        if(startCat != "moku")
        {
            var h = YAHOO.util.Dom.getViewportHeight() - 350;
            $("selectMaker").style.height = h.toString() + "px";
        }
        if(startDetailMaker != "" && startCat != "moku")
        {
            setMakerSelectIndex();
        }
   }
}

function showCatList()
{
    var html = "<span style=\"cursor:pointer;\" onclick=\"categorySearch()\">ジャンルリスト</span><input id=\"txtCatSearch\" type=\"text\" style=\"width: 85px;\" onkeydown=\"catHandlenavi()\">";
    html += catHtml;
    html +="<a href=\"#\" class=\"setA\" onclick=\"showMakerList()\">メーカーリスト</a>";
    if(startCat != "moku")
    {
        html +="<a href=\"#\" class=\"setA\" onclick=\"showStartSelector()\">入荷・予約</a>";
    }
    Element.update("prodSelector", html);
   if(catHtml != "")
    {    
        if(startCat != "moku")
        {
         var h = YAHOO.util.Dom.getViewportHeight() - 350;
            $("selectCategory").style.height = h.toString() + "px";
        }
        if(startDetailCat != "" && startCat != "moku")
        {
            setCatSelectIndex();  
        }
   } 
}

function showStartSelector()
{
    var html = "";
    if(startCat != "moku")
    {
        html +="<span class=\"secTitle\">入荷済み商品</span>";
        var count = nyuukaDates.length;
        for(var i = 0; i < count; i++)
        {
            html += nyuukaDates[i];
        }
         html +="<span class=\"secTitle\">予約商品</span>";
        var count = yoyakuDates.length;
        for(var i = 0; i < count; i++)
        {
            html += yoyakuDates[i];
        }
        html +="<a href=\"#\" class=\"setA\" onclick=\"showMakerList()\">メーカーリスト</a>";
        html +="<a href=\"#\" class=\"setA\" onclick=\"showCatList()\">ジャンルリスト</a>";
    }
    else
    {
        html +="<span class=\"secTitle\">メーカーリスト</span>";
        html += makerHtml;
        html +="<span class=\"secTitle\">ジャンルリスト</span>";
        html += catHtml;;
    }
    Element.update("prodSelector", html);
    if(startCat == "moku" && startDetailMaker != "")
    {
         setMakerSelectIndex();
    }
    else if(startCat == "moku" && startDetailCat != "")
    {
        setCatSelectIndex();
    }
}

function setCatSelectIndex()
{
    var count = document.forms[0].selectCategory.options.length;
    var ind = 0;
    for(var i = 0; i < count; i++)
    {
        var cNo = document.forms[0].selectCategory.options[i].value;
        if(cNo == startDetailCat)
        {
            ind = i;
            break;
        }
    }
    document.forms[0].selectCategory.selectedIndex = ind;
    startDetailCat = "";
    
}

function selectNyuuka_change(data, sTitle)
{
    var title = getSelectedTitle() + "　（" + sTitle + "）";
    Element.update("selectTitle", title);
    getSelectedData("nyuuka", data, 0, "0", "0");
}

function selectYoyaku_change(data, sTitle)
{
    var title = getSelectedTitle() + "　（" + sTitle + "）";
    Element.update("selectTitle", title);
    getSelectedData("yoyaku", 0, data, "0", "0");
}

function selectMaker_change()
{
    var p = document.forms[0].selectMaker.selectedIndex;
    var data = $F("selectMaker");
    var sTitle = document.forms[0].selectMaker.options[p].text;
    if(data.substring(0,1) == "N")
    {
        sTitle = sTitle.replace("New", "　予約商品");
    }
    var title = getSelectedTitle() + "　（" + sTitle + "）";
    Element.update("selectTitle", title);
    getSelectedData("maker", 0, 0, data, "0");
    if(startCat == "moku")
    {
        document.forms[0].selectCategory.selectedIndex = -1;
    }
}

function selectCat_change()
{
    var p = document.forms[0].selectCategory.selectedIndex;
    var data = $F("selectCategory");
    var sTitle = document.forms[0].selectCategory.options[p].text;
    if(data.substring(0,1) == "N")
    {
        sTitle = sTitle.replace("New", "　予約商品");
    }
    var title = getSelectedTitle() + "　（" + sTitle + "）";
    Element.update("selectTitle", title);
    getSelectedData("cat", 0, 0, "0", data);
    if(startCat == "moku")
    {
        document.forms[0].selectMaker.selectedIndex = -1;
    }
}
function getSelectedData(selectItem, nyuuka, yoyaku, maker, cat)
{
    var dataEnd = 14;
    if(slideMode == 2)
    {
        dataEnd = 19;
    }
    zanCount = 0;
    ProductsGridCode.ReturnSelectedData(startCat, selectItem, nyuuka, yoyaku, maker, cat, dataEnd, getSelectedData_callback);
}

function getSelectedData_callback(res)
{
    if(res.error != null)
    {
        alert(res.error);
        var html = "<span style=\"font-size: 16px;\">データがありません。</span>";
        Element.update("gridCont", html);
        prodCount = 0;
    }
    else
    {
        if(res.value != null && res.value.Tables[0].Rows.length > 0)
        {
            prodDs = res.value;
            setDetail();
            
        }
        else
        {
            var html = "<span style=\"font-size: 16px;\">データがありません。</span>";
            Element.update("gridCont", html)
            prodCount = 0;
        }
    }
}

function getSelectedTitle()
{
    var title = "";
    switch (startCat)
    {
        case "fig":
            title = "フィギュア";
            break;
        case "moku":
            title = "木製模型";
            break;
        case "gasya":
            title = "ガチャガチャ・ガシャポン";
            break;
        case "syoku":
            title = "トレーディングフィギュア・食玩";
            break;
        case "mini":
            title = "ミニカー・車・バイク・飛行機";
            break;
        case "doll":
            title = "ドール";
            break;  
        case "pra":
            title = "プラモデル";
            break;    
    }
    return title;
}

function setMakerSelectIndex()
{
    var count = document.forms[0].selectMaker.options.length;
    var ind = 0;
    for(var i = 0; i < count; i++)
    {
        var mNo = document.forms[0].selectMaker.options[i].value;
        if(mNo == startDetailMaker)
        {
            ind = i;
            break;
        }
    }
    document.forms[0].selectMaker.selectedIndex = ind;
    startDetailMaker = "";
}

function returnCatName(cNo)
{
    var cName = "";
    var p = cNo.substring(0, 1);
    if(p == "N")
    {
        var cLen = cNo.length;
        cNo = cNo.substring(1, cLen);
    }
    var count = tblCat.Rows.length;
    if(count > 0)
    {
        for(var i = 0; i < count; i++)
        {
            var catNo = tblCat.Rows[i].Cat_ID;
            if(catNo == cNo)
            {
                if(p == "N")
                {
                    cName = tblCat.Rows[i].Category + "　予約商品";
                }
                else
                {
                    cName = tblCat.Rows[i].Category;
                }
                break;
            }
        }
    }
    return cName;
}

function returnMakerName(mNo)
{
    var mName = "";
    var p = mNo.substring(0, 1);
    if(p == "N")
    {
        var cLen = mNo.length;
        mNo = mNo.substring(1, cLen);
    }
    var count = tblMaker.Rows.length;
    if(count > 0)
    {
        for(var i = 0; i < count; i++)
        {
            var makerNo = tblMaker.Rows[i].Maker_ID;
            if(makerNo == mNo)
            {
                if(p == "N")
                {
                    mName = tblMaker.Rows[i].M_Name + "　予約商品";
                }
                else
                {
                    mName = tblMaker.Rows[i].M_Name;
                }
                break;
            }
        }
    }
    return mName;
}

function getSearchedData(key, cat)
{
    $("prodSelector").style.display = "none";
    setGridContWidth();
    zanCount = 0
    Element.update("gridCont", "検索しています........");
    Element.update("selectTitle", "「" + key + "」の検索結果");
    var dataEnd = 14;
    if(slideMode == 2)
    {
        dataEnd = 19;
    }
    key.replace("(", "");
    key.replace(")", "");
    key = key.replace(" ", "@");
    key = key.replace("　", "@");
    ProductsGridCode.ReturnSearchedProducts(key, cat, dataEnd, memberID, getSearchedData_callback);
}

function getSearchedData_callback(res)
{
    if(res.error != null)
    {
        alert(res.error);
        var html = "<span style=\"font-size: 16px;\">検索の条件に一致するデータがありません。</span>";
        Element.update("gridCont", html);
        prodCount = 0;
    }
    else
    {
        if(res.value != null && res.value.Tables[0].Rows.length > 0)
        {
            prodDs = res.value;
            var count = prodDs.Tables[0].Rows[0].ProdCount;
            $("selectTitle").innerHTML += "　" + count.toString() + "件見つかりました。";
            setDetail();
        }
        else
        {
            var html = "<span style=\"font-size: 16px;\">検索の条件に一致するデータがありません。</span>";
            Element.update("gridCont", html);
            prodCount = 0;
            
        }
    }
}
function getSearchedAllData_callback(res)
{
    if(res.error != null)
    {
        alert(res.error);
        var html = "<span style=\"font-size: 16px;\">検索の条件に一致するデータがありません。</span>";
        Element.update("gridCont", html);
        prodCount = 0;
    }
    else
    {
        alert("ばか"); 
        if(res.value != null && res.value.Tables[0].Rows.length > 0)
        {
            prodDs = res.value;
            var count = prodDs.Tables[0].Rows[0].ProdCount;
            $("selectTitle").innerHTML += "　" + count.toString() + "件見つかりました。";
            setDetail();
        }
        else
        {
            var html = "<span style=\"font-size: 16px;\">検索の条件に一致するデータがありません。</span>";
            Element.update("gridCont", html);
            prodCount = 0;
            
        }
    }
}
function searchHandleNaviProd(evt)
{
    evt = (evt) ? evt : ((window.event) ? event: null);
    if(evt)
    {
        if(evt.keyCode == 13)
        {
          prodSearchExecProd();
        }
    }
}
function prodSearchExecProd()
{
    var key = $F("txtKey");
    if(key != "")
    {
        startCat = "search";
        var ind = document.forms[0].selectSearchCat.selectedIndex;
        var cat = document.forms[0].selectSearchCat.options[ind].value;
        getSearchedData(key, cat);
    }
}

function gotoProducts(cat)
{
    startCat = cat;
    tblCat = null;
    tblMaker = null;
    catHtml = "";
    makerHtml = "";
    getCatStart();
}

function makerSearch()
{
    var maker = $F("txtMakerSearch");
    var p = -1;
    var ind = 0;
    if(maker != "")
    {
        var count = document.forms[0].selectMaker.options.length;
        for(var i = 0; i < count; i++)
        {
            var makerName = document.forms[0].selectMaker.options[i].text;
            p = makerName.indexOf(maker);
            if(p == 0)
            {
                document.forms[0].selectMaker.selectedIndex = i;
                selectMaker_change();
                break;
            }
        }
    }
}

function makerHandlenavi(evt)
{
    evt = (evt) ? evt : ((window.event) ? event: null);
    if(evt)
    {
        if(evt.keyCode == 13)
        {
          makerSearch();
        }
    }
}

function categorySearch()
{
     var cat = $F("txtCatSearch");
    if(cat != "")
    {
        var count = document.forms[0].selectCategory.options.length;
        for(var i = 0; i < count; i++)
        {
            var catName = document.forms[0].selectCategory.options[i].text;
            var k = catName.length;
            p = catName.indexOf(cat);
            if(p == 0)
            {
                document.forms[0].selectCategory.selectedIndex = i;
                selectCat_change();
                break;
            }
        }
    }
}

function catHandlenavi(evt)
{
    evt = (evt) ? evt : ((window.event) ? event: null);
    if(evt)
    {
        if(evt.keyCode == 13)
        {
          categorySearch();
        }
    }
}

function gotoProductsHide(cat, ind)
{
    $("prodCat").style.display = "none";
    gotoProducts(cat, ind);
}



