function textQuickTip(object,txt){
	Ext.QuickTips.register({
	    target:  object,
        trackMouse: true,
        text: txt,
        width:400,
        title: '详情'
    }); 
}

function confirmClick(){
	$("#loginform").submit();
}

function closeClick(){
	$("#cancelreson").find("div").hide();
	$("#cancelreson").toggle("slow");
}

  function buyProduct(id){
      document.getElementById("buyform").submit();
  }
  
  
  function noLogin(){
} 
  
  function myCollect(id){
	var params = Ext.urlEncode({"id":id});
	Ext.Ajax.request({"url":webroot+'/security/logincheck.htm?method=loginedCheck',"params":params,"method":"POST",failure:noLogin, success:loginSuccessful});		
  } 
  
  function loginSuccessful(response,opt){
	var strResponse = ""+response.responseText+"";
	var jsonObject = eval('('+strResponse+')');
	if(jsonObject.successful=="false"){
		$("#cancelreson").show();	
		return;
	}
	
	if(jsonObject.saletarget!="A"&&jsonObject.saletarget!=jsonObject.loginedtype){
		alert("你不能收藏该产品!");
		return;
	}
		
	var productId = document.getElementById("inproductid").value;
	var params = Ext.urlEncode({"productid":productId});
	Ext.Ajax.request({"url":webroot+'/product/insproductajax.htm?method=storeCollectProduct',"params":params,"method":"POST",failure:collectFail, success:collectSuccess});		
}

   function collectSuccess(response,opt){
	var strResponse = response.responseText;
	
	if(strResponse.trim()==="{successful:false}"){
		alert("您已经收藏了这款保险产品,不能重复收藏!");
		return;
	}
	
	alert("收藏成功");
	}

   function collectFail(){
   } 

function forwardproduct(comtypeid,comid,comcompanyid){
	var forwardurl = webroot+"/product/insproduct.htm?method=viewDetail";

	forwardurl+="&typeid="+comtypeid+"&id="+comid+"&companyid="+comcompanyid;

	window.location = forwardurl;
}
   
   Ext.onReady(function(){
    Ext.QuickTips.init();
});
function sendClick(){
	var mails = [];
	var firstemail = document.getElementById("firstfriendemail");
	var secondemail = document.getElementById("secondfriendemail");
	var threeemail = document.getElementById("threefriendemail");
	
	if(strLen(firstemail.value)>0){
		if(f_check_email(firstemail))mails.push(firstemail.value);
	}
	
	if(strLen(secondemail.value)>0){
		if(f_check_email(secondemail))mails.push(secondemail.value);
	}
	
	if(strLen(threeemail.value)>0){
		if(f_check_email(threeemail))mails.push(threeemail.value);
	}
	
	if(mails.length==0)return;
	

	var content = document.getElementById("insunscommend").value;
	if(content=='')return;
	var productId = document.getElementById("inproductid").value;
	
	var params = Ext.urlEncode({"mails":mails.join(","),"content":content,"productId":productId});
	Ext.Ajax.request({"url":webroot+'/product/insproductajax.htm?method=sendMail',"params":params,"method":"POST",failure:sendFail, success:sendSuccess});	
}

function sendSuccess(){
    MM_showHideLayers('commend','','hide');
	alert("邮件发送成功!");
	
}

function sendFail(){
	alert("邮件发送失败,请重试!");
}

