jQuery.fn.extend({
	css3:function(s,c,fn){
		$(this).addClass('css3').css(s).css({WebkitBorderRadius:c[0],MozBorderRadiu:c[0],borderRadius:c[0],WebkitBoxShadow:c[1],WebkitBoxShadow:c[1],boxShadow:c[1]});
		//if(a.h==undefined)alert('');
	},
	it:function(t,color){
		var thisColor = $(this).css('color');
		if($(this).attr('type')=='text'){$(this).css({color:color}).val(t);$(this).focus(function(){if($(this).val()==t)$(this).css({color:thisColor}).val('');}).blur(function(){if($(this).val()=='')$(this).css({color:color}).val(t);});}
		else if($(this).attr('type')=='password'){
			var tl = $(this);
			var ni = $(document.createElement("input")).attr({'type':'text','id':$(tl).attr('id')}).css({color:color}).addClass($(tl).attr('class')).val(t).focus(function(){$(ni).replaceWith(tl);$(tl).val('').focus();});
			$(tl).replaceWith(ni);
			$(tl).blur(function(){if($(tl).val()=='')$(tl).it(t,color);});
		};
	}

});



function TopMenuLoading(fm)
{
	for(i=1;i<=5;i++)
	{
		if(i!=fm)
		{
			document.getElementById("m"+i).onmouseout =  function(){this.src=this.src.replace("_hover.gif",".gif");};
			document.getElementById("m"+i).onmouseover = function(){this.src=this.src.replace(".gif","_hover.gif");};
		}
		else
		{
			document.getElementById("m"+i).src=document.getElementById("m"+i).src.replace(".gif","_hover.gif");
		}
	}
}


function MoveOver(Obj)
{
	Obj.src=Obj.src.replace(".jpg","_hover.jpg");
}

function MoveOut(Obj)
{
	Obj.src=Obj.src.replace("_hover.jpg",".jpg");
}


function DownloadLoading()
{
	for(i=1;i<=5;i++)
	{
		document.getElementById("d"+i).onmouseout =  function(){
			if(this.name!="on")
			{
				this.src=this.src.replace("_hover.jpg",".jpg");
			}
		};
		document.getElementById("d"+i).onmouseover = function(){
			if(this.name!="on")
			{
				this.src=this.src.replace(".jpg","_hover.jpg");
			}
		};

		document.getElementById("d"+i).onclick = function(){
			DownloadClick(this.id.replace("d",""));
		};
	}
}

function DownloadClick(id)
{
	for(i=1;i<=5;i++)
	{
		document.getElementById("d"+i).name="dd";
		document.getElementById("d"+i).src=document.getElementById("d"+i).src.replace("_hover.jpg",".jpg");

	}
	document.getElementById("d"+id).name="on";
	document.getElementById("d"+id).src=document.getElementById("d"+id).src.replace(".jpg","_hover.jpg");
	
	//var TopPx = (580 * (parseFloat(id) - 1)) * -1;
	//$("#MoveMBox").animate({marginTop:TopPx+"px"});
	//document.getElementById("MoveMBox").style.marginTop = TopPx + "px";

	
	ContentMoreLoading();


	for(i=1;i<=5;i++)
	{
		$("#Content"+i).fadeOut(0);
	}
	$("#Content"+id).fadeIn(500);
}


function VideoOpen()
{
	floatWindow(480,400,function(m,c){
			var flash = '<embed src="http://static.youku.com/v/swf/qplayer.swf?VideoIDS=XMzA3OTUyMTA0=&isAutoPlay=true&isShowRelatedVideo=false&embedid=-&showAd=0" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>';
			$(flash).appendTo(m);
			$(c).css('display','none');
		});
}



function floatWindow(w,h,fn){
	var _window = $(document.createElement('div')).css({position:'absolute',left:0,top:0,width:$('body').width(),height:$(document).height()}).appendTo('body');
	var fw_bg = $(document.createElement('div')).css({cursor:'pointer',position:'absolute',left:0,top:0,width:$('body').width(),height:$(document).height(),opacity:0,background:'#000',zIndex:0}).appendTo(_window).animate({opacity:0.5},500,function(){
			var _fw = $(document.createElement('div')).css({opacity:0,position:'absolute',padding:10,width:10,height:10,left:($('body').width()-10)/2-10,top:(($(window).height()-10)/2+$(document).scrollTop()-10)}).appendTo(_window);
			var fwBorder = $(document.createElement('div')).css({position:'absolute',width:30,height:30,left:0,top:0,background:'#FFF',opacity:0.5}).appendTo(_fw);
			var fwBody = $(document.createElement('div')).css({position:'relative',width:10,height:10,background:'#FFF'}).appendTo(_fw);
			$(_fw).animate({opacity:1,width:w,height:h,left:($('body').width()-w)/2-10,top:($(window).height()-h)/2+$(document).scrollTop()-10},500);
			$(fwBorder).animate({width:w+20,height:h+20},500);
			$(fwBody).animate({width:w,height:h},500,function(){
				var colo = $(document.createElement('div')).css({position:'absolute',cursor:'pointer',right:10,top:10,width:23,height:23,background:'url(images/fwColo.jpg)'}).appendTo(_fw).click(function(){$(_window).animate({opacity:0},300,function(){$(this).remove();})});
				$(fw_bg).click(function(){$(colo).click()});
				fn(fwBody,colo);
			});
		});
};



$(function(){
	//$('.class li').hover(function(){imgHoverAdd($(this).find('img'),$(this).find('img').attr('src').substr($(this).find('img').attr('src').length-3,3))},function(){imgHoverRemove($(this).find('img'),$(this).find('img').attr('src').substr($(this).find('img').attr('src').length-3,3))});
	$('.RoundedCorner').css3({background:'#FFF',border:'1px solid #d3d3d3'},[3,'none']);
});


function ContentMoreLoading()
{
	for(x=1;x<=5;x++)
	{
		$('#ContentBox_'+x).css3({height:'285px'},[3,'none']);
		if($('#ContentTxt_'+x).height()>290)
		{
			$('#ContentMore_'+x).show("slow");
		}
		else
		{
			$('#ContentMore_'+x).hide("slow");
		}
	}
	
}

function ContentMoreTxtPro(n)
{
	var ContentHeight  = $('#ContentTxt_'+n).height() + 30;
	$('#ContentMore_'+n).hide("slow",function(){
		$('#ContentBox_'+n).animate({height:ContentHeight},500);	
	});
}
