﻿//请修改以下参数
//var Invite_ToRight=0;//说明：浮动图标的水平方向对齐方式，1为右对齐，0为左对齐；
//var Invite_left=400;//说明：浮动图标的水平方向的边距；
//var Invite_ToBottom=0;//说明：浮动图标的垂直方向对齐方式，1为底部对齐，0为顶部对齐；
//var Invite_top=187;//说明：浮动图标的垂直方向的边距；

var LiveAutoInvite0='您好，来自的朋友';
var LiveAutoInvite1='来自首页的对话';
var LiveAutoInvite2='<P><FONT style=\\"FONT-SIZE: 9pt\\"><FONT color=#ff0080>您好,欢迎访问华美紫馨官方网站</font><BR>';
LiveAutoInvite2 += '<FONT style=\\"FONT-SIZE: 9pt\\" color=#0080ff>华美紫馨12年来成功手术60000余例，拥有8年资历以上咨询顾问和10年资历以上主刀经验的主诊医师为您服务。</font>  <FONT style=\\"FONT-SIZE: 9pt\\"><BR><B>如果您有任何问题请<FONT color=red>接受</FONT>邀请开始沟通</B></FONT></p>';
LiveAutoInvite2+='</p>';
var LR_next_invite_seconds = 20;
var LrinviteTimeout=20;
var fixedHTML='<div id="fixedbox-bg"></div><div id="fixedbox-content"><div id="fixedbox-top"><a id="fixedbox-ask" href="http://hmzixin.zoossoft.com/LR/Chatpre.aspx?id=LEW99813501" target="_blank"><img src="http://www.hmzixin.com/tip/images/fixedbox_ask.gif" alt="" /></a><div id="fixedbox-weather"><iframe src="http://m.weather.com.cn/m/pn4/weather.htm?id=101270101T" width="160" height="20" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe></div><span id="fixedbox-close"></span></div><div id="fixedbox-gb"><div id="fixedbox-form"><p id="fixedbox-ly-box"><textarea name="" id="fixedbox-ly"></textarea></p><p id="fixedbox-tel-box"><input type="text" name="" id="fixedbox-tel" /><button id="fixedbox-send">发送</button></p></div><span id="fixedbox-gb-tips"></span></div><div id="fixedbox-list"><h3>推荐资讯</h3> <ul><li><a href="http://www.hmzixin.com/AboutHtml/2011/Huamei_Zixin_ItemNews3477.html" target="_blank">华美新春超值礼献</a></li><li><a target="_blank" href="http://www.hmzixin.com/Special/2011/xiaohua4/">美丽模范校花</a></li><li><a target="_blank" href="http://www.hmzixin.com/Special/2011/show/">爱美丽,秀自己</a></li><li><a target="_blank" href="http://www.hmzixin.com/Special/2011/TD-Skin/">华美美肤层革命</a></li></ul>   <a target="_blank" id="fixedbox-more" href="http://www.hmzixin.com/AboutHtml/2011/">更多</a></div></div>'


var freeHTML='<form name="f" action="http://tel.hoocoo.net:88/calld.php" target="freeteliframe"><input class="freetel-tel" type="text" name="tel" maxlength="13" /><input class="freetel-chkcode" type="text" name="authnum" maxlength="4" /><img class="freetel-chkcode-pic" src="http://tel.hoocoo.net:88/validate.php?act=init&id=1" alt="" /><input class="freetel-submit" type="submit" value="" /><input type="hidden" name="fromurl" id="call_fromurl" value="" /><input type="hidden" name="sid" value="2010071020" /><input type="hidden" name="did" value="562" /></form><iframe name="freeteliframe" id="freeteliframe" frameborder="0" width="0" height="0" scrolling="0" src=""></iframe><p class="freetel-close"><a href="http://www.hmzixin.com/script/zoossoft/zixun.html" target="_blank">在线咨询</a> | <a id="closefreetel" href="javascript:;" target="_self">关闭</a> <div style="width:110px;height:140px;position:relative;float:left;margin-top:10px;text-align:center;display:none;"><a href="http://ecardbox.mindpro.cn" target="_blank"><img src="http://www.hmzixin.com/img/phone_download.gif" alt="华美紫馨 手机客户端下载" /></a></div>'
document.writeln("<script language=\"javascript\" src=\"http://hmzixin.zoossoft.com/JS/LsJS.aspx?siteid=LEW99813501\"></script>");
document.writeln("<link href='http://www.hmzixin.com/script/zoossoft/kstcommon.css' rel='stylesheet' type='text/css' />");


