// JavaScript Document
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline=0;
$(document).ready(function() {
	var tags = new Array();
	tags[0] = tags0;
	tags[1] = tags1;
	tags[2] = tags2;
	loginFrmFunc(tags);
	tipsSlideUp();
});

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
function loginFrmFunc(tags) {
	$('#uname').focus(function(){
		val = $(this).val();
		if(val == tags[0]) {
			$(this).val('');
			$(this).css('color', '#000000');
		}
		$(this).css('color', '#000000');
	}).click(function(){
		val = $(this).val();
		if(val == tags[0]) {
			$(this).val('');
			$(this).css('color', '#000000');
		}
		$(this).css('color', '#000000');
	}).blur(function(){
		val = $(this).val();
		if(val == '') {
			$(this).val(tags[0]);
			$(this).css('color', '#999999');
		}
	});
	
	$('#ucode').focus(function(){
		val = $(this).val();
		if(val == tags[2]) {
			$(this).val('');
			$(this).css('color', '#000000');
		}
		$(this).css('color', '#000000');
	}).click(function(){
		val = $(this).val();
		if(val == tags[2]) {
			$(this).val('');
			$(this).css('color', '#000000');
		}
		$(this).css('color', '#000000');
	}).blur(function(){
		val = $(this).val();
		if(val == '') {
			$(this).val(tags[2]);
			$(this).css('color', '#999999');
		}
	});
	
	$('#upassword').hide();
	$('#upassword2').focus(function(){
		$(this).hide();
		$('#upassword').show().focus().css('color', '#000000');
	}).click(function(){
		$(this).hide();
		$('#upassword').show().focus().css('color', '#000000');
	});
	$('#upassword').blur(function(){
		val = $(this).val();
		if(val == '') {
			$(this).hide();
			$('#upassword2').show().css('color', '#999999');
		}
	});
}

function tipsSlideUp() {
	$("div.headline").each(function(i, n){
		if(i != 0)
			$(n).hide();
	});
	headline_count = $("div.headline").size();
   $("div.headline:eq("+current_headline+")").css('top','0px');
  
   headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
   $('#scrollup').hover(function() {
     clearInterval(headline_interval);
   }, function() {
     headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
     headline_rotate();
   });
}

function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 
   $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
     $(this).css('top','210px');
     });
   $("div.headline:eq(" + current_headline + ")").show().animate({top: 0},"slow");  
   old_headline = current_headline;
}

//首页中部信息热点、信息需求、供应
function nTabs(thisObj,Num){
	var divObj = thisObj.id;
	var dn = divObj.substr(0,4);
	for(i=1; i <4; i++) {
		if (i == Num) {
			thisObj.style.backgroundColor = "#FFFFFF";
			thisObj.style.borderBottom = "none";
   			document.getElementById(dn+"ew"+i).style.display = "block";
   			document.getElementById(dn+"ew"+i).style.height = "188px";
   			document.getElementById(dn+"ew"+i).style.width = "433px";
		} else {
			document.getElementById(dn+i).style.backgroundColor = "#eff1fe";
			document.getElementById(dn+i).style.borderBottom = "#c9c6ea 1px solid";
			document.getElementById(dn+"ew"+i).style.display = "none";
		}
	} 
}
//首页底部委托列车、资本运作站、合作伙伴
function nTabs2(thisObj,Num){
	var divObj = thisObj.id;
	var dn = divObj.substr(0,4);
	for(i=1; i <4; i++) {
		if (i == Num) {
			thisObj.style.backgroundColor = "#FFFFFF";
			thisObj.style.borderBottom = "none";
   			document.getElementById(dn+"ommission"+i).style.display = "block";
		} else {
			document.getElementById(dn+i).style.backgroundColor = "#eff1fe";
			document.getElementById(dn+i).style.borderBottom = "#c9c6ea 1px solid";
			document.getElementById(dn+"ommission"+i).style.display = "none";
		}
	} 
}
//首页右边的委托列车与合作伙伴
function nTabs3(thisObj,Num){
	var divObj = thisObj.id;
	var dn = divObj.substr(0,4);
	for(i=1; i <3; i++) {
		if (i == Num) {
			thisObj.style.backgroundColor = "#FFFFFF";
			thisObj.style.borderBottom = "none";
   			document.getElementById(dn+"eq"+i).style.display = "block";
		} else {
			document.getElementById(dn+i).style.backgroundColor = "#eff1fe";
			document.getElementById(dn+i).style.borderBottom = "#c9c6ea 1px solid";
			document.getElementById(dn+"eq"+i).style.display = "none";
		}
	} 
}
//首页左边俩个论坛
function nTabs4(thisObj,Num){
	var divObj = thisObj.id;
	var dn = divObj.substr(0,4);
	for(i=1; i <3; i++) {
		if (i == Num) {
			thisObj.style.backgroundColor = "#FFFFFF";
			thisObj.style.borderBottom = "none";
   			document.getElementById(dn+"orum"+i).style.display = "block";
		} else {
			document.getElementById(dn+i).style.backgroundColor = "#eff1fe";
			document.getElementById(dn+i).style.borderBottom = "#c9c6ea 1px solid";
			document.getElementById(dn+"orum"+i).style.display = "none";
		}
	} 
}
//信息热点图片
var t = n = count = 0;    
	$(function(){    
    count = $("#play_list a").size();    
    $("#play_list a:not(:first-child)").hide();    
    $("#play_info").html($("#play_list a:first-child").find("img").attr('alt'));    
    $("#play_text li:first-child").css({"background":"#fff",'color':'#000'});    
    $("#play_info").click(function(){window.open($("#play_list a:first-child").attr('href'), "_blank")});    
    $("#play_text li").click(function() {    
        var i = $(this).text() - 1;    
        n = i;    
        if (i >= count) return;    
        $("#play_info").html($("#play_list a").eq(i).find("img").attr('alt'));    
        $("#play_info").unbind().click(function(){window.open($("#play_list a").eq(i).attr('href'), "_blank")})    
        $("#play_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);    
        $(this).css({"background":"#fff",'color':'#000'}).siblings().css({"background":"#000",'color':'#fff'});    
    });    
    t = setInterval("showAuto()", 3000);    
    $("#play").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 3000);});    
})    
   
function showAuto()    
{    
    n = n >= (count - 1) ? 0 : n + 1;    
    $("#play_text li").eq(n).trigger('click');    
}    