﻿/* 公共JS样式 */

function $E(oID){
	oID=oID.replace("#","");
    var node=typeof oID=="string"?document.getElementById(oID):oID;
    if(node!=null){return node;}else{}
    return null;
}
function $C(tagName){
    return document.createElement(tagName);
}
function $N(name){
    return document.getElementsByName(name);
}


var Rocoforex = {
	$ : function(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}},
	isIE : navigator.appVersion.indexOf("MSIE")!=-1?true:false,
	addEvent : function(obj,eventType,func){if(obj.attachEvent){obj.attachEvent("on" + eventType,func);}else{obj.addEventListener(eventType,func,false)}},
	delEvent : function(obj,eventType,func){if(obj.detachEvent){obj.detachEvent("on" + eventType,func)}else{obj.removeEventListener(eventType,func,false)}}
};
function sim_select(o, cls) {
	o=document.getElementById(o);
	o.style.display='none';
	var opts=o.options,
		parent=o.parentNode,
		self=this;
 
	this.isShow=false;
	this.div=document.createElement('div');
	this.ul=document.createElement('ul');
	this.h3=document.createElement('h3');
	this.div.className=cls;
	parent.replaceChild(this.div,o);
	this.div.appendChild(o);
	this.ul.style.display='none';
	this.ul.style.top=this.h3.offsetHeight;
	if(opts[o.selectedIndex].innerHTML == "中文"){
	    this.h3.className = "china";
	}else{
	    this.h3.className = opts[o.selectedIndex].innerHTML;
	}
	this.h3.innerHTML = opts[o.selectedIndex].innerHTML;
 
	for (var i=0,l=o.length; i<l; i++) {
		var li=document.createElement('li');
		li.innerHTML=opts[i].innerHTML;
		li.className = "lan_"+i;
		this.ul.appendChild(li);
		li.onmouseover=function () {
			this.className+=' over';
		}
		li.onmouseout=function () {
			this.className=this.className.replace(/over/gi,'');
		}
		li.onclick=(function (i) {
			return function () {
				self.hide();
				self.h3.innerHTML=this.innerHTML;
				o.selectedIndex=i;
				if(o.onchange){
					o.onchange();
				}
			};
		})(i);
	}
	this.div.appendChild(this.h3);
	this.div.appendChild(this.ul);
 
	this.ul.style.top=this.h3.offsetHeight+'px';
	this.ul.style.width=this.h3.offsetWidth-2+'px';
 
	this.init();
}
 
sim_select.prototype={
	init : function () {
		var self=this;
		    Rocoforex.addEvent(document.documentElement,'click',function (e) {
			    self.close(e);
		    });
		this.h3.onclick=function () {
			self.toggles()
		}
	},
	show : function () {
		this.ul.style.display='block';
		this.isShow=true;
	},
	hide : function () {
		this.ul.style.display='none';
		this.isShow=false;
	},
	close : function (e) {
		var t = window.event ? window.event.srcElement : e.target;
		do {
			if (t==this.div) {
				return ;
			}else if(t==document.documentElement){
				this.hide();
				return ;
			}else {
				t=t.parentNode;
			}
		}while(t.parentNode);
	},
	toggles : function () {
		this.isShow ? this.hide() : this.show();
	}
}


var Rates = {
    Init : function(){
        var func = Rates.Load;
        Rates.setAjaxPost("http://www.rocoforex.com.au/Template/Rates.ashx?t="+new Date().getTime()+"", {type:"load"}, func);
        setTimeout("Rates.Init()", 2000);
    },
    
    Load : function(con){
        if(con.length>0){
            var str = "<ul>";
            for(var i = 0; i < con.length; i++){
                var begin = "";
                var end = "";
                if(con[i].a=="up"){
                    begin = "<i>"+con[i].c+"</i>";
                    end = "<i>"+con[i].d+"</i>";
                }else{
                    begin = "<b>"+con[i].c+"</b>";
                    end = "<b>"+con[i].d+"</b>";
                }
                str += "<li><span class=\"tit\">"+con[i].b+"</span><span class=\"txt\">"+begin+"&nbsp;&nbsp;|&nbsp;&nbsp;"+end+"</span></li>";
            }
            str += "</ul>";
            jQuery("#Live_Rates").html(str);
        }
    },
    
    setAjaxPost : function(url, d, func){
        //参数url, data数据为json, function, 数据类型json
        jQuery.post(url, d,
            function (data, textStatus){
                if(typeof(func)=="function"){
                    func(data);
                }else{
                    alert("未知错误，请刷新页面后重试");return false;
                }
             }, "json");
    }
}

