// JavaScript Document
window.g = new Object();//用具记录选择的大项
window.g=1;
window.items=new Object();//用于记录被选择的小项
window.items=0;
var cids=[48,49,50];
var first_article=[43,46,53];
var cid_names=["公司介绍","服务项目","服务品牌","在线报修"];
$(document).ready(function()
{
	/////时间
  var Week = ['日','一','二','三','四','五','六'];  
  var myDate = new Date();
  var year=myDate.getFullYear();    
  var month=myDate.getMonth()+1;
  var day=myDate.getDate();        
  var xingqi=myDate.getDay();         
  var timestr=year+"年"+month+"月"+day+"日  星期"+Week[xingqi];       
  $("#datenow").html(timestr); 
  j_height();
  
  //get_cid_data(cids[0]);
  //get_article(first_article[0],1);
});

function item_mouseover(num)
{
	$("#item"+num).attr("class","c3");
	}
function item_mouseout(num)
{
	$("#item"+num).attr("class","c1");
	}
	
function mouse_over(num)
{
  var id="#v"+num;
  var onid="#v"+window.g;
  var le=-(num-1)*135;
  var le2=-(window.g-1)*135;
  $(id).css("background","url(./images1/van2.gif) "+le+"px 0px");
  $(onid).css("background","url(./images1/van2.gif) "+le2+"px 0px");
}
 
function mouse_out(num)
{
  var id="#v"+num;
  var le=-(num-1)*135;
  var onid="#v"+window.g;
  var le2=-(window.g-1)*135;
  $(id).css("background","url(./images1/van2.gif) "+le+"px -40px");//去掉
  $(onid).css("background","url(./images1/van2.gif) "+le2+"px 0px");
} 

function mouse_click(num)
{
  
   if(num<4)
   {
     if(num!=window.g)
     {
	   var onid="#v"+window.g;
	   var le2=-(window.g-1)*135;
	   $(onid).css("background","url(./images1/van2.gif) "+le2+"px -40px");
       window.g=num;
	   var onid="#v"+window.g;
	   var le2=-(window.g-1)*135;
	   $(onid).css("background","url(./images1/van2.gif) "+le2+"px 0px");
	   cid=cids[num-1];
	   $("#bigitemname").html(cid_names[num-1]);
	   $(".lanmu").html("<strong>"+cid_names[num-1]+"</strong>");
	    $(".xiangxititle").html("详细信息");
	    get_cid_data(cid);
	    get_article(first_article[num-1],num);
	    //j_height();
	   
	 
     }
   }
   else if(num==4)//在线报修
	   {
		 document.location.href="online_repair.php";
	   }
  else
	   {
		   document.location.href="guestbook_zl.php";
	    }
  
}

function get_article(aid,id)
{ 
  $("#itemname1").html($("#item"+id).text());	
  $.ajax({
		type: "get",
		url: "ajaxzhengli.php?type=small&aid="+aid+"&sid="+Math.random(),
		dataType: "html",
		beforeSend: function(XMLHttpRequest){
			$("#wen").html("");
			ShowLoading("#wenloading");
		},
		success: function(data, textStatus){
			$("#wen").html(data);
            j_height();
		},
		complete: function(XMLHttpRequest, textStatus){
			HideLoading("#wenloading");
		},
		error: function(){
			$("#wen").html("<span style='font-size:12px; color:#666666'>数据读取失败！</span>");//请求出错处
		}
});

}

function HideLoading(id)
{
  	$(id).css("display","none");
}

function ShowLoading(id)
{
	$(id).css("display","block");
}

function get_cid_data(cid)
{
	
$.ajax({
		type: "get",
		url: "ajaxzhengli.php?type=big&cid="+cid+"&sid="+Math.random(),
		dataType: "html",
		beforeSend: function(XMLHttpRequest){
			document.getElementById("itemss").innerHTML="";
			ShowLoading("#itemloadding");
		},
		success: function(data, textStatus){
			document.getElementById("itemss").innerHTML=data;

		},
		complete: function(XMLHttpRequest, textStatus){
			HideLoading("#itemloadding");
		},
		error: function(){
			$("#itemss").html("<span style='font-size:12px; color:#666666'>数据读取失败！</span>");//请求出错处理
		}
});
	
	
}

function j_height()
{
   heights=$("#wen").height();
   if(heights<425)
     heights=488;
   else
    heights=heights+120;
  //alert(heights);
   $("#neirong").height(heights);
   $("#content").height(heights);
   doc_height=heights+420;/*document.documentElement.scrollHeight;*/
   doc_height=doc_height-20;
  //alert(doc_height);
   $("#container").height(doc_height);
   $("#wen").css("visibility","visible");
}