//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();
  }
}

//Rotates home page gallery images
var c = 0;
var s;
function photoGallery()
{
 	if (c % 19 === 1) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Animal_A.jpg"; }
    if (c % 19 === 2) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Lifestyle_A.jpg"; }
    if (c % 19 === 3) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Animal_B.jpg"; }
    if (c % 19 === 4) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Garden_A.jpg"; }
    if (c % 19 === 5) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Lifestyle_B.jpg"; }
    if (c % 19 === 6)
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Animal_D.jpg"; }
    if (c % 19 === 7)
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Lifestyle_D.jpg"; }
    if (c % 19 === 8)
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Animal_C.jpg"; }
    if (c % 19 === 9) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Landscape_B.jpg"; }
    if (c % 19 === 10) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Lifestyle_C.jpg"; }
    if (c % 18 === 11) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Animal_F.jpg"; }
    if (c % 19 === 12) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Animal_E.jpg"; }
	if (c % 19 === 13)
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Model_A.jpg"; }
    if (c % 19 === 14) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Model_B.jpg"; }
    if (c % 19 === 15) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Promotional_A.jpg"; }
	if (c % 19 === 16)
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Promotional_B.jpg"; }
    if (c % 19 === 17) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Landscape_A.jpg"; }  
	if (c % 19 === 18) 
       { document.getElementById('photo-gallery1').src = "Web_Site_images/Home_Gallery/Garden_B.jpg"; c = 0; }
    c = c + 1; 
    s = setTimeout("photoGallery()",5000);
} 
//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/PhotographYourWorld_banner_R.gif',
	'Icons/drop_button1.gif', 'Icons/drop_button1.gif', 'Icons/menu_button1.gif', 'Icons/menu_button2.gif','Web_Site_images/Link_photos/model1.gif', 
	'Icons/single_button1.gif','Icons/single_button1.gif' );

//Gets user login details
var nameSW, passwordSW,orderformtype; 
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)
  { 
   orderformtype = orderform[i];
	window.name = orderformtype;//passes variable to next window
   location.href = "_private/client_gallery_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 Photograph Your World in order for us to issue valid Login details.');
  location.href = "Client_login_page.htm";
  }
 }

//Selects correct order form
 function Order_Form(orderformtype)
 {
  orderformtype=(window.name); 

  if ( orderformtype === "lifestylePMC" )
	{
	window.open ("Order_forms/Lifestyle/Lifestyle_print_canvas_order_form.pdf",'_blank');
	}
 	else
	{
  	if ( orderformtype === "commercial" )
		{
		window.open ("Order_forms/Commercial/Commercial_order_form.pdf",'_blank');
		}
		else
			{
  			if ( orderformtype === "charity" )
				{
				window.open ("Order_forms/Charity/Charity_order_form.pdf",'_blank');
				}
			else
				{
				if ( orderformtype === "lifestyleCroft" )
					{
					window.open ("Order_forms/Lifestyle/lifestyleCroft_print_canvas_order_form.pdf",'_blank');
					}
				else
					{
					alert ("Sorry there is no order form for this gallery. Please contact Photograph Your World by e-mail, through the contact us button.")
					}
				}		
			}
	 } 
 }

//Checks login details exist against file then opens client gallery 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 = 'client_images/' + loginname + '/' + loginpassword + '.html';

if (parent.frame1)
  { 
  parent.frame1.location.href = gallerypath;
  }  
 }
//Hides email
function contact() {
 var string1  ="enqu";
 var string2 ="iries";
 var string3 ="@";
 var string4 ="photograph-";
 var string5 ="your-";
 var string6 ="world.";
 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 - Photograph Your World.";
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;
    }
}


