// first thing to do is see if it is the mobile verion; hence, onLoad in body. If yes: give warning
	 function checkscreen(){
	 if ( (location.search.substring(1,4)=='mob') && (self.screen.width>500)) {   
	 		alert("This page is designed for a small screen like a mobile phone.\nIt will not display properly on a full sized monitor");}
	 		// photo();
 } // end of function

// naviation script
	 function loadimages(){
			 					home = new Image ; home.src="./nav_images/home.jpg";
			 				  news = new Image ; news.src="./nav_images/news.jpg";
								parents = new Image ; parents.src="./nav_images/parents.jpg";
								knife = new Image ; knife.src="./nav_images/knife.jpg";
								links2 = new Image ; links2.src="./nav_images/links.jpg";							
								sponsors = new Image ; sponsors.src="./nav_images/sponsors.jpg";
								law = new Image ; law.src="./nav_images/law.jpg";
								need = new Image ; need.src="./nav_images/need.jpg";
								contact = new Image ; contact.src="./nav_images/contact.jpg";
								info = new Image ; info.src="./nav_images/info.jpg";
			 					}
			 
			 function checkload(){
			 					if (info.complete == false);
								setTimeout("checkload()", 100);
			 					}
								
			 function nav(page){
			 switch (page){
			 case "home" : document.picture.src=home.src; document.getElementById('nav_text').innerHTML='What we do'; break;
			 case "news" : document.picture.src=news.src; document.getElementById('nav_text').innerHTML='Keep up to date'; break;
			 case "parents" : document.picture.src=parents.src; document.getElementById('nav_text').innerHTML='Family Support'; break;
			 case "knife" : document.picture.src=knife.src; document.getElementById('nav_text').innerHTML='Map of knife bins'; break;
			 case "links2" : document.picture.src=links2.src; document.getElementById('nav_text').innerHTML='Other websites'; break;
			 case "sponsors" : document.picture.src=sponsors.src; document.getElementById('nav_text').innerHTML='Ways to support us'; break;
			 case "law" : document.picture.src=law.src; document.getElementById('nav_text').innerHTML='Law and consequences'; break;
			 case "need" : document.picture.src=need.src; document.getElementById('nav_text').innerHTML='The exchange'; break;
			 case "contact" : document.picture.src=contact.src; document.getElementById('nav_text').innerHTML='Get in touch'; break;
			 case "info" : document.picture.src=info.src; document.getElementById('nav_text').innerHTML='What else is available'; break;
			 default : alert (page + "error - please report it to contact us page");}
			 }		

// popup for Print Preview
	 var printpreview = "To save your black ink cartridge(!) the print version is different from the screen version.";
	 printpreview += "\nUse \'Print Preview\' on your computer; or just print a page.";
	  
// rotate images for sponsors page
	 // check if mobile version to select correct array: if it is a mobile then ?mob=mob so query length>0 but said 3 incase .php# (top of page)
	 		if (location.search.length>5){ var adImages = new Array("./images/sponsors100.jpg", "./images/sponsors2100.jpg"); // ie adImages[0], adImages[1]
	 		}else{
	 		var adImages = new Array("./images/sponsors200.jpg", "./images/sponsors2200.jpg");
	 		} // end of if
	 
	 var thisAd = 0; //start at zero
	 
	 function rotate(){
	 thisAd++; 
	 
	 if (thisAd == adImages.length){
	 thisAd=0;} // re-set to zero when reach total number of images
	 
	 document.getElementById("more").src = adImages[thisAd]; // insert into socument, the src = the number in the array
	 setTimeout("rotate()", 20 * 1000); // 20 seconds
	 
	 } // close function 

	 
// stylehseet changer
	 function setActiveStyle(option){
	 
	 linksFound = document.getElementsByTagName("link"); // each one becomes an array element
	 for(i=0; i<linksFound.length; i++){
	    thislink = linksFound[i];
						
			if (thislink.getAttribute("rel").indexOf("style")>-1){  // the book said add this: && thislink.getAttribute("title")){
				  thislink.disabled = true; // disable all links..then...
			
					if (thislink.getAttribute("title") == option){ 
					thislink.disabled = false; // enable the style sheet with the correct title (which overides the default one). 

			}}}}// close all the parameters
			
			
// change .src of every photo, (since nav photos with 100.jpg dont exist & hidden not downloaded or displayed)
// not used as loads 200px first then changes them - php only loads the 100px
	 function photo(){
	 photosFound = document.getElementsByTagName("img");
	 for (j=0; j<photosFound.length; j++){ // for each photo
	 		 thisphoto = photosFound[j].src; // get the src for the current photo
			 thisphoto = thisphoto.replace(/200/, "100"); // change src from 200.jpg to 100.jpg
			 photosFound[j].src = thisphoto;  // replace the photo
		}}


// change font colour
	 function cc(which){
	 
	 if (confirm ("This will change "+which.toUpperCase()+" colour.\n Have the RGB number ready for the colour you want.\n If not ready, or dont know what that means then cancel."))
	 { // do the following if confirm is true
	 
	 var rgb = prompt("Enter EXACTLY in format: RRR,GGG,BBB (commas between numbers)\nIf r=090, g=010, b=233 Enter: 090,010,233");
	 var re = /^[0-2][0-9][0-9],[0-2][0-9][0-9],[0-2][0-9][0-9]$/;
	 var lessthan = rgb.split(",");
	 	 
	 if (!re.test(rgb) | lessthan[0]>255 | lessthan[1]>255 | lessthan[2]>255){ // wrong format
	 alert ("Sorry, either:\n Format is wrong, or\n Numbers do not relate to a colour");
	 
	 }else{ // right in right format
	 			rgb = "rgb(" + rgb + ")"; 
	 			if (which=='font'){document.getElementById("content").style.color = rgb;
				}else{ // must be which = title
	 			var h1=document.getElementsByTagName("h1");h1[0].style.color = rgb; // since there is only 1 h1
	 			var h2=document.getElementsByTagName("h2");h2[0].style.color = rgb; // as above
				
						// for title also change the border to match the title
						for (i=0; i< document.getElementsByTagName("div").length; i++){   	 // loop through all the divs
						if (document.getElementsByTagName("div")[i].className == 'mugshot'){ // when you get to the one with the right class, are know you are at the right element 
		 				var newborder = "2px solid " + rgb; 										 						 // get the new property ready in the form of a string
						document.getElementsByTagName("div")[i].style.border = newborder;		 // put the property into the style sheet
						}} // end of this little section
	 			} // end of else (must be title)
	 } // end of else (didn't work)
	 
	 }else{return false;} // the confirm message was not evaluated as true
	 } // end of function

// see if being displayed on mobile screen or not
	 function checkscreensize(){
	 if(self.screen.width>500){
	 alert("This page is designed for a small screen like a mobile phone.\nIt will not display properly on a full sized monitor");}
	 } // end function
	 
// redirect to full screen from mobile version navigation
	 function fullscreen() {
	 var url = location.href.split("?"); // get the url without the ?mob=mob
	 url = url[0];
	 window.location = url; // reload the page with the new href
	 } // end function

// redirect to mobile screen
	 function mobileversion(){
	 var url = location.href;
	 url = url + "?mob=mob";
   window.location = url;
	 } // end function
			 
