<!--
function getCookie(name){
 var cookie=""+document.cookie;
 var search=""+name+"=";
 var setStr=null;
 var offset=0;
 var end=0;
 if(cookie.length>0) {
   offset=cookie.indexOf(search);
   if(offset!= -1) {
     offset+=search.length;
     end=cookie.indexOf(";",offset);
     if(end == -1) {
       end=cookie.length;
     }
     setStr=unescape(cookie.substring(offset,end));
   }
 }
 //if(setStr!=null)alert(setStr);
 //else alert('null')
 return(setStr);
}
//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function track(){
 var cookiename="count";
 var count=getCookie(cookiename);
 if(count){
   count=parseInt(count)+1;
   SetCookie(cookiename,count);
   //return (count-1);
 }
 else { count=1;
   SetCookie(cookiename,count);
   //return null;
 }
 return count;
}

function trackfile(){
 var file=""+document.location+"";
 var where=file.lastIndexOf("/")+1;
 var file=file.substring(where,file.length);
 var cookiename=file;
 var count=getCookie(cookiename);
 if(count){
   count=parseInt(count)+1;
   SetCookie(cookiename,count);
   //return (count-1);
}
 else { count=1;
   SetCookie(cookiename,count);
   //return null;
 }
 return count;
}

// show only done once, when the site/page is first accessed
function windowopenonce(url_file){
  var test=track();
  if(test==1){
    window.open(url_file,"","scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=625,height=433");
  }
}

// pop will keep popping everytime the page is accessed
function windowopen(url_file){
    window.open(url_file,"","scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=640,height=480");
}

// show the window with any different window name everytime the page is accessed.
function windowsizeopen(url_file,w,h,fname){
    window.open(url_file,fname,"scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",screenx=0,screeny=0");
}

function windowsizeopenonce(url_file,w,h,fname){
  var test=trackfile();
  if(test==1){
    window.open(url_file,fname,"scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+"");
  }
}
// show window with position control:center, pop up only when accessed the first time.
function windowpositiononce(url_file,w,h,fname,pos){
  var test=trackfile();
  if(test==1){
    x=parseInt((screen.width-w)/2);
    y=parseInt((screen.height-h)/2);
    window.open(url_file,fname,"scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",screenX="+x+",screenY="+y+"");
  }
}
function windowposition(url_file,w,h,fname,pos){
  x=parseInt((screen.width-w)/2);
  y=parseInt((screen.height-h)/2);
  window.open(url_file,fname,"scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",screenX="+x+",screenY="+y+"");
}

function redirect(url1,url2){
  var test=track();
  if(test%2 == 0){
     window.location.href=url1;
  }
  else window.location.href=url2;
}

function popcookie(name){
  var msg=getCookie(name);
  alert('cookie:'+name+'='+msg);
}

function clearcount(){
  var cookiename="count";
  var sess=getCookie('session');
  //alert(sess);
  if(sess == null){
     SetCookie(cookiename,null);
  }
  //else SetCookie(cookiename,0);
  var countcookie=getCookie(cookiename);
  //alert(countcookie);
  document.forms[0].elements[0].focus();
  return true;
}
//-->

