var historyName
var cookieName = "page_history"   
var cookieInfo
var arr = new Array()
var historyURL = document.URL
var stop_toolbar; //=1 when to stop the d2p toolbar
var d2p_url = 'http://www.d2pass.com/';

function showUserStatus() {
	user_status = getCookie('user_status');
	netia = getCookie('NetiA');
	user_status_name = '';
	if(netia) {
		if(user_status=='1') { 
			user_status_name = '非会員';
		} else if(user_status=='2') {
			user_status_name = '会員';
		} else if(user_status=='3') {
			user_status_name = 'VIP会員';
		}
	}

	if(user_status_name!='') {
		document.write('<li>' + user_status_name + '</a></li><li><a href="/logoff.php"><img src="/images/header/button_logout.gif" width="87" height="19" border="0" /></a></li><li class="spacer"><a href="/logoff.php?id=1">別名でログインする</a></li>');
	} else {
		document.write('<li><a href="/member/login.php?url=' + document.URL + '"><img src="/images/header/login.gif" border="0" ALT="ログイン" /></a></li><li class="spacer"><a href="https://perldesk.dtiserv.com/cgi-bin/up.cgi" target="blank">ID/パスワードを忘れた方</a></li>');
	}
}

function showD2PToolbar() {
  if (stop_toolbar != 1) {
	netia = getCookie('NetiA');
	ml = '';
        if(netia) {
	    cForm = netia.split(":");
	    check = /.+@.+\..+/;
	    if (cForm[0].match(check)) {
		document.write('<div class="d2_toolbar"><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 ><TBODY><TR><TD height=23><IFRAME src="/d2ptb');
		document.write('" frameBorder=0 width="100%" scrolling=no height=23></IFRAME></TD></TR></TBODY></TABLE></div>');
	    }
        }
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function check_password() {
  if(document.orderForm.password.value=="") {
    alert("パスワードを入力してください。");
    document.orderForm.password.focus();
    return false;
  } else {
    document.orderForm.submit();
  }
}

if(historyURL.indexOf('#')>-1){
   historyURL = historyURL.substring(0,historyURL.indexOf('#'))

}


function setCookie (name, value){ 
    document.cookie = name + '=' + escape(value) + ";path=/;" 
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getCookie(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; 
}

var cookieInfo = getCookie("page_history")

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function showHistory(){
          document.write(" <table cellspacing=0 cellpadding=0 width=\"100%\" border=0><tr><td height=\"26\" bgcolor=\"#000000\"><font color=\"#000000\">.</font>")
	  if(cookieInfo){
               	arr = cookieInfo .split("|") 
		for(var i=0; i < arr.length; i++){
			if ( (arr[i].split("::"))[1].indexOf("vote.php", 0) == -1 ){
				if(i+1 == arr.length)
					document.write("<a href="+(arr[i].split("::"))[1]+">"+(arr[i].split("::"))[0]+"</a>") 
				else if((arr[i].split("::"))[0] != "")
					document.write("<a href="+(arr[i].split("::"))[1]+">"+(arr[i].split("::"))[0]+"</a>&nbsp;&nbsp;&nbsp;>&nbsp;&nbsp;&nbsp;")
			}
		}
                
          }
          document.write("</td></tr></table>")
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkHistory(arrLocal){
  for(i=0; i<arrLocal.length; i++){
    strHistory = arrLocal[i]
    strHistoryName = (strHistory.split("::"))[0]
    strHistoryURL = (strHistory.split("::"))[1]
    if(strHistoryURL.indexOf(historyURL) > -1 || ( strHistoryName.indexOf(historyName) > -1 && strHistoryName.length == historyName.length)) return false
  }
   
  return true

}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!historyName){
   historyName = (document.title).replace("カリビアンコム　プレミアム　", "")
   if(historyName.indexOf('#') > -1){
       historyName = historyName.substring(0,historyName.indexOf('#'))
   }
}
if(historyName && historyName != ""){   
    if(cookieInfo){
        arr = cookieInfo .split("|")
        if(checkHistory(arr)){
    		if(arr.length >= 5) 
		        arr = (arr.slice(1,5)).concat(new Array(historyName+"::"+historyURL))
		else 
		    	arr = arr.concat(new Array(historyName+"::"+historyURL))
		    
		    setCookie(cookieName,  (cookieInfo = arr.join("|")))
        }
    
    }    
    else
        setCookie(cookieName, historyName+"::"+historyURL)
}

function MM_showFlash(path, width, height, title) {
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'" tabindex="2" title="'+title+'"><param name="movie" value="'+path+'" /><param name="quality" value="high" /><embed src="'+path+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>');
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function delete_confirm() 
{
    var len = document.forms.delForm.delid.length;
    var count_checked = 0;
    var del_id = "";
  	
    for( i = 0; i < len; i++ ) 
    {
        if ( document.forms.delForm.delid[i].checked == 1 ) 
        {
            if (del_id != "") del_id = del_id + ',';
		
            del_id = del_id + document.forms.delForm.delid[i].value;

            count_checked++;
        }
    }
      
    if( count_checked ) 
    {
        document.forms.delForm.id.value = del_id;
        	
        var flag = confirm( "Ok to remove " + count_checked + " items from cart?");
        	
        if (flag) return true; else return false;
    } 
    else 
    {
        if (!document.forms.delForm.delid.checked) 
        {
            alert('Please select item to remove from cart\n');
            return false;
        } 
        else 
        {
            document.forms.delForm.id.value = document.forms.delForm.delid.value;
            var flag = confirm("OK to remove 1 item from cart?");
            if (flag) return true; else return false;
        }
    }
}

var netiA = getCookie("NetiA");