function SetEmail(){
    var Rule = /^[-A-Z0-9_\.]+@([0-9A-Z][0-9A-Z-]+\.)+[A-Z]{2,5}$/i;
    var error_00 = "请输入您常用电子邮箱";
    var error_01 = "您的电子邮箱格式错误";
    if($("#Langu").val()=="en")
    {
        error_00 = "Email can not be empty";
        error_01 = "Email format error";
    }
    if($("#Email").val() == ""){
        alert(error_00);
        $("#Email")[0].focus();
        $("#Email")[0].select();
        return false;
    }
    if(!Rule.test($("#Email").val())){
        alert(error_01);
        $("#Email")[0].focus();
        $("#Email")[0].select();
        return false;
    }
    location.href="http://www.rocoforex.com.au/Template/Email.ashx?email="+$("#Email").val()+"&langu="+$("#Langu").val()+"";
}


/* 视频加载 */
function VideoLoad(url){
    var id = url.split("/");
    if(id[2]=="www.tudou.com"){
        var video = new SWFObject(url, "","550", "450", "9", false, "high");
        video.addParam("allowscriptaccess", "always");
        video.addParam("allowFullScreen", "true");
    }else{
        var video = new SWFObject("http://static.youku.com/v1.0.0131/v/swf/qplayer.swf?VideoIDS="+id[5]+"&isAutoPlay=true", "","550", "450", "9", false, "high");
    }
    video.write("VideoFlash");
/*
    var video = new SWFObject(url, "","550", "450", "9", false, "high");
    video.addParam("wmode", "transparent");
    video.addParam("allowFullScreen", "true");
    video.write("VideoFlash");
*/
}

