/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function collection(){
	try{
		window.external.addFavorite("http://www.365h.com/","好易订旅行团购网")
	}catch(b){
		try{
			window.sidebar.addPanel("好易订旅行团购网","http://www.365h.com/","")
		}catch(b){
			alert("您可以尝试通过快捷键 Ctrl+D 加入到收藏夹~")
		}
	}
	return false
}

function share(title,url){
	var html = '<dl style="padding:0 0 3px 0;" class="other_weblist">';
	html +='<dt>分享到：</dt>';
	html +='<dd class="ow_icn1 fx_list_width"><a target="_blank" href="http://v.t.qq.com/share/share.php?title='+title+'&amp;url='+url+'&amp;source=1000012&amp;site=www.365ecall.com.com&amp;pic=">腾讯微博</a></dd>';
	html +='<dd class="ow_icn2 fx_list_width"><a target="_blank" href="http://www.kaixin001.com/repaste/share.php?rtitle='+title+'&amp;rurl='+url+'">开心网</a></dd>';
	html +='<dd class="ow_icn3 fx_list_width"><a target="_blank" href="http://share.renren.com/share/buttonshare.do?link='+url+'&amp;title='+title+'">人人网</a></dd>';
	html +='<dd class="ow_icn4 fx_list_width"><a target="_blank" href="http://www.douban.com/recommend/?url='+url+'&amp;title='+title+'">豆瓣</a></dd>';
	html +='<dd class="ow_icn5 fx_list_width"><a target="_blank" href="http://v.t.sina.com.cn/share/share.php?title='+title+'&amp;url='+url+'&amp;source=bookmark&amp;appkey=2825073638">新浪微博</a></dd>';
	html +='<dd class="ow_icn6 fx_list_width"><a target="_blank" href="mailto:?subject='+title+'&amp;body='+url+'">E-mail</a></dd>';
	html +='</dl>';
	return html;
}

function g(o){
	return document.getElementById(o);
}
function HoverLi(n){
	for(var i=1;i<=2;i++){
		g('tb_'+i).className='r_out';
		g('tbc_0'+i).className='undis';
	}
	g('tbc_0'+n).className='dis';
	g('tb_'+n).className='r_over';
}

function selectCity(obj,id){
	$('.GB_citymain').hide();
	var selectCityObj = $('#'+id);
	var offset = $(obj).offset();
	var left = offset.left;
	var top = offset.top + $(obj).outerHeight();
	selectCityObj. mouseover( function(){
		$(this).show();
		return false;
	});
	selectCityObj.mouseout( function(){
		$(this).hide();
		return false;
	});
	$(obj).bind({
		foucs:function(){
			selectCityObj.show();
			return false;
		}

	});

	$('.GB_cityhot span',selectCityObj).click(function(){
		var index = $(this).index();
		$(this).parent().find('span').removeClass('hot');
		$(this).addClass('hot');
		$(this).parent().parent().find('.GB_citylist ul').hide().eq(index).show();
	});

	selectCityObj.css({
		left:left,
		top:top
	}).show();
	$('.GB_citylist .nodecity,.hote_city .nodecity',selectCityObj).bind('click',function(){
		var cityname = $.trim($(this).attr('cityname'));
		$(obj).val(cityname);
		selectCityObj.hide();
	})
}

function add_subscribe( email )
{
	if( email != '' || email != '请输入您的E-mail...' )
	{
		$.get( 'http://365h.com/member_subscribe.php', {
			'email':email
		}, function(data){
			var result = $.parseJSON(data);
			if ( result.status )
			{
				alert( '订阅成功' );
			}
			else
			{
				alert( result.message );
			}
		});
	}
	else
	{
		alert( '请输入您的邮箱' );
		return false;
	}
}
//初始化城市选择器
function initCity(){
	$( '.city' ). mouseover( function(){
		$(this).find( '.tabcity' ).show();
		$(this).find( '.GB_citymain' ).show();
		autoHeight(this);
		return false;
	});
	$( '.city' ). mouseout( function(){
		$(this).find( '.tabcity' ).hide();
		return false;
	});

	$( '#change_city' ). mouseover( function(){
		$(this).parent('.city').find( '.tabcity' ).show();
		$(this).parent('.city').find('.GB_citymain').show();
		return false;
	});
	$( '#change_city' ). mouseout( function(){
		$(this).parent('.city').find( '.tabcity' ).hide();
		return false;
	});

	$( '.city .tabcity' ). mouseover( function(){
		$('.GB_citymain',this).show();
		$( this ).show();
		return false;
	});
	$( '.city .tabcity' ). mouseout( function(){
		$('.GB_citymain',this).hide();
		$( this ).hide();
		return false;
	});


	$('.tabcity').each(function(){
		$(this).find('.GB_cityhot span').click(function(){
			var index = $(this).index();
			$(this).parent().find('span').removeClass('hot');
			$(this).addClass('hot');
			$(this).parent().parent().find('.GB_citylist ul').hide().eq(index).show();
		});

	});

};

function autoHeight(obj){
	$(obj).find('.GB_citylist ul').each(function(){
		if(parseInt($(this).height()) < 100){
			$(this).css('height',100);
		}
	});
}
