function showLogin() {
	if(document.getElementById('overlay').style.visibility != 'visible') {
                var login = document.getElementById('login');

                OnWindowResize();

		document.getElementById('overlay').style.visibility = 'visible';
                document.getElementById('overlay').style.display = 'block';

		login.style.visibility = 'visible';
		login.style.display = 'block';

               document.getElementById('username').focus();

               if (window.attachEvent) 
		    window.attachEvent('onresize', OnWindowResize); 
               else if (window.addEventListener) 
    		    window.addEventListener('resize', OnWindowResize, false);
 	       else
		    window.onresize = OnWindowResize;
	
  	       if (document.all) 
		    document.documentElement.onscroll = OnWindowResize;


	} else {
		document.getElementById('overlay').style.visibility = 'hidden';
		document.getElementById('overlay').style.display = 'none';

		document.getElementById('login').style.visibility = 'hidden';
		document.getElementById('login').style.display = 'none';

                if (window.detachEvent)
		      window.detachEvent('onresize', OnWindowResize);
           	else if (window.removeEventListener)
		      window.removeEventListener('resize', OnWindowResize, false);
                else
            		window.onresize = null;
       }
}

function showWorking() {
	if(document.getElementById('overlay').style.visibility != 'visible') {
                var login = document.getElementById('working');

                OnWindowResizeWorking();

		document.getElementById('overlay').style.visibility = 'visible';
		document.getElementById('overlay').style.display = 'block';
		login.style.visibility = 'visible';
		login.style.display = 'block';

               if (window.attachEvent) 
		    window.attachEvent('onresize', OnWindowResizeWorking); 
               else if (window.addEventListener) 
    		    window.addEventListener('resize', OnWindowResizeWorking, false);
 	       else
		    window.onresize = OnWindowResizeWorking;
	
  	       if (document.all) 
		    document.documentElement.onscroll = OnWindowResizeWorking;


	} else {
		document.getElementById('overlay').style.visibility = 'hidden';
		document.getElementById('overlay').style.display = 'none';
		document.getElementById('working').style.visibility = 'hidden';
		document.getElementById('working').style.display = 'none';

                if (window.detachEvent)
		      window.detachEvent('onresize', OnWindowResizeWorking);
           	else if (window.removeEventListener)
		      window.removeEventListener('resize', OnWindowResizeWorking, false);
                else
            		window.onresize = null;
       }
}

function OnWindowResize()
{
        var divwidth;
        divwidth = 471;
        var divheight;
        divheight = 243;
	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
        var div = document.getElementById('login');
	div.style.left = Math.max((left + (getWindowWidth() - divwidth) / 2), 0) + 'px';
	div.style.top = Math.max((top + (getWindowHeight() ) / 2) - divheight , 0) + 'px';

}

function OnWindowResizeWorking()
{
        var divwidth;
        divwidth = 471;
        var divheight;
        divheight = 170;

	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
        var div = document.getElementById('working');
	div.style.left = Math.max((left + (getWindowWidth() - divwidth) / 2), 0) + 'px';
	div.style.top = Math.max((top + (getWindowHeight() ) / 2  - divheight), 0) + 'px';
}

function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight)=='number') {
windowHeight=window.innerHeight;
}
else {
if (document.documentElement&&
document.documentElement.clientHeight) {
windowHeight=
document.documentElement.clientHeight;
}
else {
if (document.body&&document.body.clientHeight) {
windowHeight=document.body.clientHeight;
}
}
}
return windowHeight;
}


function getWindowWidth() {
var windowWidth=0;
if (typeof(window.innerWidth)=='number') {
windowWidth=window.innerWidth;
}
else {
if (document.documentElement&&
document.documentElement.clientWidth) {
windowWidth=
document.documentElement.clientWidth;
}
else {
if (document.body&&document.body.clientWidth) {
windowWidth=document.body.clientWidth;
}
}
}
return windowWidth;
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
domain = ".adgooroo.com";

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}		

