﻿function startmarquee(elementID,h,n,speed,delay){
	var t = null;
	var box = '#' + elementID;
	$(box).hover(function(){
		clearInterval(t);
		}, function(){
		t = setInterval(start,delay);
	}).trigger('mouseout');
	function start(){
		$(box).children('ul:first').animate({marginTop: '-='+h},speed,function(){
			$(this).css({marginTop:'0'}).find("li").slice(0,n).appendTo(this);
		})
	}
}

$(document).ready(function(){

/*------渐变按钮------*/
	$('.nav a').css('opacity', 0).hover(
	function(){
		$(this).stop().fadeTo(400, 1)
	},function(){
		$(this).stop().fadeTo(350, 0);
	});

/*------cover_tab------*/
	$(".menu a").mouseover(function(){
			$(this).addClass("current").siblings("a").removeClass("current").parent().next().children().hide();;
			$("."+$(this).attr("id")).show();
			return false;
		});
	$(".tabc>div:not(:first)").hide(); 
	
	
/*------tab click------*/
	$(".tabnt span,.picst span,.ft span").mouseover(function(){
		$(this).addClass("hovern").siblings("span").removeClass("hovern").parent().next().children().hide();
		$("."+$(this).attr("id")).show();
	});
	
/*------hot hover------*/
	$(".hots dl").mouseover(function(){
		$(this).attr("class","hover").siblings("dl").attr("class","no");
	})
	
/*------hover------*/
$(".sidernav1 a,.smenu a").hover(
  function () {
    $(this).addClass("hover");
  },
  function () {
    $(this).removeClass("hover");
  });
	
	
/*------input value------*/

$("#ikw").focus(function(){
	if(this.value == this.title)
		this.value = '';
});
$("#ikw").blur(function(){
	if(this.value == '')
		this.value = this.title;
});

/*------marquee------*/
	
	startmarquee('media_logo',48,3,1000,3000);
	
/*------随机显示media------*/
var src_arr = [
	{url:'http://mhzx.17173.com/zqtj_02.shtml',img:'images/main1007/tit_17173.jpg'},
	{url:'http://mhzx.duowan.com/gf/index.html',img:'images/main1007/tit_duowan.jpg'},
	{url:'http://games.qq.com/z/mhzx/mz.htm',img:'images/main1007/tit_qzone.jpg'},
	{url:'http://mhzx.178.com/s/minisite.html',img:'images/main1007/tit_178.jpg'}];

var ifid_arr = [{ifid:'if1',imid:'im1'},{ifid:'if2',imid:'im2'},{ifid:'if3',imid:'im3'},{ifid:'if3',imid:'im3'}]

Array.prototype.del = function(n){ if (n < 0) return this; return this.slice(0, n).concat(this.slice(n + 1, this.length)); }
	function toAr(ar,arid,nb,bak){
		var b = []; var c = 0;
		for(j = 1; j <= nb; j ++ ) { c = Math.floor(Math.random() * ar.length); b.push(ar[c]); ar = ar.del(c); }
		bak(b,arid)
	}

toAr(src_arr,ifid_arr,4,function(r,idd){
		for(j in idd){ 
		if(j>idd.length){ return false;}
		if(document.getElementById(idd[j].ifid)){document.getElementById(idd[j].ifid).src = r[j].url;}
		if(document.getElementById(idd[j].imid)){document.getElementById(idd[j].imid).src = r[j].img;}
		}
	});

function rnd(start, end){
    sj = Math.floor(Math.random() * (end - start) + start); 
}

rnd(1,6);
$('#lpic_'+sj).css('display','none');
	
});

