//jquery taconite ajax
function hook_taconite_result(){
    $("a.jq_a_ajax").livequery(function(){
	    $(this).unbind()
		    .bind('click', function(){
			    var url = getUrl(this.href);
		        var hash = this.hash && this.hash.substr(1);
			    if (hash != ""){
			        eval(hash + '.call(this);');
			    }else{
				    $.get(url);
				}
				return false;
			});			
	});	
}

//get url from  href
function getUrl(href){
    var i = href.indexOf("#");
	return (i != -1) ? href.substring(0, i) : href;
}

//ajax loading status
function hook_loading_progress(){
    $("#ajax_request_progress").livequery(function(){
	    $(this).unbind()
		    .ajaxStart(function(){
			    $(this).show();
			})
			.ajaxComplete(function(){
			    $(this).hide();
			});
	});
}

function hook_history_back(){
	$('input[@name=_back]').bind('click',function(){
		window.location.href = history.back();
	});
}

function hook_go_page(){
	$('#go_page').bind('click', function(){
		var page = $('#inpt_page').val();
		var url_prefix = $('#url_prefix').attr('href');
		if(page > 0){
			window.location.href = url_prefix+'/page/'+page;
		}
	});
}

// 手机号码验证   
jQuery.validator.addMethod("mobile", function(value, element){   
	var length = value.length;
	return this.optional(element) || (length == 11 && /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/.test(value));   
}, "请正确填写您的手机号码");

function scrollTips(){
	var handler, sTop ;
	
	var pos = $('.chinarax').position();
	
	$('<div id="copychina"></div>')
		.prependTo('body')
		.append($('.chinarax').clone())
		.css('left', pos.left+178);
		
	$(window).bind('scroll',function(){
		window.clearTimeout(handler);
		handler = window.setTimeout(function(){
			sTop = $(document).scrollTop();
			if(sTop > 274){
				$("#copychina").css('top',sTop+31).show();
			}else{
				$("#copychina").css('top',0).hide();
			}
	    },10);
	});
	
}

function playswf(sFile,sWidth,sHeight){
	 document.write('<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="'+ sWidth +'" height="'+ sHeight +'">  ');
	 document.write(' <param name="movie" value="'+ sFile +'">  ');
	 document.write(' <param name="quality" value="high">  ');
	 document.write(' <param name="wmode" value="transparent">  ');
	 document.write(' <embed src="'+ sFile +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="'+ sWidth +'" height="'+ sHeight +'"></embed>  ');
	 document.write('</object> ');
}
function closer(){
	document.getElementById("TipsLeft").style.display="none"
}
//onload bind
$(function(){
	hook_taconite_result();
	hook_loading_progress();
	
	hook_history_back();
	
	hook_go_page();
	
	scrollTips();
	
	
	$('a.js_hover_on').hover(function(){
		var src = $(this).children('img').eq(0).attr('src');
		var rel = $(this).attr('rel');
		
		$(this).children('img').eq(0).attr({'src':rel});
		$(this).attr({'rel':src});
	},function(){
		var src = $(this).children('img').eq(0).attr('src');
		var rel = $(this).attr('rel');
		
		$(this).children('img').eq(0).attr({'src':rel});
		$(this).attr({'rel':src});
	});
	
});