createNotes=function(){

            showNote=function(){
                        // gets corresponding note element id
                        var id=this.id.replace(/a/,'note');
                        note=document.getElementById(id);
                        // assigns X,Y mouse coordinates to note element
                        var coors = findPos(this);
                        note.style.left=coors[0] + 20 + 'px';
                        note.style.top=coors[1] + 'px';
                        // makes note element visible
                        note.style.visibility='visible';
            }

            hideNote=function(){ 
                        // gets corresponding id for note element
                        var id=this.id.replace(/a/,'note');
                        note=document.getElementById(id);
                        // hides note element
                        note.style.visibility='hidden';
            }

            // gets all <a> elements 
            as=document.getElementsByTagName('a');
            // iterates over all <a> elements
            for(i=0;i<as.length;i++){
                        // assigns mouse event handlers to <a> elements with class name "special"
                        if(/\bspecial\b/.test(as[i].className)){
                                    // shows note element when mouse is over 
                                    as[i].onmousemove=showNote;
                                    // hides note element when mouse is out
                                    as[i].onmouseout=hideNote;
                        }
            }
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function showtab(tabname, liname) {

    document.getElementById("overview").style.visibility = "hidden";
    document.getElementById("overview").style.display = "none";
    document.getElementById("features").style.visibility = "hidden";
    document.getElementById("features").style.display = "none";
    document.getElementById("support").style.visibility = "hidden";
    document.getElementById("support").style.display = "none";
    document.getElementById("screenshots").style.visibility = "hidden";
    document.getElementById("screenshots").style.display = "none";


    document.getElementById(tabname).style.visibility = "visible";
    document.getElementById(tabname).style.display = "block";

    document.getElementById('taboverview').setAttribute("class", "");
    document.getElementById('taboverview').setAttribute("className", "");
    document.getElementById('tabfeatures').setAttribute("class", "");
    document.getElementById('tabfeatures').setAttribute("className", "");
    document.getElementById('tabsupport').setAttribute("class", "");
    document.getElementById('tabsupport').setAttribute("className", "");
    document.getElementById('tabscreenshots').setAttribute("class", "");
    document.getElementById('tabscreenshots').setAttribute("className", "");

    document.getElementById(liname).setAttribute("class", "current");
    document.getElementById(liname).setAttribute("className", "current");

}

function trim(sString) 
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function validated(string) {
    for (var i=0, output='', valid="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
} 

function validated0(string) {
    for (var i=0, output='', valid=" _-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
} 


function validated2(string) {
    for (var i=0, output='', valid=" _-+=;:?!@#$%^&*().~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
} 

function validated3(string) {
    for (var i=0, output='', valid=" +-()0123456789"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
} 

function validated4(string) {
    for (var i=0, output='', valid=" -'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
} 

function validated5(string) {
    for (var i=0, output='', valid=" 0123456789"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
}

var xmlHttp;

function ajaxFunction()
  {  

     try
       {    
          // Firefox, Opera 8.0+, Safari    
          xmlHttp=new XMLHttpRequest();    
       }
       catch (e)
      {    
          // Internet Explorer    
          try
             {      
                 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
             }
         catch (e)
         {      
            try
              {        
                  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
              }
             catch (e)
             {        
                  alert("You must enable javascript to use this site.");        
                  return false;        
             }      
         }    
      }  

    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        ajaxhandler();
        }
      }

    xmlHttp.open("POST","/publish2/default.aspx",true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    var params = '';
  
    for(i=0; i < document.validate.elements.length; i++) {
       params += document.validate.elements[i].name + "=" + document.validate.elements[i].value + "&";
    }
   
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.send(params);
}


// Credit card validation code

function Mod10(ccNumb) {  // v2.0
var valid = "0123456789"  // Valid digits in a credit card number
var len = ccNumb.length;  // The length of the submitted cc number
var iCCN = parseInt(ccNumb);  // integer of ccNumb
var sCCN = ccNumb.toString();  // string of ccNumb
sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
var iTotal = 0;  // integer total set at zero
var bNum = true;  // by default assume it is a number
var bResult = false;  // by default assume it is NOT a valid cc
var temp;  // temp variable for parsing string
var calc;  // used for calculation of each digit

// Determine if the ccNumb is in fact all numbers
for (var j=0; j<len; j++) {
  temp = "" + sCCN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1"){bNum = false;}
}

// if it is NOT a number, you can either alert to the fact, or just pass a failure
if(!bNum){
  bResult = false;
}

// Determine if it is the proper length 
if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
  bResult = false;
} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
  if(len >= 15){  // 15 or 16 for Amex or V/MC
    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
      calc = parseInt(iCCN) % 10;  // right most digit
      calc = parseInt(calc);  // assure it is an integer
      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
      i--;  // decrement the count - move to the next digit in the card
      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
      calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
      calc = calc *2;                                 // multiply the digit by two
      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
      switch(calc){
        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
      }                                               
    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
    iTotal += calc;  // running total of the card number as we loop
  }  // END OF LOOP
  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
    bResult = true;  // This IS (or could be) a valid credit card number.
  } else {
    bResult = false;  // This could NOT be a valid credit card number
    }
  }
}

  return bResult; // Return the results
}

