/* TRANSLATE */
function translator(pattern)
{ 
  window.open('http://www.google.com/translate?u=http://'+ location.host + location.pathname +'&langpair='+ pattern +'&hl=en&ie=UTF8','subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0'); 
}

/* HELLP SUGGESTION VALIDATION FUNCTION */
function validateForm() { 
 var name = document.HelpSuggest.description.value; 
 if (name == "") { 
   alert("Please provide a detailed description of your proposed addition to this page, or new help topic."); 
   return false; 
 } else thanks();return true;
}

var putItThere = null; 

var chasm = screen.availWidth;
var mount = screen.availHeight;
function thanks() {
  putItThere = window.open('http://trackerhelp.serengetilaw.com/0734Hlp/Thanks.htm','posB','width=310,height=200,left=' + ((chasm - 300) * .5) + ',top=' + ((mount - 270) * .5));
}

/* EMAIL THIS PAGE FUNCTION */
function EmailLink() 
{
var subject = "Tracker Help: ";
var title = document.title
var page = window.location;
var doc = "mailto:?subject=" + escape(subject) + escape(title) + "&body=ADDRESS:%0D%0A" + escape(page); 
window.location = doc.substr(0,255);
}

/* BG-IMAGE SWAP FUNCTION */
function StringArray (n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = ' '
  }
}
image = new StringArray(5)
image[0] = 'https://trackerhelp.serengetilaw.com/images/000.jpg'
image[1] = 'https://trackerhelp.serengetilaw.com/images/001.jpg'
image[2] = 'https://trackerhelp.serengetilaw.com/images/002.jpg'
image[3] = 'https://trackerhelp.serengetilaw.com/images/003.jpg'
image[4] = 'https://trackerhelp.serengetilaw.com/images/004.jpg'
image[5] = 'https://trackerhelp.serengetilaw.com/images/005.jpg'
image[6] = 'https://trackerhelp.serengetilaw.com/images/006.jpg'
var ran = 60/image.length
function ranimage() {
  currentdate = new Date()
  core = currentdate.getSeconds()
  core = Math.floor(core/ran)
    return(image[core])
}

/* OPEN WINDOW */
function openwindowlink(link) {
newwin = window.open(link,"windowname","height=530,width=772,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,")
}

function openbigwindowlink(link) {
newwin = window.open(link,"windowname","height=604,width=904,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,")
}

/*ADITI - Function to recognise Safari browser - IE/FF and Safari handled separately 2/12/2011*/
function IsSafari() {
    if (navigator.userAgent.toLowerCase().indexOf('safari/') > -1)
        return true;
    return false;
}

/*ADITI - Function to recogise IE browser (Any version)*/
function IsIE() {
    if(navigator.appName == 'Microsoft Internet Explorer')
        return true;
    return false;
}

/*ADITI - Function to bookmark current page - IE/FF and Safari handled separately 2/12/2011*/
function CreateBookmark(url, title) {
    if (IsSafari()) {
        alert("Press CTRL-D to add this page to your bookmarks list.");
    }
    else {
        // Mozilla Firefox Bookmark
        if (window.sidebar) {
            window.sidebar.addPanel(title, url, "");
        }
        // IE Add to Favorite	
        else if (window.external) {
            window.external.AddFavorite(url, title);
        }
        else {
            //ADITI:TODO- Need to add default message here?
        }
    }

}

/*List all functions that need to be called on Page load*/
function ContentPageLoad() {
    EnableBookmarkInIE();
    FooterUI();
}

/*UI changes to page*/
function FooterUI() {
    if (IsSafari()) {
        /*The footer UI width had to be changed for Safari*/
        var needHelpSection = document.querySelector('td.need');
        if (needHelpSection != null && needHelpSection != undefined) {
            needHelpSection.width = 149;
        }
    }
}

/*Disable bookmark in Safari & FF*/
function EnableBookmarkInIE() {
   if(IsIE()){
        if(document.getElementById('imgBookmark') != null && document.getElementById('imgBookmark') != undefined){
            document.getElementById('imgBookmark').style.display = '';
        }
    }
}

