var sms_subscription_html = '<link rel="stylesheet" type="text/css" href="http://pic.house365.com/sars/css/news/sms-subscription.1.0.css?t=0"/>' +
'<div id="tlf-365-fixed">' +
    '<div class="show-warp">' +
        '<a href="javascript:void(0)" class="close-tlfFixed">关闭</a>' +
        '<iframe src="http://news.house365.com/api/newhouse/baoming.php?city=nj" scrolling="No" width="190" height="140" frameborder="0" style="margin:20px 0 0 10px;"></iframe>' +
        '<a href="http://tlf.house365.com/tfh" target="_blank" class="thfy">365特惠房源</a><a href="javascript:void(openWin(\'dingyue\',\'http://newhouse.house365.com/sms/sms_new.php?moreids=456\',true))" class="kpdy">开盘订阅</a>' +
    '</div>' +
    '<a href="javascript:void(0)" class="tlf-365-cur">点我</a>' +
    '<iframe scrolling="no" frameborder="0" class="tlf-365-iframe-background"></iframe>' +
'</div>' +
'<div id="dingyue" class="tabFrame" style="display:none;">' + 
    '<div class="title" style="padding-left:0;"><a class="titleL" href="#">开盘动态订阅</a><a class="titleR close-win" href="#" id="close_tabFrame"></a></div>' +
    '<div class="win-content"><iframe width="465" scrolling="no" height="365" frameborder="0" src="http://newhouse.house365.com/sms/sms_new.php"></iframe></div>'+
'</div>';

document.write(sms_subscription_html);

var openWin = function(obj,ajaxUrl,iframe){
	var winElemt = jQuery('#'+ obj);
	var ajaxContent = winElemt.find('.win-content')
	var $coverDom = "<div id=\"GTipsCover\" style=\"background:#000;position:absolute;filter:alpha(opacity=0);opacity:0;width:100%;left:0;top:0;z-index:1000001\"><iframe src=\"about:blank\" style=\"width=100%;height:"+jQuery(document).height()+"px;filter:alpha(opacity=0);opacity:0;scrolling=no;z-index:1000000\"></iframe></div>"
	var win = {
		height : function(){
			return winElemt.outerHeight();
		},
		width : function(){
			return winElemt.outerWidth();
		},
		show : function(){
			winElemt.css({
				'position':'absolute',
				'z-index':'1000002',
				'left':'50%',
				'margin-left':'-' + win.width() / 2 + 'px',
				'top':jQuery(window).height()/2 - (win.height()/2) + jQuery(window).scrollTop() + 'px'
			}).show();
			jQuery($coverDom).appendTo('body').css({opacity:0.2});

			if(iframe)
			{
				ajaxContent.html("<iframe src=\""+ajaxUrl+"\" width='465' height='365' frameborder=\"0\" scrolling=\"no\"></iframe>");
			}
		},
		
		hide : function(){
			winElemt.hide();
			jQuery('#GTipsCover').remove();
		}
	
	};
	
	win.show();
	
	jQuery('.close-win,#tg-tip-sub').live('click',function(){
		win.hide();
		return false;
	});
};

(function($){
	var defaults = {
		top : 0
	};
	$.fn.fixed= function(options){
		options = $.extend({},defaults,options);
		return this.each(function(){
			var self = $(this);
			var isIE6 = $.browser.msie && ($.browser.version == "6.0") && !$.support.style;
			if(isIE6)
			{
				self.css({'position':'absolute','top':options.top+'px'})
				$(window).scroll(function(){
					self.css({
						'top' : $(window).scrollTop() + options.top + 'px'
					})
				})
			}
			else
			{
				self.css({'position':'fixed','top':options.top+'px'})
			}
		});
	}
})(jQuery);

jQuery(function(){
	jQuery('#tlf-365-fixed').fixed({'top':200});
	var oTlf365Fix = {
		shrink : function(){
			jQuery('#tlf-365-fixed').animate({
				'right':'-225px'
			})
		},
		spread : function(){
			jQuery('#tlf-365-fixed').animate({
				'right':'0'
			})
		}
	};
	jQuery('.tlf-365-cur').click(function(){
		oTlf365Fix.spread();
	});
	
	jQuery('.close-tlfFixed').click(function(){
		oTlf365Fix.shrink();
	})
})

jQuery('#close_tabFrame').click(function(){
    jQuery('#dingyue').hide();
});

jQuery('#sms_subscription_form').submit(function(){
    //必填项验证
    var requireds = jQuery(this).find('.required');
    var len = requireds.length;
    var cansub = true;
    for(var i=0; i<len; i++){
        if( jQuery(requireds[i]).val()=='' || jQuery(requireds[i]).val()==0 ){
            cansub = false;
            jQuery(requireds[i]).css('border','1px solid Red');
        }else{
            jQuery(requireds[i]).css('border','');
        }
    }
    
    
    var phones = jQuery(this).find('.phone');
    len = phones.length;
    for (i=0; i<len; i++){
        var prg = /^1[0-9]{10}$/i;
        if( prg.test( jQuery(phones[i]).val() )==false ){
            cansub = false;
            jQuery(phones[i]).css('border','1px solid Red');
        }else{
            jQuery(phones[i]).css('border','');
        }
    }
    
    return cansub;
});