/**
 * vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 
 * 
 * ExciteWomanRecipe
 *
 * @package EWR
 * @author  
 * @version $Id: recipe.js,v 1.13 2006/08/24 05:31:08 excited Exp $
 * @since   Man Mar 27 10:30:52 GMT+09:00 2006 
 */


/**
 * font resize
 *
 */
function reSizeFont(size)
{
    if (size == 0){
        $('material').style.fontSize = '0.6em';
    }else if (size == 1){
        $('material').style.fontSize = '0.8em';
    }else{
        $('material').style.fontSize = '1em';
    }

}

/**
 * printer
 *
 */
function print_out() 
{
   /* print() が使えるブラウザかどうかを判断 */
   if (navigator.userAgent.match(/msie (\d)/i))
      v = (eval(RegExp.$1) >= 5) ? 1 : 0;
   else if (self.innerWidth)
      v = (eval(navigator.appVersion.charAt(0)) >= 4) ? 1 : 0;
   else v = 0;

   /* print() が使えるブラウザなら印刷を実行 */
   if (v) self.print();
   else alert("お使いのブラウザではこの機能は利用できません。");
}


/**
 * 材料の削除
 */
function deleteMaterial(order_num)
{
    var mRet=confirm("本当に削除しますか");
    if(!mRet){
        return;
    }else{
        var url = "/api/recipe/material/rm/?order_num="+order_num;
        bear(url);
    }
}

/**
 * 作り方の削除
 */
function deleteProcess(process_num)
{
    var mRet=confirm("本当に削除しますか");
    if(!mRet){
        return;
    }else{
        var url = "/api/recipe/process/rm/?process_num="+process_num;
        bear(url);
    }
}

/**
 * レビューの削除
 */
function deleteReview(review_id,recipe_id)
{
    var mRet=confirm("本当に削除しますか");
    if(!mRet){
        return;
    }else{
        var url = "/api/review/delete.php?review_id="+review_id+"&recipe_id="+recipe_id;
        bear(url);
    }
}


/**
 * 画像アップロードフォーム
 */
function uploadForm(tag)
{

    if($(tag+'_recipe').style.display != 'none'){
        $(tag+'_recipe').style.display = 'none';
        $(tag+'_iframe').style.display = 'block';
    }

}

/**
 * 画像アップロードフォーム
 */
function backUploadForm(tag)
{
    var par = window.parent.document;
    var iframe_tag = par.getElementById(tag+'_iframe');
    iframe_tag.style.display = 'none';

    var image = par.getElementById(tag+'_recipe');
    image.style.display = 'block';

}

/**
 * 画像のアップロード
 *
 */
function upload(form)
{
    // hide old iframe
    var par = window.parent.document;
    var img_tag = form.img_tag.value;
    var hidden_tag = form.hidden_tag.value;

    // add image progress
    var image = par.getElementById(img_tag);
    image.src = 'http://image.excite.co.jp/jp/med/progress_01_red.gif';
//    image.width = '15';

    // send
    setTimeout("document.form.submit()",1000);
}

/**
 * 画像アップロード
 *
 */
function finishImage(imagePath,hidden_tag,img_tag,domain)
{

    var par = window.parent.document;
    var image = par.getElementById(img_tag);
    image.src = domain+imagePath;
//    image.width = '280';
    var image = par.getElementById(hidden_tag+'_recipe');
    image.style.display = 'block';

    var image = par.getElementById(hidden_tag);
    image.value = imagePath;

    var delete_tag = par.getElementById(hidden_tag+'_delete');
    delete_tag.style.display = 'block';

    var iframe_tag = par.getElementById(hidden_tag+'_iframe');
    iframe_tag.style.display = 'none';
}

/**
 * ダイアログ表示
 * (OKならば指定のURLへ遷移)
 */
function userConfirm(msg,url)
{
    myConf = confirm(msg);
    if(myConf) window.location.href = url;
}

