// JavaScript Document

function requestAjax(requestUrl)
{
	new Request({
		url: 'requestAjax.php?'+requestUrl,
		method: 'post',
//		async: false,
		data: {},
		onSuccess: function(response) {
			//alert('Received the following response:  ' + response);
			response = response.replace(/(^\s*)|(\s*$)/g, "");
			$('content').innerHTML =response;
			if(requestUrl == "subPage=exchange"||requestUrl == "subPage=en_exchange")
			{
				showjiaoliu();
				w(1)
			}
			if(requestUrl == "subPage=honor"||requestUrl == "subPage=en_honor")
			{
				showhonor();
				w(1)
			}

		}
	}).send();
}

function showjiaoliu()
{
	var so = new SWFObject('flash/jiaoliu.swf', 'exchange', '600', '350', '10.0', '#000000');
	so.addParam("wmode", "transparent");
	so.write("exchange");
}

function showhonor()
{
	var so = new SWFObject('flash/rongyu1.swf', 'honor', '600', '350', '10.0', '#000000');
	so.addParam("wmode", "transparent");
	so.write("honor");
}

function setClass(id)
{
	var obj = $(id);
	obj.getParent().getParent().getElements('a').each(function(a){a.className = "bluefont"});
	obj.className = "jv1 bluefont";
	if($('location') != null && $('location') != "")
	{
		$('location').set("text",obj.get("text"));
	}
}

function changeHonor(url,n)
{
	w(n);
	$('honor').empty();
	var str = "flash/"+url+".swf";
	var so = new SWFObject(str, 'honor', '600', '350', '10.0', '#000000');
	so.addParam("wmode", "transparent");
	so.write("honor");
	
}

function changeExchange(url,n)
{
	w(n)
	$('exchange').empty();
	var str = "flash/"+url+".swf";
	var so = new SWFObject(str, 'exchange', '600', '350', '10.0', '#000000');
	so.addParam("wmode", "transparent");
	so.write("exchange");
	
}

function w(n)
{
	var as = $('splitPages').getElements('a');
	if(n==1){
		as[0].setStyle('display', 'none');
	} else {
		as[0].setStyle('display', 'inline');
		as[0].set('href', as[n-1].get('href'));
	}
	
	if(n==as.length-2){
		as[as.length-1].setStyle('display', 'none');
	} else {
		as[as.length-1].setStyle('display', 'inline');
		as[as.length-1].set('href', as[n+1].get('href'));
	}
	
	x(n);
}

function x(n)
{
	var as = $('splitPages').getElements('a');
	for(var i=0; i<as.length; i++)
	{
		as[i].set("class","");
	}
	as[n].set("class","red");
}

function f(){
	var height = $('newsTitle').getElements('div')[0].getStyle('height');
	var bo = count*height.toInt()/100;
	
	$('newsTitle').getElements('div')[0].setStyle('bottom', bo+'px');
	$('newsTitle').getElements('div')[1].setStyle('bottom', bo+'px');
	
	if(count >= 100)
	{
		count=0;
		$('newsTitle').grab($('newsTitle').getElements('div')[0], 'bottom');

	}
	else{count++;}
	
	setTimeout(f, 100);
}


window.addEvent('domready', function(){
	$('children').getElement('span').addEvent('click', function(){
		var target = this.getParent().getElement('p');
		if(target.getStyle('display') == "none")
		{
			target.setStyle('display', 'block');
			$('tubiao').set('class','an2');
		}
		else
		{
			target.setStyle('display', 'none');
			$('tubiao').set('class','tubiao');
		}
	});
	
	if($('leftNav') != null && $('leftNav') != "")
	{
		$('leftNav').getElements('a').each(function(name, index){
			name.addEvent('click', function(){
				this.getParent().getParent().getElements('a').each(function(a){a.className = "bluefont"});
				this.className = "jv1 bluefont";
				if($('location') != null && $('location') != "")
				{
					$('location').set("text",this.get("text"));
				}
			});
		});
	}
	
	if($('midLink') != null && $('midLink') != "")
	{
		$('midLink').getElements('a').each(function(name, index){
			name.addEvent('mouseover', function(){
				this.getParent().getPrevious('li').getElement('img').src = "images/tubiao3.jpg";
			});
			name.addEvent('mouseout', function(){
				this.getParent().getPrevious('li').getElement('img').src = "images/tubiao4.jpg";
			});
		});
	}
	
	if($('navId') != null && $('navId') != "")
	{
		var value = $('navId').value;
		var arr = $('navigation').getElements('a');
		arr[value].getParent().className = "zi_di";
		if(value != 0)
		{
			arr[0].getParent().className = "zi_di_2";
		}
	}
	
	if($('newsTitle') != null)
	{
		count = 3;
		f();
		//alert($('newsTitle').getElements('div')[0].getStyle('height'));
	}
});
