var historyName;
var cookieName = "page_history";
var cookieInfo;
var showPopup = false;
var arr = new Array();
var http_request;
var response_array;
var req;
var is_status = 1;
var stop_toolbar; //=1 when to stop the d2p toolbar
//var d2p_url = 'https://staging.d2pass.d2p/';
//var ccg_url = 'http://jp.staging.caribbeancomgirl.com/';
var d2p_url = 'http://www.d2pass.com/';
var ccg_url = 'http://www.caribbeancomgirl.com/guest/'
//var ccg_url = 'http://jp.caribbeancomgirl.com/';

function setCookie (name, value){ 
	document.cookie = name + '=' + escape(value) + ";path=/;domain=.caribbeancom.com" 
}

function getCookieRaw(cookieName)
{
        var search = cookieName + '=';
        if (document.cookie.length>0) {
                offset = document.cookie.indexOf(search);
                if (offset != -1){
                        offset += search.length;
                        end             = document.cookie.indexOf(';',offset);
                        if(end == -1)
                                end = document.cookie.length;
                        return unescape(document.cookie.substring(offset,end));
                }
        }
        return null;
}

function isMember( )
{
    if( !getCookieRaw('NetiA') )
    {
        return null;
    }

    if( !getCookieRaw('user_status') || getCookieRaw('user_status') != 99 )
    {
        return getCookieRaw('NetiA');
    }

    return null;
}
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getCookie(cookieName){

	if( cookieName == 'NetiA' ){ return isMember( );}

	var search = cookieName + '=';
	if (document.cookie.length>0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1){
			offset += search.length;
			end 		= document.cookie.indexOf(';',offset);
			if(end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset,end));
		}
	}
	return null; 
}

