/***********************************************
* Bookmark site script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title, url){
  if (window.sidebar) { // firefox
	  window.sidebar.addPanel(title, url, "");
	} else if(window.opera && window.print){ // opera
  	var elem = document.createElement('a');
  	elem.setAttribute('href',url);
  	elem.setAttribute('title',title);
  	elem.setAttribute('rel','sidebar');
  	elem.click();
  }  else if(document.all) { // ie
	  window.external.AddFavorite(url, title);
	}
}

function ajaxFavor(id, obj){ 
  $.ajax({
   type: "get",
   url: "/main.php",
   data: "cf_view=mdo.FavorAdd&ref_id=" + id + "&cf_favorite_objtype=" + obj,
   success: function(msg){
     alert(msg);
   }
  });
}


function addAsPartner(id){
  $.ajax({
   type: "get",
   url: "/main.php",
   data: "cf_view=company.AddAsPartner&cf_company_id=" + id,
   success: function(msg){
     alert(msg);
   }
  });
}

function showPrice(product_id, id, click) {
  if(undefined == click) {
    click = false;
  }
  $.ajax({
   type: "get",
   cache: false,
   url: "/main.php",
   data: "cf_view=product.ShowPrice&cf_product_id=" + product_id + "&cf_click=" + click,
   success: function(msg){   		
      if(msg.indexOf('<img') != -1) {
        //$('#' + id).html(msg);
      } else {
        if('请先登录' == msg || '帐户余额不足,请先充值' == msg) {
          alert(msg);
          if('请先登录' == msg) {
            window.location.href = '/login.html?cf_return=' + request_uri;
          } else {
            window.location.href = '/main.php?cf_view=mdo.MyBalance';
          }
        } else {
          if(confirm(msg + "\n您是否希望按次付费查看？")) {
            showPrice(product_id, id, true)
          }
        } 
      }
   }
  });
}