var titlebars_hover = ['','','','','',''];
var tab_news;
var offset = 5000; //轮换时间
var timer = null;
var cur_tab_id = 0;
$(document).ready(function(){
	$('#header .drpparent').each(
		function(i){
			var $this = $(this);
			var $thisImg = $this.children('a').eq(0);
			$this.hover(
				function(){
					$thisImg.css('backgroundPosition','0px -110px'); //$this.find('.dropdown').css('display','block');
					$this.find('.dropdown').css('display','block');
				},function(){ 
					$thisImg.css('backgroundPosition','0px 0px'); //$this.find('.dropdown').css('display','none');
					$this.find('.dropdown').css('display','none');
				}
			
			); 
			 
		}
	);
	$('#tab_news').tabs({navClass:'tag_menu',selectedClass:'on',disabledClass:'disabletab',loadingClass:'tab-remote'});
		$('#tab_news').bind("mouseover", function(){isHover = true; });
		$('#tab_news').bind("mouseout", function(){isHover = false;  });
	tab_news = $('#tab_news');

	timer = window.setTimeout(autoroll, offset);
	

	if($.browser.msie6){
		ieFixed(true);
		window.onscroll=function(){
			ieFixed(false);
		}
		window.onresize=function(){
			ieFixed(true);
		}
	}
});

var isHover = false;
function autoroll(){ 
	if ( !isHover )
	{
			cur_tab_id++;
		if (cur_tab_id > 2)
		{
			cur_tab_id  = 0;
		}
		//if(tab_news)
		//	tab_news.triggerTab(cur_tab_id); 
		var lis = $('#index_news_tabs').find("li");
		lis.eq(cur_tab_id).children("a").trigger("click"); 
	} 
	timer = window.setTimeout(autoroll, offset  );
}

function tab(m){
	$('#detial_tab > h5').each(function(i){
		if(m == i+1){
			$(this).addClass('tab_down');
			$('#tab'+m).css('display','block');
		}else{
			$(this).removeClass('tab_down');
			$('#tab'+(i+1)).css('display','none');
			}
	});
}

function post_form($formId,$url,$clewDiv){
	var clewDiv = $("#"+$clewDiv);
	var thisForm = $("#"+$formId);
	clewDiv.html("提交中..");
	
	$.post($url,thisForm.serialize(),function(data){
		if(data.indexOf("error") != -1){
			clewDiv.empty();
			data = data.substr(6);
			clewDiv.html(data);
		}else{
			clewDiv.empty();
			clewDiv.html("提交成功");
			eval("var json="+data);
			
		}										  
	});
	
	return false;
}





//显示半透明黑色背景
function show_back(){
	var $body_height = document.documentElement.scrollHeight;
	$('#div_background').show();
	//$('#small_window').show();
	$('#div_background').css('height',$body_height);
	return false;
	 
}

function close_back(){
	$('#background').hide();	
}

function ieFixed(b){
	if(document.all){ 
		var $top = parseInt(document.documentElement.scrollTop);
		var $top2 = parseInt(document.documentElement.clientHeight);
		var bodyh = $('body').height(); 
		
		var s = $top2-27+$top;
		if(b)$('#footer').css('top',s);
		if(s <= bodyh ) { 
			$('#footer').css('top',s);
		} 
		$('#footer').css('position','absolute'); 
	}
}

function post_ex_form($formId,$url,$clewDiv)
{  
	try{  
		var clewDiv = $("#"+$clewDiv);
		var thisForm = $("#"+$formId);//clewDiv.html("提交中..");
		/*if( this["jqDialog"] == null) { 
			alert("提示框没有初始化");//jqDialog.init();
			return false;
		}

		if ( jqDialog )
		{	
			if ( !jqDialog.isinit )
			{
				jqDialog.init();
			}
			jqDialog.notify("提交中.."); 
		}*/
		
		
		$.post($url,thisForm.serialize(),function(data){
			if(data.indexOf("error") != -1){
				clewDiv.empty();
				data = data.substr(6);
				//if ( jqDialog )jqDialog.notify(data); 
				alert( data );
				clewDiv.html(data);
				//$("form")[0].reset();
				//$("#apply_from").reest
			}else{
				clewDiv.empty();
				  // alert("" + data);
				 
				//if ( jqDialog )jqDialog.notify("提交成功", 3);  //clewDiv.html("提交成功");
				alert( "提交的数据清除" );$("form")[0].reset();
				//alert($("form")[0]);
				//eval("var json="+data); 
			}										  
		});
	}catch(er){
		alert(er + er.message);
		
	}
	return false;
	 
}




