//var _ra_gloabal_host="http://localhost/paris_shanghai/";
//var _ra_gloabal_host="http://localhost:1200/paris_shanghai/";
var _ra_gloabal_host="http://www.chanel-eclub.com/paris_shanghai/";
//var _ra_gloabal_host="http://www.chanel-eclub.com/paris_shanghai_test/";


function _ra_GetCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function _ra_SetCookie(name, value)
{
    var expdate = new Date();
    var argv = _ra_SetCookie.arguments;
    var argc = _ra_SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
    document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
}

function _ra_DelCookie(name)
{
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = _ra_GetCookie (name);
    document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

function _ra_GetCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen){
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return _ra_GetCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}





function showSystemMessage(w,h,url,t){
    closeSystemMessage();
    var f=document.getElementById("frmSystemMessage");
	f.style.width = document.documentElement.scrollWidth+"px";
	f.style.height = document.documentElement.scrollHeight+"px";
	f.style.zIndex="2000";
    f.style.display="inline";
    
    var c=document.getElementById("divSystemMessageContent"); 
    
	c.style.width = w+"px";
	c.style.height = h+"px";
	c.style.left=document.documentElement.scrollLeft+parseInt((document.documentElement.clientWidth-w)/2)+"px";
	c.style.top=document.documentElement.scrollTop+parseInt((document.documentElement.clientHeight-h)/2)+"px";
	c.style.zIndex="2001";

    //c.getElementsByTagName("IFRAME")[0].style.height=h-0+"px";

    c.getElementsByTagName("TABLE")[0].rows[1].style.height=h-42+"px";
    c.getElementsByTagName("TABLE")[1].getElementsByTagName("TD")[0].innerHTML=t;
    c.getElementsByTagName("IFRAME")[0].style.height=h-42+"px";

    
    url+=((url.indexOf("?")>0)?"&":"?");
    url+=Math.random();
   
    c.getElementsByTagName("IFRAME")[0].src=url;

    c.style.display="inline";
    
    
    window.onresize=window.onscroll=function(){
        //alert(document.documentElement.clientHeight);
        var f=document.getElementById("frmSystemMessage");
        if(f.style.display=="inline"){
	        f.style.width = document.documentElement.scrollWidth+"px";
	        f.style.height = document.documentElement.scrollHeight+"px";
        }
        var c=document.getElementById("divSystemMessageContent");
        if(c.style.display=="inline"){
	        c.style.left=document.documentElement.scrollLeft+parseInt((document.documentElement.clientWidth-w)/2)+"px";
	        c.style.top=document.documentElement.scrollTop+parseInt((document.documentElement.clientHeight-h)/2)+"px";
        }
    }
    

}

function closeSystemMessage(){
    var f=document.getElementById("frmSystemMessage");
    f.style.display="none";
    
    var c=document.getElementById("divSystemMessageContent"); 
    c.getElementsByTagName("IFRAME")[0].src=_ra_gloabal_host+"transparent.html";
    c.style.display="none";
    
    window.onresize=window.onscroll=null;

}

if(!document.getElementById("frmSystemMessage")){    
    document.write('<iframe id="frmSystemMessage" src="'+_ra_gloabal_host+'transparent.html" allowtransparency="true"');
    document.write('    width="0" height="0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"');
    document.write('    style="display: none;"></iframe>');
    document.write('<div id="divSystemMessageContent">');
    document.write('    <table cellpadding="0" cellspacing="0" border="0" width="100%" style="height: 100%;">');

	document.write('        <tr height="36">');
    document.write('            <td>');
    document.write('                <table cellpadding="0" cellspacing="0" border="0" width="100%" style="height: 100%;"><tr><td style="text-align: center;color:#969696;font-size:14px;font-weight:bold;width:100%;"></td><td width="39" style="text-align: right;"><a href="#" onclick="javascript:closeSystemMessage();return false;"');
    document.write('                    style="font-family: Verdana; font-size: 10px;color:red;"><img src="'+_ra_gloabal_host+'images/close.gif" width="39" height="36" border="0" alt="close" title="close" /></a></td></tr></table></td>');
    document.write('        </tr>');

	
	document.write('        <tr>');
    document.write('            <td>');
    document.write('                <iframe id="frmSystemMessageContent" width="100%" height="100%" frameborder="0"');
    document.write('                    marginwidth="0" marginheight="0" scrolling="no"></iframe>');
    document.write('            </td>');
    document.write('        </tr>');
    document.write('    </table>');
    document.write('</div>');
    document.write('<style>');
    document.write('#frmSystemMessage');
    document.write('{');
    document.write('	position:absolute;');
    document.write('	top:0px;');
    document.write('	left:0px;');
    document.write('	FILTER: Alpha(opacity=50);');
    document.write('	-moz-opacity: 0.5;');
    document.write('	opacity: 0.5;');
    document.write('	background-color:#000000;');
    document.write('	display:none;');
    document.write('}');
    document.write('#divSystemMessageContent');
    document.write('{');
    document.write('	position:absolute;');
    document.write('	background-color:#FFFFFF;');
    document.write('	display:none;');
    document.write('	border: 1px solid #E4E4E4;');
    document.write('}');
    document.write('</style>');    
}


function ra_register(l){
	if(l!="cn" && l!="tw"){
		alert("language error");
		return false;
	}
	var t;
	if(l=="tw") t="";
	else t="";

	showSystemMessage(700,470,_ra_gloabal_host+'register.aspx?l='+l+'&r='+escape(location.href),t);
	return false;
}


function ra_alert(l){
	if(l!="cn" && l!="tw" && l!="en" && l!="fr"){
		alert("language error");
		return false;
	}
	var t;
	if(l=="tw") t="";
	else t="";

	showSystemMessage(400,200,_ra_gloabal_host+'alert.aspx?l='+l+'&r='+escape(location.href),t);
	return false;
}

function ra_alert_subscribe(l,e){
	if(l!="cn" && l!="tw" && l!="en" && l!="fr"){
		alert("language error");
		return false;
	}
	var t;
	if(l=="tw") t="";
	else t="";

	showSystemMessage(400,200,_ra_gloabal_host+'alert_unsubscribe.aspx?l='+l+'&e='+escape(e),t);
	return false;
}

if(location.href.indexOf("_ra_showregister_fromedm=")>=0){
    var v=location.href.split("_ra_showregister_fromedm=")[1];
    v=v.split("&")[0];
    v=v.split("#")[0];
    ra_register(v);
}

if(location.href.indexOf("_ra_showregister=")>=0){
    var v=location.href.split("_ra_showregister=")[1];
    v=v.split("&")[0];
    v=v.split("#")[0];
    
    if(_ra_GetCookie("ra_showregister")!=v){
        _ra_SetCookie("ra_showregister",v);
        ra_register(v.split("|")[1]);
    }
}

if(location.href.indexOf("_ra_showregister=")<0&&location.href.indexOf("_ra_alert_unsubscribe=")>=0){
    var v=location.href.split("_ra_alert_unsubscribe=")[1];
    v=v.split("&")[0];
    v=v.split("#")[0];
    
    var splitstring=((v.indexOf("|")>=0)?"|":"%7C");
    ra_alert_subscribe(v.split(splitstring)[0],v.split(splitstring)[1]);
}