//关闭广告
function closeAd(id,closeId)
{  
$("#"+id).bind("click",function(){
$("#"+closeId).animate({height:0},1000)})
}
//$(function(){closeAd("sidefloatadbtn","sidefloatad")})

//查找要做的项目
function ValNull(obj)
{
    switch(obj.value)
    {
        case "查找想做的项目":
        obj.value="";
        break;
        
        case "输入问题":
        obj.value="";
        break;
        
        case "把您想咨询的问题写在这":
        obj.value="";
        break;    
        
        case "请输入正确的验证码":
        obj.value="";
        break;     
    }
}
function SubBut()
{
	if(window.document.Form1.Val.value=="查找想做的项目" || window.document.Form1.Val.value=="")
	{
		alert("请输入要查询的项目名!");
		ValNull(window.document.Form1.Val);
		window.document.Form1.Val.focus();
	}else
	{
	    location.href = "http://www.hmzixin.com/Search.aspx?p=1&pno=1&q=" + escape(window.document.Form1.Val.value);
	}
}
function testKey(event)
{
    if(event.keyCode==13){
        SubBut();
        return false;
    }
}

//$(document).ready(function() {
//    $("#footer").after("<div id='alertglow' style=\"position:absolute\"></div>");
//    $('#alertglow').load('/glow.html');
//    if (/MSIE 6.0/ig.test(navigator.appVersion)) {
//        $("meta").after('<link href=\"http://www.hmzixin.com/styles/ie-stuff.css\" rel=\"stylesheet\" type=\"text/css\" />');
//    }
//})



     //右下角信息
    //jQuery('body').append('<div id="fixedbox"></div>');
    //jQuery('#fixedbox').html(fixedHTML)


	jQuery('body').append('<div id="freetel"></div>');
	jQuery('#freetel').html(freeHTML)
	jQuery('#sidefloatad').hide()
    //jQuery('#freetel').append('<p><a href='http://www.hmzixin.com/script/zoossoft/zixun.html" target="_blank"><img src="http://www.hmzixin.com/img/notice.jpg" /></a></p>')




<!-- WPA Button Begin -->
document.writeln("<script type='text/javascript' src='http://static.b.qq.com/account/bizqq/js/wpa.js?type=10&kfuin=800000708&ws=http%3A%2F%2Fwww.hmzixin.com&title=%E5%9C%A8%E7%BA%BF%E4%B8%93%E5%AE%B6&btn1=%E7%82%B9%E5%87%BB%E5%92%A8%E8%AF%A2%E4%B8%93%E5%AE%B6&fsty=0&fposX=2&fposY=1&csty=1&tx=4'></script>")
<!-- WPA Button END -->


// JavaScript Document

