/*
 * softkeybord関連のJS
 *
 */

function showKeyboard(targetId,defaultQuery,categoryPath,categoryName,selectCategoryFlag){
   
   var flashUrl = 'http://i.yimg.jp/images/kids/search/softkeyboard/keyboard.swf';
   //var flashUrl = './keyboard.swf';

   var flashVer = '1002';

   var flashcontent = YAHOO.util.Dom.get(targetId);
   flashcontent.innerHTML="FLASHがインストールされていません。";
   
   var so = new SWFObject(flashUrl+'?v='+flashVer, "keyboar", "618", "465", "8", "#FFFFFF");

   so.addParam('allowScriptAccess','always');
   
   //check os
   var isWin = true;
   if(navigator.userAgent.indexOf('Windows') < 0){
       isWin = false;
   }

   if(defaultQuery !== undefined){
       so.addVariable("defaultQuery",defaultQuery);
   }

   if(categoryPath !== undefined){
       so.addVariable("categoryPath",categoryPath);
   }

   if(categoryName !== undefined){
       so.addVariable("categoryName",categoryName);
   }

   if(selectCategoryFlag !== undefined){
       so.addVariable("selectCategoryFlag",selectCategoryFlag);
   }

   if(isWin){
       so.addVariable("isWin","TRUE");
   }else{
       so.addVariable("isWin","FALSE");
   }

   so.addVariable('testMode','OFF');

   so.addVariable('apiUrl','http://api.search.kids.yahoo.co.jp/Search/V1/kanaConv');
   so.write(targetId);
}

function showHelp(helpType){

    //location.href = 'http://help.yahoo.co.jp/help/jp/kids/';
    //var helpUrl = 'http://help.yahoo.co.jp/help/jp/kids/';  

    var helpUrl = '';
    if(helpType == 'category'){
        helpUrl = 'http://guide.kids.yahoo.co.jp/keyboard/category/index.html';
    }else{
        helpUrl = 'http://guide.kids.yahoo.co.jp/keyboard/standard/index.html';
    }
    
    window.open(helpUrl,'kidshelp','width=660,height=590,scrollbars=yes');
    
}


function executeSearch(query,categoryPath,categoryName){

    //alert('EXECUTE SEARCH...');

    var rdurl = '';

    if(typeof(search_box_rd_name) === 'undefined'){
        rdurl = 'http://rd.yahoo.co.jp/kids/search/box/';
    }else{
        rdurl = 'http://rd.yahoo.co.jp/kids/search' + search_box_rd_name + 'sk/';
    }

    var option = '';
    if(categoryPath !== undefined){
        option = '&y=n&r='+encodeURI(categoryPath)+'&rn='+encodeURI(categoryName);
    }

    var search_url = rdurl + '*http://search.kids.yahoo.co.jp/bin/search?ei=UTF-8&p=' + encodeURI(query) + option;


    if(document.domain.indexOf('cvt') == -1){
        //normal
        top.location.href = search_url;
        return;

    }else{
        //using yomigana
        var regObj  = new RegExp('ykvrank([0-9])');
        var rankStr = location.href.match(regObj);

	var cvtUrl = 'http://cvt.kids.yahoo.co.jp/yomigana/index.cgi?ykvrank' + rankStr[1]+ '&ykvdesturl=';

        top.location.href = cvtUrl + search_url;
        return;
    }
}





