﻿// JavaScript File
// **Copyright Alphatask Ltd UK & Worldwide Craig kelly-soens-hughes**
function doGetQueryString( name )
{//credit to http://www.netlobo.com/url_query_string_javascript.html
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
      return "";
    else
      return results[1];
}

function doGetAllParameters()
{
	var sURL = new String(window.location);
  	var iQMark= sURL.indexOf('?');
	return sURL.slice(iQMark+1);
}

function BlinkThis() {
 if (!document.all)//make sure IE as firefox has a  blink  in-built
    return;
 else {
   for(i=0;i<document.all.tags('Blink').length;i++){
      s=document.all.tags('Blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}

function doToggleMenu(itemName)
{
    var vElement = document.getElementById(itemName);
    if (vElement.style.display == 'block')
        vElement.style.display='none';
    else 
        vElement.style.display='block';
    
    return false;
}

var IE = (window.clipboardData);
var win = window;// window to search. 
var n = 0;
var bScrolled=false;
function findinpage(str){
    //numtimes=0; no no no or no repeat searches
    if (bScrolled==false) {win.scroll(0,450); bScrolled=true;}
    var txt, i, found;
    if (str == "") return false;
    str=str.toLowerCase();
    // Find next occurance of the given string on the page, wrap around to start of the page if necessary. 
    if (!IE){
        // Look for match starting at the current point. If not found, rewind back to the first match. 
        if (!win.find(str))
           while(win.find(str, false, true))
              n++;
        else
          n++;// If not found in either direction, give message. 
        if (n == 0)
          alert("Not found.");
    }
    if (IE){
        txt = win.document.body.createTextRange();
        // Find the Nth match from the top of the page
        for (i = 0; i <= n && (found = txt.findText(str, 1, 0)) != false; i++){
          txt.moveStart("character", 1); 
          txt.moveEnd("textedit");
        } 
        if (found){// If found, mark it and scroll it into view.
           txt.moveStart("character", -1);
           txt.findText(str); 
           txt.select();
           txt.scrollIntoView();
           n++;
        }else{// Otherwise, start over at the top of the page and find first match. 
          if (n > 0){
            n = 0; findinpage(str); 
          } 
          else // Not found anywhere, give message.
            alert("Not found.");
        }
    } 
    return false;
} 