$(function() {
        //初始化变量
        var timer = 50;
        var purl = 'http://www.hmzixin.com/Alertpreengage.ashx';
        var fixedbox = $('#fixedbox');
        var close = $('#fixedbox-close');
        var theClose = function() {
            fixedbox.animate({ height: '40px' });
            close.css('backgroundPosition', 'bottom');
        }
        var theOpen = function() {
            fixedbox.animate({ height: '181px' });
            close.css('backgroundPosition', 'top');
        }
        $('#fixedbox-close').toggle(theClose, theOpen);
        setTimeout(theOpen, timer);
        var ly = $('#fixedbox-ly');
        var tel = $('#fixedbox-tel');
        var send = $('#fixedbox-send');
        var defaultLy = '欢迎留言\n咨询热线：028-62988888';
        var defaultTel = '您的手机号码';
        var tip = $('#fixedbox-gb-tips');
        var frm = $('#fixedbox-form');
        var timerHideTip, sending = false;
        //textarea得到(失去)焦点时
        ly.val(defaultLy);
        ly.focus(function() {
            var val = $.trim($(this).val());
            if (val == defaultLy) {
                ly.val('');
            }
        });
        ly.blur(function() {
            var val = $.trim($(this).val());
            if (val == '') {
                ly.val(defaultLy);
            }
        });
        //input得到(失去)焦点时
        tel.val(defaultTel);
        tel.focus(function() {
            var val = $.trim($(this).val());
            if (val == defaultTel) {
                tel.val('');
            }
        });
        tel.blur(function() {
            var val = $.trim($(this).val());
            if (val == '') {
                tel.val(defaultTel);
            }
        });
        //错误提示
        var theTipShow = function(str) {
            clearTimeout(timerHideTip);
            tip.html(str || '').animate({ height: '20px' }, 150);
            if (!sending) {
                timerHideTip = setTimeout(theTipHide, 3000);
            }
            sending = false;
        };
        var theTipHide = function(str) {
            tip.html('').animate({ height: '0px' }, 150);
        }
        //重复留言检查
        var lyCount = [];
        //发送留言按钮事件
        send.click(function() {
            if (sending) { return false; }
            var lyVal = $.trim(ly.val());
            var telVal = $.trim(tel.val());
            var isSended = false;
            $.each(lyCount, function(i) {
                if (lyVal == lyCount[i]) { isSended = true; }
                else { isSended = false; }
            });
            if (isSended) { theTipShow('请勿提交相同的留言'); return false; }
            if (lyVal == '' || lyVal == defaultLy) {
                theTipShow('请输入留言内容');
                return false;
            }
            if (telVal == '' || telVal == defaultTel) {
                theTipShow('请输入手机号码');
                return false;
            } else if (telVal.length != 11) {
                theTipShow('手机号码位数错误');
                return false
            } else {
                if (!/^1[3,5,8][0-9]\d{8}$/.test(telVal)) {
                    theTipShow('请输入正确的手机号码');
                    return false;
                }
            }
            sending = true;
            theTipShow('正在发送留言……');
            $.ajax({
                type: 'POST',
                url:purl,
                data: 'content=' + lyVal + '&tel=' + telVal,
                success: function(data) {
                    if (data == 1) {
                        theTipShow('<span style="color:#360;">留言成功 </span>');
                        lyCount.push(lyVal);
                    } else {
                    theTipShow('留言失败，请重试！');
                    }
                }
            });
            return false;
        }).hover(function() {
            $(this).css('font-weight', 'bold');
        }, function() {
            $(this).css('font-weight', 'normal');
        });

        tel.keydown(function(event) {
            if (event.keyCode == 13) {
                send.click();
            }
        });

    });






	$(function(){
		var box = $('#freetel');
		var speed = 300;
		var tp = 100;
		var hmw = 1003;//网页宽度
		var boxw = box.width()+5;//加点留白
		var boxh = box.height();
		var win = $(window);
		var bd = $('body');
		var moveTimer;
		var setposition = function(){
			if(box.is(':hidden')){return;}		
			var winw = win.width();		
			var t = $(window).scrollTop();
			var winh = win.height();
			//当窗口高度过小时，改变tp值
			if(boxh >= winh){
				tp = winh - boxh;//负的top值
			}else{
				if((tp+boxh) >= winh){
					tp = winh - boxh;
				}
			}			
			if(winw >= (2*boxw + hmw)){
				box.animate({left:((winw-(hmw+2*boxw))/2) + 'px' , top:(t+tp)+'px'},speed);
			}else{
				box.animate({left:0 , top:(t+tp)+'px'},speed);
			}		
		};
		win.scroll(function(){
			clearTimeout(moveTimer);
			moveTimer = setTimeout(setposition,80);
		});
		win.resize(function(){
			clearTimeout(moveTimer);
			moveTimer = setTimeout(setposition,80);
		});
		setposition();
	});
	
	
	
	
	$(function(){
		document.getElementById("call_fromurl").value=window.location.href;
		var tel = $('.freetel-tel');
		var telDef = '请输入电话号码';
		tel.focus(function() {
	        var val = $.trim($(this).val());
	        if (val == telDef) {
	            tel.val('');
	        }
	    });
	    tel.blur(function() {
	        var val = $.trim($(this).val());
	        if (val == '') {
	            tel.val(telDef);
	        }
	    });
		tel.val(telDef);
		
		
		var chk = $('.freetel-chkcode');
		var chkDef = '验证码';
		 chk.focus(function() {
	        var val = $.trim($(this).val());
	        if (val == chkDef) {
	             chk.val('');
	        }
	    });
	     chk.blur(function() {
	        var val = $.trim($(this).val());
	        if (val == '') {
	            chk.val(chkDef);
	        }
	    });
		chk.val(chkDef);
		$('#freetel form').submit(function(){
			var v1 = tel.val();
			var v2 = chk.val();
			if(v1 == '' || v1 == telDef){
				alert('请填写电话号码');
				tel.focus();
				return false;
			}
			if(!/^\d+$/.test(v1)){
				alert('电话号码只能是数字');
				tel.focus();
				return false;
			}
			if(v2 == '' || v2 == chkDef){
				alert('请填写验证码');
				chk.focus();
				return false;
			}
			if(!/^\d{4}$/.test(v2)){
				alert('验证码为4位数字');
				chk.focus();
				return false;
			}
		});
		$('#closefreetel').click(function(){
			$('#freetel').hide('fast');
		});
	})

