var historyName
var cookieName = "page_history"   
var cookieInfo
var arr = new Array()
var historyURL = document.URL

function showUserStatus() {

	user_status = getCookie('user_status');
	netia = getCookie('NetiA');

	if(netia) {
		document.write('<li><a href="/eng/logoff.php"><img src="/eng/images/logoff.gif" width="87" height="19" border="0" /></a></li>');
	} else {
		document.write('<li><a href="/eng/member/login.php?url=' + document.URL + '"><img src="/eng/images/login.gif" border="0" ALT="Login" /></a></li><li><a href="https://perldesk.dtiserv.com/cgi-bin/up.cgi?lang=en" target="blank">Forgot Password??</a></li>');
	}
}

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("Caribbeancom Premium ", "")
   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[0].delid.length;
  	var count_checked = 0;
	var del_id = "";
  	for (i=0; i < len; i++ ) {
    	if ( document.forms[0].delid[i].checked == 1 ) {
		if (del_id != "") del_id = del_id + ',';
		del_id = del_id + document.forms[0].delid[i].value;
                count_checked++;
        }
      }
      if (count_checked) {
		document.forms[0].id.value = del_id;
        	var flag = confirm("delete " + count_checked + " movies from shopping cart?");
        	if (flag) return true; else return false;
      } else {
		if (!document.forms[0].delid.checked) {
        		alert('Please check movies which you want to delete\n');
          		return false;
		} else {
			document.forms[0].id.value = document.forms[0].delid.value;
        		var flag = confirm("delete 1 movies from shopping cart?");
        		if (flag) return true; else return false;
		}
      }
}

var netiA = getCookie("NetiA");

