//checks current year
function copyDate() {
  var cpyrt1 = document.getElementById("copyright1")
  var cpyrt2 = document.getElementById("copyright2")
  if (cpyrt1) {
     cpyrt1.firstChild.nodeValue = (new Date()).getFullYear();
  }
  if (cpyrt2) {
     cpyrt2.firstChild.nodeValue = (new Date()).getFullYear();
  }
}

//Pre loads home page gallery images
var preloaded = new Array();
function preload_images() {
  for (var i = 0; i < arguments.length; i++) {
      preloaded[i] = document.createElement('img');
      preloaded[i].setAttribute('src', arguments[i]);
    }
}
preload_images('Icons/bottom.gif', 'Icons/top.gif', 'Icons/vertical.gif', 'Icons/Potential4Success_banner_R.gif' );

//Gets user login details
var nameSW, passwordSW; 
var nameSW, passwordSW; 
var i = 0;
nameSW = false;
passwordSW = false;
function login() 
 {
 var loginname = document.clientlogin.username.value;
 	 loginname = loginname.toLowerCase();
 var loginpassword = document.clientlogin.password.value;
 	 loginpassword = loginpassword.toLowerCase();
  for (i=0; i<names.length; i++)
  {
   if (loginname === names[i]) 
    {
    nameSW = true; break; 
    }
  }
 if (loginname === names[i]) { nameSW = true; }
 if (loginpassword == passwords[i]) { passwordSW = true; }
 
 //if in list goto client_gallery_page.htm if not re-load page
  if (nameSW && passwordSW)
  { 
   location.href = "_private/Client_Library_Link_page.htm" + '?' + loginname + '&' + loginpassword;
  }
 else
  {
  if (loginname.length === 0) {
  alert("You must enter a username.");
  return false;
 }

 if (loginpassword.length === 0) {
  alert("You must enter a password.");
  return false;
 }
  alert('We are sorry that ' + loginname + ' and ' + loginpassword + ' are not valid. If you should be allowed access, please contact Potential 4 Success in order for us to issue valid Login details.');
  location.href = "Client_login_page.htm";
  }
 }
//Checks login details exist against file then opens client Library page 
function GetPassedData() {
 var start = location.search.indexOf('?');
 var end   = location.search.indexOf('&');
 var loginname = location.search.substring(start+1,end);
 var loginpassword = location.search.substring(end+1);
 var gallerypath = '_private/Client_Library_Link_page.htm';

if (parent.frame1)
  { 
  parent.frame1.location.href = gallerypath;
  }  
 }
//Hides email
function contact() {
 var string1  ="enqu";
 var string2 ="iries";
 var string3 ="@";
 var string4 ="potential-";
 var string5 ="4-";
 var string6 ="success.";
 var string7 ="co.uk";
 var string8 = string1 + string2 + string3 + string4 + string5 + string6 + string7;
 location.href="mail" + "to:" + string8;
}
//Prints selected window
function printpage() { window.print(); }
//Disables mouse right click function
var message = "Right Click Function Disabled! Copyright Protection - Potential 4 Success.";
function clickIE4() {
 if (event.button === 2) {
    alert(message);
    return false;
    }
}
function clickNS4(e) {
 if (document.layers || document.getElementById && ! document.all) {
    if (e.which === 2 || e.which === 3) {
	alert(message);
	return false;
       }
    }
}
if (document.layers) {
   document.captureEvents(Event.MOUSEDOWN);
   document.onmousedown = clickNS4;
}
else if (document.all && ! document.getElementById) {
	document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("alert(message); return false");
function Drop_Down_Menu() {
  if (navigator.appVersion.indexOf("MSIE") === -1)
     {
     return;
     }
     var i,k,g,lg,r=/\s*hvr/,nn='',c,cs='hvr',bv='dropmenu';
     for(i=0;i<10;i++)
 	{
  	g = document.getElementById (bv+nn); if (g)
 	  {lg = g.getElementsByTagName("LI");if (lg)
 		{
 		for(k = 0; k < lg.length; k++)
 	              {
 		      lg[k].onmouseover  =function()
 			{
 			c = this.className; cl = (c)?c+' '+cs:cs;
			this.className = cl;
			};
		          lg[k].onmouseout = function()
		 	     {
		 	     c = this.className;
		 	     this.className = (c)?c.replace(r,''):'';
		 	     };
		 	}
		 }
	}
     nn = i + 1;
    }
}



