
function commentsSubmit() {

 with (document.quickcomments) {
   if ( (comments.value.length < 20) || (comments.value.indexOf('Have comments on our site? Please let us know here!')>-1) ) {
     alert('Please enter your comments (of at least 20 characters) and submit again.');
     return false;
   }
   else {
     if (name.value == "") name.value = "Anonymous";
     return true;
   }
 }

}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function GetLastModified(){

  var a,lm_year,lm_month,lm_day;
  a=new Date(document.lastModified);
  lm_year=a.getYear();lm_year=((lm_year<1000)?((lm_year<70)?2000:1900):0)+lm_year;
  lm_month=a.getMonth()+1;lm_month=((lm_month<10)?'0':'')+lm_month;
  lm_day=a.getDate();lm_day=((lm_day<10)?'0':'')+lm_day;
  return lm_year+'-'+lm_month+'-'+lm_day;

}


function GetCurDate() {

var today = new Date();
var date = today.getDate();
var day = today.getDay();
var month = today.getMonth();
var year = today.getYear();
var dayName;
var daySuffix;
var monthName;

if (day == 0) dayName = "Sunday";
else if (day == 1) dayName = "Monday";
else if (day == 2) dayName = "Tuesday";
else if (day == 3) dayName = "Wednesday";
else if (day == 4) dayName = "Thursday";
else if (day == 5) dayName = "Friday";
else if (day == 6) dayName = "Saturday";

if (month == 0) monthName = "January";
else if (month == 1) monthName = "February";
else if (month == 2) monthName = "March";
else if (month == 3) monthName = "April";
else if (month == 4) monthName = "May";
else if (month == 5) monthName = "June";
else if (month == 6) monthName = "July";
else if (month == 7) monthName = "August";
else if (month == 8) monthName = "September";
else if (month == 9) monthName = "October";
else if (month == 10) monthName = "November";
else if (month == 11) monthName = "December";

return (dayName + " " + monthName + " " + date + ", " + year);

}

function popUp (sURL, sName, x, y, dx, dy) {
	window.open(sURL, sName, 'left='+x+',top='+y+',width='+dx+',height='+dy+',scrollbars=1,resizable=1');
}

function GoURL(s){
  document.location = s;
}

function Add2Fav(){
  if (document.all)
    window.external.AddFavorite(document.location.href,document.title)
}

function OpenPreview(s_url) {
  var w_s = 50;
  var h_s = 50;
  var w = window.screen.width;
  var h = window.screen.height;
  popUp(s_url,'PreviewWin', w_s, h_s, w-2*w_s, h-2*h_s-50);
}

function OpenImages(id,f){
  OpenPreview('index.php?page=images&id='+id+'&f='+f);
}

function hwReloadCat(page,cid,hwJsCats){

  var catbox = document.frm.cid;
  var new_cid = catbox.options[catbox.selectedIndex].value;
  var f1,f2,s1,s2;
  s1 = '|' + new_cid + '|';
  s2 = '|' + cid + '|';
  
  for (i = 0; i < hwJsCats.length; i++) {
    f1 = hwJsCats[i].indexOf(s1) != -1;
    f2 = hwJsCats[i].indexOf(s2) != -1;
    if(f1 && f2) return;
    if(f1 || f2) break;
  }
  
  var ch_sep = page.indexOf('?') != -1 ? '&' : '?';  
  document.location = page + ch_sep + 'cid=' + new_cid;
}
//######################### COOKIE INFORMATION ###########################
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
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" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