/*
舌签构造函数
SubShowClass(ID[,eventType][,defaultID][,openClassName][,closeClassName])
version 1.21
*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('s 7(h,j,k,l,m){5.1i="1.1j";5.1k="1l";5.t=7.$(h);6(5.t==p&&h!="9"){L M N("7(w)参数错误:w 对像存在!(V:"+h+")")};6(!7.u){7.u=[]};5.w=7.u.q;7.u.1b(5);5.1m=r;5.8=[];5.W=k==p?0:k;5.B=5.W;5.X=l==p?"1n":l;5.Y=m==p?"":m;5.O=r;x n=Z("7.u["+5.w+"].O = z"),G=Z("7.u["+5.w+"].O = r");6(h!="9"){6(5.t.v){5.t.v("10",n)}y{5.t.H("11",n,r)}};6(h!="9"){6(5.t.v){5.t.v("12",G)}y{5.t.H("13",G,r)}};6(14(j)!="1o"){j="1p"};j=j.1q();1r(j){P"10":5.A="11";I;P"12":5.A="13";I;P"1s":5.A="1t";I;P"1u":5.A="1v";I;1w:5.A="1x"};5.1c=s(a,b,c,d,e){6(7.$(a)==p&&a!="9"){L M N("1c(1d)参数错误:1d 对像存在!(V:"+a+")")};x f=5.8.q;6(c==""){c=p};5.8.1b([a,b,c,d,e]);x g=Z(\'7.u[\'+5.w+\'].C(\'+f+\')\');6(a!="9"){6(7.$(a).v){7.$(a).v("1y"+5.A,g)}y{7.$(a).H(5.A,g,r)}};6(f==5.W){6(a!="9"){7.$(a).Q=5.X};6(7.$(b)){7.$(b).D.R=""};6(h!="9"){6(c!=p){5.t.D.1e=c}};6(d!=p){J(d)}}y{6(a!="9"){7.$(a).Q=5.Y};6(7.$(b)){7.$(b).D.R="9"}};6(7.$(b)){6(7.$(b).v){7.$(b).v("10",n)}y{7.$(b).H("11",n,r)};6(7.$(b).v){7.$(b).v("12",G)}y{7.$(b).H("13",G,r)}}};5.C=s(a,b){6(14(a)!="15"){L M N("C(1f)参数错误:1f 不是 15 类型!(V:"+a+")")};6(b!=z&&5.B==a){S};x i;16(i=0;i<5.8.q;i++){6(i==a){6(5.8[i][0]!="9"){7.$(5.8[i][0]).Q=5.X};6(7.$(5.8[i][1])){7.$(5.8[i][1]).D.R=""};6(h!="9"){6(5.8[i][2]!=p){5.t.D.1e=5.8[i][2]}};6(5.8[i][3]!=p){J(5.8[i][3])}}y 6(5.B==i||b==z){6(5.8[i][0]!="9"){7.$(5.8[i][0]).Q=5.Y};6(7.$(5.8[i][1])){7.$(5.8[i][1]).D.R="9"};6(5.8[i][4]!=p){J(5.8[i][4])}}};5.B=a};5.17=s(){6(E.q!=5.8.q){L M N("17()参数错误:参数数量与标签数量不符!(q:"+E.q+")")};x a=0,i;16(i=0;i<E.q;i++){a+=E[i]};x b=1z.17(),18=0;16(i=0;i<E.q;i++){18+=E[i]/a;6(b<18){5.C(i);I}}};5.F=r;x o=p;5.K=1A;5.1B=s(a){6(14(a)=="15"){5.K=a};T(o);o=19("7.u["+5.w+"].U()",5.K);5.F=z};5.U=s(){6(5.F==r||5.O==z){S};5.1g()};5.1g=s(){x a=5.B;a++;6(a>=5.8.q){a=0};5.C(a);6(5.F==z){T(o);o=19("7.u["+5.w+"].U()",5.K)}};5.1C=s(){x a=5.B;a--;6(a<0){a=5.8.q-1};5.C(a);6(5.F==z){T(o);o=19("7.u["+5.w+"].U()",5.K)}};5.1D=s(){T(o);5.F=r}};7.$=s(a){6(1a.1h){S J(\'1a.1h("\'+a+\'")\')}y{S J(\'1a.1E.\'+a)}}',62,103,'|||||this|if|SubShowClass|label|none||||||||||||||||null|length|false|function|parentObj|childs|attachEvent|ID|var|else|true|eventType|selectedIndex|select|style|arguments|autoPlay|mouseOutFunc|addEventListener|break|eval|spaceTime|throw|new|Error|mouseIn|case|className|display|return|clearInterval|autoPlayFunc|value|defaultID|openClassName|closeClassName|Function|onmouseover|mouseover|onmouseout|mouseout|typeof|number|for|random|percent|setInterval|document|push|addLabel|labelID|background|num|nextLabel|getElementById|version|21|author|mengjia|lock|selected|string|onmousedown|toLowerCase|switch|onclick|click|onmouseup|mouseup|default|mousedown|on|Math|5000|play|previousLabel|stop|all'.split('|'),0,{}))



//===========================
//为了美观，不要报错
//function killerr(){return true;}
//window.onerror = killerr;
//===========================


/*
******************************************************************************
*2011-6-21Laven
*/
var RatesPrice = {
    Init : function(){
        var func = RatesPrice.Load;
        RatesPrice.setAjaxPost("http://www.rocoforex.com.au/Template/Ratesprice.ashx?t="+new Date().getTime()+"", {type:"load"}, func);
        setTimeout("RatesPrice.Init()", 60000);
        
    },
    Load : function(con){
        if(con.length>0){
            var str = "";
            for(var i = 0; i < con.length; i++){
                var begin = con[i].c;
                var end = con[i].d;
                var img="Rates_down.gif";
                var color="red";
                if(con[i].a=="up"){
                    img="Rates_up.gif";
                    color="green";
                }else{
                    img="Rates_down.gif";
                    color="red";
                }
                str+="<dt><img src=\"http://www.rocoforex.com.au/image/"+img+"\" /><span style=\"font-weight:bold;\">"+con[i].b+"</span><span style=\"color:"+color+"; font-weight:bold;\">"+begin+"</span><span>"+end+"</span></dt>";
            }
            jQuery("#demo1").html(str);
            jQuery("#demo4").html(str); 
      }
    },
    setAjaxPost : function(url, d, func){
        //参数url, data数据为json, function, 数据类型json
        jQuery.post(url, d,
            function (data,textStatus){
                if(typeof(func)=="function"){
                    func(data);
                }else{
                    alert("未知错误，请刷新页面后重试");return false;
                }
             }, "json");
    }
}


//***********************************************
//滚动效果
var speed=70; //数字越大速度越慢
var tab=new Object();
var tab1=new Object();
var tab2=new Object();
function rollEvent()/*在页面313行调用*/
{
	tab=document.getElementById("demo");
	tab1=document.getElementById("demo1");
	tab2=document.getElementById("demo2");
	tab2.innerHTML=tab1.innerHTML;
	var MyMar=setInterval(Marquee,speed);
	tab.onmouseover=function(){clearInterval(MyMar)};
	tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
}

function Marquee()
{
	if(tab2.offsetWidth-tab.scrollLeft<=0)
	{
		tab.scrollLeft-=tab1.offsetWidth
	}
	else
	{
		tab.scrollLeft++;
	}
}
//**************图片时间
var DayTime={
   Init:function(){
     var now=new Date();
     var year=now.getFullYear();
     var month=now.getMonth()+1;
     var day=now.getDate();

     $("#div_time1").html(year+"-"+month+"-"+day);
     $("#div_time2").html(year+"-"+month+"-"+day);
     $("#div_time3").html(year+"-"+month+"-"+day);
   }
}



