if(typeof(loadingbar)=='undefined'){
var loadingbar=function(){
this.show=function(msg){
if(typeof(msg)=='undefined'){msg='loading...';}
var $loadingbar=$('#loadingbar_______1');
if($loadingbar.length==0){
$(document.body).append('');
$loadingbar=$('#loadingbar_______1');
if($.browser.msie && $.browser.version=='6.0'){
$loadingbar.css({'position':'absolute'});
$(window).bind('scroll',setSize);
}
$(window).bind('resize',setSize);
}
setSize();
$loadingbar.html(msg).show();
}
this.hide=function(){
$('#loadingbar_______1').hide();
}
var setSize=function(){
setresize($('#loadingbar_______1'),200,50);
}
}
}
$.loadingbar=new loadingbar();
if(typeof(setresize)=='undefined'){
var setresize=function($obj,w,h){
$window = $(window);
var windowHeight = $window.height();
var left = ($window.width() - w) / 2;
var top =(windowHeight - h) / 2 ;
if($.browser.msie && $.browser.version=='6.0'){
top=top+parseInt($window.scrollTop(), 10);
}
if (top < 0) { top = 0; }
setTimeout(function () {
$obj.css({
left: left + 'px',
top: top + 'px'
});
}, 0);
}
}
var corssajax=function(url,data,callback,timeoutcallback){
var timeout=true
var corssajaxcallback='corssajaxcallback__'+new Date().getTime();
if(url.indexOf('jsoncallback=?')>-1){
url=url.replace('jsoncallback=?','jsoncallback='+corssajaxcallback);
}else{
if(url.indexOf('?')>-1){
url+="&";
}else{
url+="?";
}
url+="jsoncallback="+corssajaxcallback;
}
window[corssajaxcallback]=function(json){
if(timeout==true){
timeout=false;
callback(json);
timeout=true;
}
}
var corssform=$('#corssform__');
if(corssform.length==0){
$(document.body).append('');
corssform=$('#corssform__');
}
else
{
corssform.attr('action',url);
}
var html='';
html+=''
for(var o in data){
html+='';
}
corssform.html(html);
corssform.submit();
if(timeoutcallback){
setTimeout(function(){
if(timeout){
timeoutcallback();
}
},5000);
}
}
var buyask = function (type, host, id, cid) {
var buyaskhtml = '';
this.id = id;
this.cid = cid;
this.host = host || '';
this.tjhost = 'http://tj.bmlink.com';
this.type == type || 0;
var $this = this;
this.setType = function (type) {
$this.type == type || 0;
}
var setSize = function () {
var $window = $(window);
var bodyHeight = $(document.body).outerHeight(true);
var windowHeight = $window.height();
var height = bodyHeight > windowHeight ? bodyHeight : windowHeight;
setresize($this.child, 630, 350);
$this.con.css({ height: height + 'px' });
}
this.init = function () {
$(document.body).append('');
$this.con = $('#buyaskdiv');
$(document.body).append(buyaskhtml);
$this.child = $('#buylogonalready');
$this.child.css({ position: 'fixed','font-size':'12px', border: '1px solid #ccc', margin: '0px', 'padding': 0, 'z-index': 1001, width: '630px', height: '350px', 'background-color': '#fff' });
$this.child.find('.title').css({'height':'29px','line-height':'29px','background':'url(//meta.bmlink.com/2012/images/bg_title.gif) repeat-x scroll 0 0 transparent'});
$this.child.find('.title>strong').css({'float':'left','margin':'0 0 0 10px'});
$this.child.find('.title>p').css({'float':'right','margin':'0 10px 0 0'});
$this.child.find('.title img').css({'vertical-align':'middle','margin-left':'5px','border':'0'});
$this.child.find('.regline').css({'padding-bottom':'2px',color:'#333','display':'block','overflow':'hidden','width':'100%'}).find(':text').css({padding:'0'});
$this.child.find('.lef').css({'text-align':'right','width': '100px','float':'left','line-height':'28px','padding':'0 5px'});
$this.child.find('.mid').css({'display':'inline-block','float':'left','line-height':'28px','padding':'0 5px'});
$this.child.find(':text').css({border:'1px solid #ccc','color':'#666',width:'230px','padding':'3px 5px','line-height':'14px'});
$this.child.find('textarea').css({'font-size':'12px','height':'200px','width':'450px','border':'1px solid #ccc','line-height':'18px','padding':'5px 0'});
$this.child.find('.submit').css({'margin-left':'115px','line-height':'32px',width:'500px'});
$this.child.find('.submit>button').css({'background':'url(//meta.bmlink.com/2012/images/reglogin/bg_red.gif) repeat-x scroll 0 0 transparent','border': '1px solid #024ECA','color': '#FFFFFF','cursor': 'pointer','font-size': '14px','font-weight': 'bold','height': '32px','margin-right': '10px','width':' 160px'});
$this.child.find('.submit>button.bg_gbutton').css({'background': 'url("../images/trade/bg_btngray.gif") repeat-x scroll 0 0 transparent','border': '1px solid #CCCCCC','color': '#333333'});
$this.child.find('a').css({color:'#095CB4','text-decoration':'none'});
$this.child.find('.red').css({'color':'#f00'});
$(window).bind('resize', setSize);
if ($.browser.msie && $.browser.version == '6.0') {
$this.child.css({ position: 'absolute' });
$(window).bind('scroll', setSize);
}
$this.child.find('.close,.submit>button.bg_gbutton').click(function () {
$this.close();
});
$this.child.find('.senbuyask').click(function () {
if ($this.id == 0) {
alert('参数错误'); return;
}
var title = $.trim($this.child.find('#title').val());
var content = $.trim($this.child.find('#content').val());
if (title.length == '') {
alert('请填写产品名称'); return;
}
if (content.length == 0) {
alert('请填写产品介绍信息'); return;
}
if (content.length > 1000) {
alert('产品介绍字数不能超过1000'); return;
}
data={
id:$this.id,
cid:$this.cid,
title:title,
content:content,
type:0
};
$.loadingbar.show();
corssajax($this.host + '/ashx/pub.ashx?method=savebuyask',data,function(json){
$.loadingbar.hide();
if(json.error){
alert(json.msg);
}else{
alert('发送报价信息成功');
$.ajax({
url: $this.tjhost + '/pub.ashx?method=addtradestat&jsoncallback=?',
dataType:'jsonp',
type:'GET',
data: { ids: $this.id + '|' + $this.cid, t: $this.type == 0 ? 1 : 3, st: 2 },
success:function(){}
});
$this.close();
}
});
});
}
this.init();
this.hadcheckedcontact=false;
this.hadcheckedcontactpass=0;
this.show = function () {
if(!this.hadcheckedcontact){
corssajax($this.host + '/ashx/pub.ashx?method=checkedcontact',{ type: 0 },function(json){
$this.hadcheckedcontact=true;
if(json==null)
{
$this.hadcheckedcontactpass=200;
}
else
{
$this.hadcheckedcontactpass=json.msg;
}
$this.checkedcontactresult();
});
}
else
{
this.checkedcontactresult();
}
}
this.checkedcontactresult=function()
{
if(this.hadcheckedcontactpass=="0")
{
alert('请先登录再报价!');
return;
}
else if(this.hadcheckedcontactpass=="1")
{
alert('您必须完善您账户联系信息后才能报价!');
return;
}
else if(this.hadcheckedcontactpass=="2")
{
alert('您必须完善您的公司资料后才能报价!');
return;
}
else if(this.hadcheckedcontactpass=="3")
{
alert('您必须完善您的账户联系信息和公司资料后才能报价!');
return;
}
else if(this.hadcheckedcontactpass=="4")
{
alert('对不起,只有付费会员才能进行报价!');
return;
}
$this.con.show();
$this.child.show();
setSize();
}
this.close = function () {
$this.con.hide();
$this.child.hide();
}
}
$.buyask=new buyask(0,'//member.bmlink.com',4079230,838515);