function validator_keyword(){
  if ($('key_word').value == ""){
    alert("please input the key word");
    $('key_word').focus();
    return false;
  }
  return true;
}
function submit_email_friend_form(form){
  if($('email_friend_user_addr').value == ''){
    alert("Please enter sender email");
    return false;
  }
  if($('email_friend_addr1').value == '' && $('email_friend_addr2').value == '' && $('email_friend_addr3').value == ''){
    alert("Please enter at least one receiver email");
    return false;
  }
  if($('email_friend_title').value == '' && $('email_friend_content').value == ''){
    alert("Please enter title or content");
    return false;
  }
  form.onsubmit();
  return true;
}
function validator_submit_deal_form(){
  if($('submit_deal_deal_url').value == ''){
    alert('Please enter deal url');
    $('submit_deal_deal_url').focus();
    return false;
  }else if($('submit_deal_title').value == ''){
    alert('Please enter title');
    $('submit_deal_title').focus();
    return false;
  }
  return true;
}

function toggle_coupon_comment_from(coupon_id,if_good){
    $("comments" + coupon_id).hide();
    if (if_good)
    {
        $("comment1" + coupon_id).hide();
        $("comment0" + coupon_id).toggle();
    }
    else
    {
        $("comment0" + coupon_id).hide();
        $("comment1" + coupon_id).toggle();
    }
    var url = "/coupon_comments/new?coupon_id=" + coupon_id;
    if(if_good) url = url + "&good=yes";
    new Ajax.Request(url,{method:'get',onComplete:function(response) {
            if(if_good){
                $('comment0' + coupon_id).update(response.responseText);   
            }else{
                $('comment1' + coupon_id).update(response.responseText);   
            }
            
        }});
}

function request_coupon_comments(coupon_id){
 new Ajax.Request("/coupon_comments/index?coupon_id=" +coupon_id,{asynchronous:true, evalScripts:true});
}

function toggle_coupon_comments(coupon_id){
    $("comment1" + coupon_id).hide()
    $("comment0" + coupon_id).hide()
    $("comments" + coupon_id).toggle()
}


function generate_compare_price_htmls(type_id,product_id){
  var cobrand_id = '1306';
  var rating_star_type = 1;
  var cb_limit = 6;
  var open_link_type2 = 1;
  var show_link_price2 = 1;
  var head_title_type = '1';
  document.write('<scr'+'ipt src="http://ah.pricegrabber.com/cb_table.php?'+
    type_id+'='+product_id+
    '&dw=1'+
    '&cobrand_id='+cobrand_id+
    '&rst='+rating_star_type+
    '&slp='+show_link_price2+
    '&olt='+open_link_type2+
    '&l='+cb_limit+
    '&htt='+head_title_type+
    '"></scr'+'ipt>');
}