var cookieInfo = getCookie("page_history")

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function showHistory(){
	if(cookieInfo){
		document.write("<table width='670' height=20 cellspacing=0 cellpadding=2 border=0><tr><td>");
		arr = cookieInfo .split("|") 
		for(var i=0; i < arr.length; i++){
			var temp = arr[i].split("::");
			var title = temp[0]; 
			if(title.length>13) title = title.substring(0, 13)+'...';
			var url = temp[1]; 
			if(i>0) document.write("&nbsp;>&nbsp;");
			document.write("<a href=" + url + ">" + title + "</a>"); 
		}
		document.write("</td></tr></table>");
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkHistory(arrLocal){
	for(i=0; i<arrLocal.length; i++){
		strHistory = arrLocal[i]
		strHistoryName = (strHistory.split("::"))[0]
		if(strHistoryName.indexOf(historyName) > -1 && strHistoryName.length == historyName.length)
			return false
	}
	return true
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!historyName)
	historyName = (document.title).replace("カリビアンコム ", "")

	 
if(cookieInfo){
	arr = cookieInfo .split("|")
	if(historyName != "" && checkHistory(arr)){
		if(arr.length >= 5) 
			arr = (arr.slice(1,5)).concat(new Array(historyName+"::"+document.URL))
		else 
			arr = arr.concat(new Array(historyName+"::"+document.URL))
		setCookie(cookieName,  (cookieInfo = arr.join("|")))
	}
} else {
	setCookie(cookieName, historyName+"::"+document.URL)
}

function showUserStatus() {
	user_status = getCookie('user_status');
  netia = getCookie('NetiA');
  user_status_name = '';
  if(netia) {
  	if(user_status=='1') {
    	user_status_name = '会員';
      var status = '/images/header/logged_in.gif';
    } else if(user_status == '2') {
     	user_status_name = '２ヶ月会員';
     	var status = '/images/header/2month_logged_in.gif';
    } else if(user_status=='3') {
     	user_status_name = 'VIP会員';
      var status = '/images/header/vip_logged_in.gif';
    } else if(user_status=='5') {
     	user_status_name = '超VIP会員';
      var status = '/images/header/supervip_logged_in.gif';
    }
  }
	if(user_status_name!='') {
		document.write('<div class="log_box"><ul><li><img src="' + status + '" alt="'+ user_status_name + '" width="78" height="23" border="0"></li><li><a href="/logout.php"><img src="/images/header/logout_button.jpg" alt="ログアウト" width="78" height="23" border="0"></a></li></ul><p><a href="https://perldesk.dtiserv.com/cgi-bin/up.cgi">ID・パスワード忘れた人はこちら</a></p></div></td><td>&nbsp;</td><td>');
//  	document.write('<table border="0"  background="/images/header/login_box_normal_bg.gif" style="background-repeat: no-repeat;" width="199" height="50" cellpadding="0" cellspacing="0"><tr><td width="199 height="50" style="padding:2px 0 0 15px;"><img src="' + status + '" alt="'+ user_status_name + '"></td><td style="padding: 5px 20px 0 0;"><a href="/logout.php"><img src="/images/header/logout_button.jpg" width="78" height="23" border="0" alt="ログアウト"></a></td></tr><tr><td colspan="2" style="padding: 0 0 3px 21px;"><a href="https://perldesk.dtiserv.com/cgi-bin/up.cgi" class="black11px" target="_blank">ＩＤ/パスワードを忘れた方はこちら</a></td></tr></table>');
     	} else {
  //     	document.write('<table border="0" background="/images/header/login_box_normal_bg.gif" style="background-repeat: no-repeat;" width="199" height="50" cellpadding="0" cellspacing="0"><tr><td width="78" style="padding: 2px 0 0 17px;"><a href="/first.htm"><img src="/images/header/first_button.jpg" alt="初めての方" width="78" height="23" border="0"></a></div></td><td style="padding: 1px 4px 0 0;"><a href="/member/login.php?url=' + document.URL + '"><img src="/images/header/login_button.jpg" alt="ログイン" width="78" height="23" border="0"></a></td></tr><tr><td colspan="2" style="padding-left: 20px;"><a href="https://perldesk.dtiserv.com/cgi-bin/up.cgi" class="black11px" target="_blank">ＩＤ/パスワードを忘れた方はこちら</a></td></tr></table>');
			document.write('<div class="log_box"><ul><li><a href="/first.htm"><img src="/images/header/first_button.jpg" alt="初めての方" width="78" height="23" border="0"></a></li><li><a href="/member/login.php?url=' + document.URL + '"><img src="/images/header/login_button.jpg" alt="ログイン" width="78" height="23" border="0"></a></li></ul><p><a href="https://perldesk.dtiserv.com/cgi-bin/up.cgi">ID・パスワード忘れた人はこちら</a></p></div></td><td>&nbsp;</td><td>');
   }
}


function showD2PToolbar() {
netia = getCookie('NetiA');
document.write('<script type="text/javascript" src="/d2ptoolbar/caribbeancom.com/util.js"><\/script>');
//document.write('<script language="javascript" src="/js/d2ptar.js"><\/script>');
/*
  var d2ptoolbar_url;

  if (stop_toolbar != 1) {
        netia = getCookie('NetiA');
        ml = '';
        if(netia) {
            cForm = netia.split(":");
            check = /.+@.+\..+/;

            if (cForm[0].match(check)) 
            {           
                d2ptoolbar_url = "/d2ptb?NetiFL=1";
            }
            else
            {
                d2ptoolbar_url = "https://images.d2pass.com/images/toolbar/sjis/black_dti.html";
            }
  
           document.write('<center><div class="d2_toolbar"><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 ><TBODY><TR><TD height=23>');
           document.write('<IFRAME src="' + d2ptoolbar_url );
           document.write('" frameBorder=0 width="100%" scrolling=no height=23></IFRAME></TD></TR></TBODY></TABLE></div></center>');        


        }
  }
*/
}

function showLogin(){
   netiA = getCookie('NetiA');
   if(netiA){
        document.write('<div><a href="/logout.php"><img src="/images/left_logout.gif" width="159" height="21" border="0" alt="カリビアンコム　ログアウト"></a></div>');
   }else{
        document.write('<div><a href="/member/login.php?url=' + document.URL + '"><img src="/images/left_login.gif" width="159" height="21" border="0" alt="カリビアンコム　ログイン"></a></div>');
   }
}

function joinPeriod(){
    joindate = getCookie('joindate');
    if (joindate) {
    	join = joindate.split(",+");
    	return join[1];
    }
}

function recurringFlg(){
    joindate = getCookie('joindate');
    if (joindate) {
    	result = joindate.split(",+");
    	return result[0];
    }
}

function ppvCoupon(){
    coupon = getCookie('ppv');   
    if (coupon) {
        ppv = coupon.split(",+");
        return ppv[0];
    }
}

function ppvExpiry(){
    coupon = getCookie('ppv');
    if (coupon) {
        ppv = coupon.split(",+");
        if (ppv[0]==0) {
                return '';
        } else {
                return ppv[1];
        }
    }
}

function showHeaderTitleimage() {
    user_status = getCookie('user_status');
    netia = getCookie('NetiA');
    user_status_name = '';
    var header_image = '/images/header/logo_samp.gif';

    if(netia) {
  	if(user_status=='1') {
    		header_image = '/images/header/logo_mem.gif';
    	} else if(user_status == '2') {
      		header_image = '/images/header/logo_mem.gif';
    	} else if(user_status=='3') {
      		header_image = '/images/header/logo_vip.gif';
    	} else if(user_status=='5') {
      		header_image = '/images/header/logo_vip.gif';
    	} else {
			header_image = '/images/header/logo_samp.gif';
		}
    }
	
    document.write('<td width="179" height="60"><a href="/index2.htm"><img src="' + header_image + '" width="179" height="60" alt="カリビアンコム"></a></td>');
}

function showHeaderimage() {
  user_status = getCookie('user_status');
  netia = getCookie('NetiA');
  user_status_name = '';
  var act_image = '/images/header/header_01_samp.jpg';
  var bg_image = '/images/header/header_bg_sample.gif';
  var css_class = 'samp';
  var img_alt = '';
  if(netia) {
    if(user_status=='1') {
		css_class = 'mem';
      	act_image = '/images/header/header_01_mem.jpg';
		bg_image = '/images/header/header_bg_member.gif';
    } else if(user_status == '2') {
		css_class = 'mem';
      	act_image = '/images/header/header_01_mem.jpg';
      	bg_image = '/images/header/header_bg_member.gif';
    } else if(user_status=='3') {
		css_class = 'vip';
      	act_image = '/images/header/header_01_vip.jpg';
      	bg_image = '/images/header/header_bg_vip.gif';
    } else if(user_status=='5') {
		css_class = 'svip';
      	act_image = '/images/header/header_01_vip.jpg';
      	bg_image = '/images/header/header_bg_vip.gif';
    }
  }
  document.write('<body id="' + css_class + '"><div id="header_c"><table border="0" width="1000" height="146" cellpadding="0" cellspacing="0" id="header2"><tr><td rowspan="4"><a href="/index2.htm"><img src="'+ act_image + '" width="114" height="146" alt="カリビアンコム ' + img_alt + '" border="0"></a></td>');
}

function showHeaderMenu() {
  user_status = getCookie('user_status');
  netia = getCookie('NetiA');
  var ppv = 'http://www.caribbeancompr.com/index2.html';
  var ppv2 = '/member/home.htm?NetiR=Y-Y-Wl.01lsn2lm0Jl.4JLEZWl.4JqSDOMS4JkmN2lmZWji4xjsvW9ES1MSZI6o-OlocOkOc.MOV.qOD26O-xqYl.62KOqOZ.ko32q1H&V=1';
  var ccg2 = 'http://click.dtiserv2.com/redir.fcgi?click=1400&site=173&b=1400&lang=tokyo';

//	var ppv = 'http://ccpr.macatoo.lax03.dti/index2.html';
//	var ppv2 = '/member/home.htm?NetiR=2j.K1n3N2k.0Yrg4Wli0CMUHWlBcGqSDOMS4JkmN2lmZWji4xjsvW9ES1MSiOManIqFH.6sA.kdDOHOKxkFDx6snOqdD.MB6x6FDOMFD2f&V=1'; 
//	var ccg2 = 'http://jp.staging.caribbeancomgirl.com/home.shtml'; 
  	var ccg = 'javascript:void(0);" onClick="javascript:gotoCCG()';	
  
  if(netia) {
		if(user_status<='2'){
			document.write('<td colspan="2" width="886" height="30"><ul><li><a href="/index2.htm"><img src="/images/header/top_movie.gif" alt="ムービー" width="84" height="25" border="0"></a></li><li><a href="' + ccg + '"><img src="/images/header/top_livechat.gif" alt="ライブチャット" width="104" height="25" border="0"></a></li><li><a href="' + ppv2 + '"><img src="/images/header/top_ppv.gif" alt="単品購入" width="87" height="25" border="0"></a></li><li><a href="/first.htm"><img src="/images/header/top_first.gif" alt="初めての方" width="97" height="25" border="0"></a></li><li><a href="/vip/index.htm"><img src="/images/header/top_vip.gif" alt="VIP" width="57" height="25" border="0"></a></li><li><a href="/member/vip_express.shtml"><img src="/images/header/top_vipupgrade.gif" alt="VIPアップグレード" width="130" height="25" border="0"></a></li><li><a href="/supervip/index.htm"><img src="/images/header/top_svip.gif" alt="超VIP" width="68" height="25" border="0"></a></li><li><a href="/member/cc_vip_upgrade.htm"><img src="/images/header/top_svip_upgrade.gif" alt="超VIPアップグレード" width="143" height="25" border="0"></a></li></ul></td></tr><tr><td colspan="2" width="886" height="34" valign="top"><ul><li><a href="/index2.htm"><img src="/images/header/b_home.gif" alt="カリビアンコム" width="60" height="20"></a></li><li><a href="/listpages/all1.htm"><img src="/images/header/b_all.gif" alt="全ムービーリスト" width="116" height="20" border="0"></a></li><li><a href="/listpages/original1.htm"><img src="/images/header/b_og.gif" alt="独占動画" width="77" height="20" border="0"></a></li><li><a href="/listpages/av1.htm"><img src="/images/header/b_av.gif" alt="AV女優" width="74" height="20" border="0"></a></li><li><a href="/listpages/student1.htm"><img src="/images/header/b_school.gif" alt="女子校生" width="77" height="20" border="0"></a></li><li><a href="/listpages/amateur1.htm"><img src="/images/header/b_amature.gif" alt="素人" width="60" height="20" border="0"></a></li><li><a href="/projects/past_projects/past_projects.htm"><img src="/images/header/b_special.gif" alt="企画・特集" width="90" height="20" border="0"></a></li><li><a href="/ranking/index.htm"><img src="/images/header/b_ranking.gif" alt="ランキング" width="84" height="20" border="0"></a></li></ul></td>');
		} else if(user_status == '3'){
			document.write('<td colspan="2" width="886" height="30"><ul><li><a href="/index2.htm"><img src="/images/header/top_movie.gif" alt="ムービー" width="84" height="25" border="0"></a></li><li><a href="' + ccg + '"><img src="/images/header/top_livechat.gif" alt="ライブチャット" width="104" height="25" border="0"></a></li><li><a href="' + ppv2 + '"><img src="/images/header/top_ppv.gif" alt="単品購入" width="87" height="25" border="0"></a></li><li><a href="/first.htm"><img src="/images/header/top_first.gif" alt="初めての方" width="97" height="25" border="0"></a></li><li><a href="/vip/index.htm"><img src="/images/header/top_vip.gif" alt="VIP" width="57" height="25" border="0"></a></li><li><a href="/member/cc_vip_upgrade.htm"><img src="/images/header/top_svip_upgrade.gif" alt="超VIPアップグレード" width="143" height="25" border="0"></a></li><li><a href="/supervip/index.htm"><img src="/images/header/top_svip.gif" alt="超VIP" width="68" height="25" border="0"></a></li></ul></td></tr><tr><td width="886" height="34" colspan="2" valign="top"><ul><li><a href="/index2.htm"><img src="/images/header/b_home.gif" alt="カリビアンコム" width="60" height="20"></a></li><li><a href="/listpages/all1.htm"><img src="/images/header/b_all.gif" alt="全ムービー表示" width="116" height="20" border="0"></a></li><li><a href="/listpages/original1.htm"><img src="/images/header/b_og.gif" alt="独占動画" width="77" height="20" border="0"></a></li><li><a href="/listpages/av1.htm"><img src="/images/header/b_av.gif" alt="ＡＶ女優" width="74" height="20" border="0"></a></li><li><a href="/listpages/student1.htm"><img src="/images/header/b_school.gif" alt="女子校生" width="77" height="20" border="0"></a></li><li><a href="/listpages/amateur1.htm"><img src="/images/header/b_amature.gif" alt="素人" width="60" height="20" border="0"></a></li><li><a href="/projects/past_projects/past_projects.htm"><img src="/images/header/b_special.gif" alt="入会案内" width="90" height="20" border="0"></a></li><li><a href="/ranking/index.htm"><img src="/images/header/b_ranking.gif" alt="ランキング" width="84" height="20" border="0"></a></li></ul></td>');
		} else if(user_status== '5') {
			document.write('<td colspan="2" width="886" height="30"><ul><li><a href="/index2.htm"><img src="/images/header/top_movie.gif" alt="ムービー" width="84" height="25" border="0"></a></li><li><a href="' + ccg + '"><img src="/images/header/top_livechat.gif" alt="ライブチャット" width="104" height="25" border="0"></a></li><li><a href="' + ppv2 + ' "><img src="/images/header/top_ppv.gif" alt="単品購入" width="87" height="25" border="0"></a></li><li><a href="/first.htm"><img src="/images/header/top_first.gif" alt="初めての方" width="97" height="25" border="0"></a></li><li><a href="/vip/index.htm"><img src="/images/header/top_vip.gif" alt="VIP" width="57" height="25" border="0"></a></li><li><a href="/supervip/index.htm"><img src="/images/header/top_svip.gif" alt="超VIP" width="68" height="25" border="0"></a></li></ul></td></tr><tr><td width="886" height="34" colspan="2" valign="top"><ul><li><a href="/index2.htm"><img src="/images/header/b_home.gif" alt="カリビアンコム" width="60" height="20"></a></li><li><a href="/listpages/all1.htm"><img src="/images/header/b_all.gif" alt="全ムービー表示" width="116" height="20" border="0"></a></li><li><a href="/listpages/original1.htm"><img src="/images/header/b_og.gif" alt="独占動画" width="77" height="20" border="0"></a></li><li><a href="/listpages/av1.htm"><img src="/images/header/b_av.gif" alt="ＡＶ女優" width="74" height="20" border="0"></a></li><li><a href="/listpages/student1.htm"><img src="/images/header/b_school.gif" alt="女子校生" width="77" height="20" border="0"></a></li><li><a href="/listpages/amateur1.htm"><img src="/images/header/b_amature.gif" alt="素人" width="60" height="20" border="0"></a></li><li><a href="/projects/past_projects/past_projects.htm"><img src="/images/header/b_special.gif" alt="企画・特集" width="90" height="20" border="0"></a></li><li><a href="/ranking/index.htm"><img src="/images/header/b_ranking.gif" alt="ランキング" width="84" height="20" border="0"></a></li></ul></td>');
		}
	}else{
		document.write('<td colspan="2" width="886" height="30"><ul><li><a href="/index2.htm"><img src="/images/header/top_movie.gif" alt="ムービー" width="84" height="25" border="0"></a></li><li><a href="' + ccg2 + '"><img src="/images/header/top_livechat.gif" alt="ライブチャット" width="104" height="25" border="0"></a></li><li><a href="' + ppv + '"><img src="/images/header/top_ppv.gif" alt="単品購入" width="87" height="25" border="0"></a></li><li><a href="/first.htm"><img src="/images/header/top_first.gif" alt="初めての方" width="97" height="25" border="0"></a></li><li><a href="/vip/index.htm"><img src="/images/header/top_vip.gif" alt="VIP" width="57" height="25" border="0"></a></li><li><a href="/join.htm"><img src="/images/header/top_join.gif" alt="入会案内" width="86" height="25" border="0"></a></li></ul></td></tr><tr><td width="886" height="34" colspan="2" valign="top"><ul><li><a href="/index2.htm"><img src="/images/header/b_home.gif" alt="カリビアンコム" width="60" height="20"></a></li><li><a href="/listpages/all1.htm"><img src="/images/header/b_all.gif" alt="全ムービー表示" width="116" height="20" border="0"></a></li><li><a href="/listpages/original1.htm"><img src="/images/header/b_og.gif" alt="独占動画" width="77" height="20" border="0"></a></li><li><a href="/listpages/av1.htm"><img src="/images/header/b_av.gif" alt="ＡＶ女優" width="74" height="20" border="0"></a></li><li><a href="/listpages/student1.htm"><img src="/images/header/b_school.gif" alt="女子校生" width="77" height="20" border="0"></a></li><li><a href="/listpages/amateur1.htm"><img src="/images/header/b_amature.gif" alt="素人" width="60" height="20" border="0"></a></li><li><a href="/projects/past_projects/past_projects.htm"><img src="/images/header/b_special.gif" alt="企画・特集" width="90" height="20" border="0"></a></li><li><a href="/ranking/index.htm"><img src="/images/header/b_ranking.gif" alt="ランキング" width="84" height="20" border="0"></a></li></ul></td>');
	}
}


function showFooterBgimage() {
  user_status = getCookie('user_status');
  netia = getCookie('NetiA');
  user_status_name = '';
  if(netia) {
    if(user_status=='1') {
      var bg_image = '/images/footer/footer_back_member.jpg';
    } else if(user_status == '2') {
      var bg_image = '/images/footer/footer_back_member.jpg';
    } else if(user_status=='3') {
      var bg_image = '/images/footer/footer_back_vip.jpg';
    } else if(user_status=='5') {
      var bg_image = '/images/footer/footer_back_vip.jpg';
    }
  }else{
      var bg_image = '/images/footer/footer_back.jpg';
  }
  document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" nowrap background="' + bg_image + '">');
}

function gotoCCG() {
	var jump_url;
	var netia = getCookie('NetiA');
	if(netia) {
	    cForm = netia.split(":");
	    check = /.+@.+\..+/;
	    if (cForm[0].match(check)) {
			jump_url =  'http://www.caribbeancomgirl.com/viewers/';
	//	jump_url = d2p_url + 'account/amenity/issue/?amenitySID=20000597&from=amenitySignup&strip=1&NetiFL=1';
	    } else {
	// real  
//	jump_url = '/member/home.htm?NetiR=G9Uv2jeZGk5nxkev2jgNxjsZJX36JjcyIMUyW-xaxLYs19O4Gk3AxLfv1j0cJkKyOqFy.6esx6msxr2KOHAZxqoV.6fH.Hms.q2i.Mms.6E0262&V=1';
		jump_url = 'http://www.caribbeancomgirl.com/viewers/'; 
   // staging
	//	jump_url = '/member/home.htm?NetiR=G9Uv1-B0xjsvxZ362L5a2l5s2k36JjV9GL5TWl.4JqSDOMS4YlssYjmZ1ZgaJlBsCX3HGuBNJMSiOqSi26oc.qfV.lhKOMOZ.MUi.jFc.HAVOHdiOr2DIM5lxd&V=1';
	    }	
	} else {
		//jump_url = ccg_url + 'home.shtml';
                jump_url = 'http://click.dtiserv2.com/redir.fcgi?click=1400&site=173&b=1400&lang=tokyo';
	}
	//window.open(jump_url, 'couponWindow');
        window.location.href = jump_url;


}

function gotoPPV(){

    var jump_url;
    var netia = getCookie('NetiA');

    if(netia){
         //jump_url = 'http://www.caribbeancompr.com/member/login.php?url=http://www.caribbeancompr.com/index2.html';
         jump_url = 'http://www.caribbeancom.com/member/home.htm?NetiR=Y-Y-Wl.01lsn2lm0Jl.4JLEZWl.4JqSDOMS4JkmN2lmZWji4xjsvW9ES1MSZI6o-OlocOkOc.MOV.qOD26O-xqYl.62KOqOZ.ko32q1H&V=1';

    }else{

         jump_url = 'http://www.caribbeancompr.com/index2.html';

    }

    window.location.href = jump_url;
    //window.open(jump_url, 'couponWindow');


}

function gotoCC(){
    var jump_url;
    var netia = getCookie('NetiA');

    if(netia ){
         jump_url = 'http://www.caribbeancom.com/member/login.php';

    }else{
         jump_url = 'http://www.caribbeancom.com/index2.htm';

    }

    location.href = jump_url;

}


function showUpgradeimage() {
    user_status = getCookie('user_status');
    netia = getCookie('NetiA');
    user_status_name = '';
    var upgrade_image = '/images/detail/detail_join.gif';
    var upgrade_page  = '/join.html';
    if(netia) {
        if(user_status=='1') {
            upgrade_image = '/images/detail/upgrade_vip.gif';
            upgrade_page = '/member/vip_express.shtml';
        } else if(user_status == '2') {
            upgrade_image = '/images/detail/upgrade_vip.gif';
            upgrade_page = '/member/vip_express.shtml';
        } else if(user_status=='3') { // vip
            upgrade_image = '/images/detail/upgrade_svip.gif';
            upgrade_page = '/member/cc_vip_upgrade.htm';
        } else if(user_status=='5') { // super vip
            upgrade_image = '/images/detail/upgrade_svip.gif';
            upgrade_page = '/member/cc_vip_upgrade.htm';
        } else {
            upgrade_image = '/images/detail/detail_join.gif';
            upgrade_page = '/join.html';
        }
    } else {
        upgrade_image = '/images/detail/detail_join.gif';
        upgrade_page = '/join.html';
    }

    document.write('<td width="179" height="60"><a href="' + upgrade_page + '"><img src="' + upgrade_image + '" width="227" height="100" alt="カリビアンコム"></a></td>');
}

function common_makeRequest(url, callback) {
  http_request = null;
  if (window.XMLHttpRequest) {
    http_request = new XMLHttpRequest();
    http_request.onreadystatechange = callback;
    http_request.open("GET", url, true);
    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http_request.send(null);
    // branch for IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    isIE = true;
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
    if (http_request) {
      http_request.onreadystatechange = callback;
      http_request.open("GET", url, true);
      http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      http_request.send(null);
    }
  }
  return;
}

function common_do_it() {
  // (0:uninitialized, 1:loading, 2:loaded, 3:interactive, 4: complete)
  if (http_request.readyState == 4) {
    // (200:ok)
    if (http_request.status == 200) {
      var server_response = http_request.responseText;
  
  //alert("response: " + server_response );

     if (server_response.indexOf('1') != -1) {
          var res = http_request.responseText.split("\n");
          var stop_flag;
          if (res[3]) { stop_flag = res[3]; }
                is_d2p = res[2];
          if (stop_flag == 99) {
                show_popup = 0;
          } else {
                var expiration = res[3];
                site_name_ex = res[4];
                user_type_ex = res[5];

                // re-define "$" 
                $ = function () {
                      var elements = new Array();

                      for (var i = 0; i < arguments.length; i++) {
                          var element = arguments[i];
                          if (typeof element == 'string')
                          element = document.getElementById(element);

                          if (arguments.length == 1)
                              return element;

                          elements.push(element);
                      }

                      return elements;
                }

                myLightbox = new Lightbox();
                myLightbox.start(null);

                return;
          }
      }
    }

    location.href = "/logout.php?id=1";

  }

}


function loginout(){

var redirect_url;

 if( !getCookieRaw('NetiA') )
 {
     top.window.location.href = '/login/login.php?checkAmenity=1&url=' + document.URL;
 }
 else
 { 
    if( (((getCookieRaw('NetiA')).split(":"))[0]).match(/.+@.+\..+/) )
    {
			 top.window.location.href = "/logout.php?id=1";
			 return;	
	   /*    if( getCookie('woman') == '1' )
        {
            location.href = "/logout.php?id=1";
            return;
        }

        // d2pass 
        if( !is_ex_member )
        {
             // re-define "$" 
                $ = function () {
                      var elements = new Array();

                      for (var i = 0; i < arguments.length; i++) {
                          var element = arguments[i];
                          if (typeof element == 'string')
                          element = document.getElementById(element);

                          if (arguments.length == 1)
                              return element;

                          elements.push(element);
                      }

                      return elements;
                }


            myLightbox = new Lightbox();
            myLightbox.start(null);
        }
        else
        {
            common_makeRequest("/member/cgi-bin/coupon2_ex.cgi", common_do_it);
        }
*/
    }
    else
    {
        // dti
        top.window.location.href = '/logout.php?url=' + document.URL;
    }

 }


}


function getUserStatusStr(){

var user_status  = parseInt(getCookie("user_status"));
return  ( getCookie('NetiA')  ) ?
        ( ( user_status == 1 )  ? "メンバー"  :
        ( ( user_status == 2 )  ? "メンバー"  :
        ( ( user_status == 3 )  ? "ＶＩＰ"  :
        ( ( user_status == 5 )  ? "超ＶＩＰ" :
        "ログインはこちらから"
        )))) :
        "ログインはこちらから";
}

function clickJoin(){

 var is_ota_member = ( typeof( window.is_ota_member ) != "undefined" )
                   ? window.is_ota_member : 0;

 var user_status  = parseInt(getCookie("user_status"));
 var redirect_url =  ( getCookie('NetiA')  ) ?
        ( ( is_ota_member == 1 ) ? "/otameshi/upgrade.html" :
        ( ( user_status == 1 )  ? "/member/vip_express.shtml"  :
        ( ( user_status == 2 )  ? "/member/vip_express.shtml"  :
        ( ( user_status == 3 )  ? "/member/cc_vip_upgrade.htm"  :
        ( ( user_status == 5 )  ? "/member/cc_vip_upgrade.htm" :
        "/join.htm"
        ))))) :
        ( ( document.domain == "female.caribbeancom.com" ) 
        ? "/join_women.htm" : "/join.htm" );

  //alert(redirect_url);
  location.href = redirect_url;

}

function footer()
{
    document.write('<script type="text/JavaScript" src="http://tar1.d2pass.com/js/carib.js"><\/script>');
}

function htmlEntities(str) 
{
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

