function Marquee()
{
	preTop = document.getElementById('tmp1').scrollTop;
	document.getElementById('tmp1').scrollTop++;
	if (preTop == document.getElementById('tmp1').scrollTop)
	{
		document.getElementById('tmp1').scrollTop = document.getElementById('tmp2').offsetHeight - $('#tmp1').height() + 1;
		//document.getElementById('tmp1').scrollTop++;
	}	
}
function showSHExpo()
{
	var now = new Date();
	var expoDate = (new Date(2010, 4, 1)).getTime();
	if (now > expoDate) return false;
	$('#sh-shibo').html('距离上海世博会还有 <font style="color:#ff5a00;font-family:Georgia;">'+ Math.floor((expoDate - now) / 86400000 + 1) +'</font> 天 ');
}
$(document).ready
(
	function()
	{
		showSHExpo();
		var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="358" height="218">' +
				'<param name="movie" value="/skin/bcastr.swf?bcastr_xml_url=/uploadfile/xml/bcastr.xml" />' +
				'<param name="quality" value="high" />' +
				'<param name="menu" value="false" />' +
				'<param name="wmode" value="transparent" />' +
				'<embed src="/skin/bcastr.swf?bcastr_xml_url=/uploadfile/xml/bcastr.xml" type="application/x-shockwave-flash" menu="false" wmode="transparent" width="358" height="218"></embed>' +
				'</object>';
		$('#ppt').html(html);
		html = '<li class="tel">021-51877018</li>' +
					'<li class="qq"><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=802bbce38e768109658c1a1029cc730105e9a412e1857ae22d9e3d7a54543513" target="_blank" onclick="var tempSrc=\'http://sighttp.qq.com/wpa.js?rantime=\'+Math.random()+\'&sigkey=802bbce38e768109658c1a1029cc730105e9a412e1857ae22d9e3d7a54543513\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;">1056225808</a></li>' +
					'<li class="msn"><a href="msnim:chat?contact=fair20845@hotmail.com" target="_blank">fair20845#hotmail.com</a></li>' +
					'<li class="ww"><a href="http://amos1.taobao.com/msg.ww?v=2&uid=%E7%99%BD%E5%85%B0%E4%B8%BD%E4%BA%BA&s=2" target="_blank">白兰丽人</a></li>';
		$('#service-info').html(html);
		
		$('<p id="tmp2"></p>').appendTo( $('#site-note') );
		while ( document.getElementById('tmp2').offsetHeight < $('#tmp1').height() )
		{
			document.getElementById('tmp2').innerHTML += $('#tmp1').html();
		}
		document.getElementById('tmp1').innerHTML = document.getElementById('tmp2').innerHTML +'<br />'+ document.getElementById('tmp2').innerHTML;
		document.getElementById('tmp1').scrollTop = 1;
		var preTop = 0;
		window.setInterval(Marquee, 100);

		$('#ui-tab a').mouseover
		(
			function()
			{
				if ($(this).parent().hasClass('current')) return;
				$('#ui-tab li').removeClass('current');
				$('.ui-tab-panel').children().hide();
				$(this).parent().addClass('current');
				$('#'+ $(this).attr('rel')).fadeIn('slow');
			}
		);
		$('#enroll-form').submit
		(
			function()
			{
				var str_error = '';
				if ($.trim($('input[name=username]', this).val()) == '') str_error += '<li>请留下您的姓名</li>';
				if ($.trim($('input[name=idcard]', this).val()) == '') str_error += '<li>请留下您的身份证号，以便进行前期准备工作</li>';
				if ($.trim($('input[name=tel]', this).val()) == '') str_error += '<li>请留下您的联系电话</li>';
				if ($.trim($('input[name=tel]').val()) != '')
				{
					if ( !check_tel( $.trim($('input[name=tel]').val()) ) && !check_mobile( $.trim($('input[name=tel]').val()) ) ) str_error += '<li>请输入正确的电话或手机</li>';
				}
				if ($.trim($('input[name=mail]').val()) != '')
				{
					if ( !check_tel( $.trim($('input[name=mail]').val()) ) && !check_mobile( $.trim($('input[name=mail]').val()) ) ) str_error += '<li>请输入正确邮件地址</li>';
				}
				if (str_error != '')
				{
					if ($(this).prev('div.error-info').length == 0)
					{
						$(this).before( '<div class="error-info"><ul id="error-info">'+ str_error +'<\/ul><\/div>' );
					}
					else
					{
						$('ul#error-info').html( str_error );
					}
					return false;
				}
			}
		);
	}
);
function addFavorite(url, title)
{
	if(window.ActiveXObject)
	{
		window.external.addFavorite(url, title);
	}
	else
	{
		window.sidebar.addPanel(title, url, '');
	}
}
function setHomePage(url)
{
	if (window.ActiveXObject)
	{
		document.links[0].style.behavior = 'url(#default#homepage)';
		document.links[0].setHomePage(url);
	}
	else
	{
		window.alert('请使用 工具->选项 添加当前页为您的首页，谢谢！');
	}
}
function check_mail(str_mail)
{
	return /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int)$/.test(str_mail);
}
function check_tel(str_tel, is_fax)
{
	return (is_fax ? /^(\d{3,4}-)?\d{7,8}$/ : /^(\d{3,4}-)?\d{7,8}(-\d+)?$/).test(str_tel);
}
function check_mobile(str_mobile)
{
	return /^(0)?1[35]\d{9}$/.test(str_mobile);
}