function pdfme(){
var links = document.getElementsByTagName("a");
for (var eleLink=0; eleLink < links.length; eleLink ++) {
	//alert(links.length);
	if (links[eleLink].className == 'popup')
//if (links[eleLink].href.indexOf('.pdf') !== -1) 
{

	//alert(links[eleLink].href);
	
	links[eleLink].onclick = function(){
		var links = this;
		var url=this.href;
		//alert(url);
		window.open(url,'resizable,scrollbars'); 
		
		return false;
		}
		
		
	}  
	
}

}

	    function maphide(id) {
       var e = document.getElementById(id);
	      
	   var y = document.getElementById("viewarea");
	   //y.onclick = function(){
       if(e.style.display == 'block'){
		  var img = document.createElement("img");
		   img.setAttribute('id','plus')
		      img.setAttribute('src','/clients/infostore/css/plus.gif')
			  var q = document.getElementById("viewarea");
			  q.appendChild(img)
			  img.parentNode.style.position = 'relative';
			  img.style.position = 'absolute';
			  img.style.right = '0px';
			   img.style.top = '-15px';
          e.style.display = 'none';
		  
	   }else{
		      var img = document.createElement("img");
		   img.setAttribute('id','minus')
		      img.setAttribute('src','/clients/infostore/css/minus.gif')
			  var q = document.getElementById("viewarea");
			  q.appendChild(img)
			  	  img.parentNode.style.position = 'relative';
			  img.style.position = 'absolute';
			  img.style.right = '0px';
			   img.style.top = '-15px';
          e.style.display = 'block';
		
	  //}
    }
		
		}

function loader(){
		pdfme();
	if(!document.getElementById("viewarea")){return false;}

maphide('mapcont');
var viewarea = document.getElementById("viewarea");
viewarea.onclick = function(){
//alert("boo");	
maphide('mapcont');
}
}


function rolloverarea() {//prepares list of leeds areas on my area
	if(!document.getElementById('selectArea'))return false;// checks bodyId for correct page - contine if passes test
	var allareas = document.getElementById('selectArealist'); // finds list of areas
	var eacharea = allareas.getElementsByTagName('li');//gets list items
	var postcodelist=document.getElementById('postcodes');//gets group of postcode lists
	var eachpc=postcodelist.getElementsByTagName('li');//.. then an array with the lists of postcodes
	
	for (var i=0; i<eacharea.length;i++) 
	{
		eacharea[i].onmouseover = function (){//for each area list item
		
				for (var i=0; i<eacharea.length;i++)
					{
					eacharea[i].firstChild.style.fontWeight='normal';//eacharea - resets hignlite
					}
				var pclist=this.className+'pc';//to match id of postcode list
				this.firstChild.style.fontWeight='bold';//highlites current area
				for (var i=0; i<eachpc.length;i++)//for each poscode list item
					{						
					if(pclist==eachpc[i].getAttribute("id")){eachpc[i].style.display='block';}//if constructed areaname matched id of postcode list - display it
					else{eachpc[i].style.display='none';}	//hide irrelavant postcodes				
					}			
				}
		pclist='';
	};
	//end area list routine
	//after dealing with area list perform similar routine on image map
	var imgMap=document.getElementById('mapimgMap');//the image map
	var theMapAreas=imgMap.getElementsByTagName('area');//the areas within the image map
	for (var i=0; i<theMapAreas.length;i++){//for each area
		theMapAreas[i].onmouseover = function (){
				for (var j=0; j<eacharea.length;j++){
						eacharea[j].firstChild.style.fontWeight='normal';//resets all highlites						
						if(eacharea[j].className==this.className){eacharea[j].firstChild.style.fontWeight="bold";}//highlights active one
					}
				var pclist=this.className+'pc';//the id of the relevant postcode list
				for (var i=0; i<eachpc.length;i++)//for each lsit of postcodes
					{						
					if(pclist==eachpc[i].getAttribute("id")){eachpc[i].style.display='block';}//ifconstructed areaname matches id - show it
					else{eachpc[i].style.display='none';}//else hide it
					}		
				
				}
		pclist='';
		}
	//that's it - we're done	
	}

	
	myPix = new Array("/clients/infostore/images/rnd1.jpg","/clients/infostore/images/rnd2.jpg","/clients/infostore/images/rnd3.jpg","/clients/infostore/images/rnd4.jpg","/clients/infostore/images/rnd5.jpg","/clients/infostore/images/rnd6.jpg","/clients/infostore/images/rnd7.jpg","/clients/infostore/images/rnd8.jpg")
imgCt = myPix.length
function choosePic() {
if (document.images) {
randomNum = Math.floor((Math.random() * imgCt))
document.homePics.src = myPix[randomNum] } }


function loadfunctions(){
	if((document.parent)||document.getElementById('bblitebar'))return false;
	rolloverarea();
	popupLinks();

}

window.onload=loadfunctions;


var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}



function docPopup(url){
                                                window.open(url,'popup');
}

function popupLinks(){
if(!document.getElementById)return false;
var aLinks=document.getElementsByTagName('a');
//alert('running script');
for (var i=0;i<aLinks.length;i++) {
        if (aLinks[i].className == 'popup' || aLinks[i].className == 'download')
                        {
                                aLinks[i].onclick = function ()
                                {
                                        //alert(linktype);]
                                        //
										
                                        var linktype=this.getAttribute('href');
                                        var linktype_array=linktype.split(".");
                                        var linkex=linktype_array[linktype_array.length-1];
                                                                                linkex=linkex.toLowerCase();
										//alert(linkex);
                                        //if(this.protocol=="file:"){
                                        if(linkex=='jpg' || linkex=='gif' || linkex=='ipx'){
                                                imgPopup(this.getAttribute('href'),this.getAttribute('title') );}
										//else if(linkex=='pdf'){pdfPopup(this.getAttribute('href'));}
                                        //else{docPopup(this.getAttribute('href'));}
										else{
											
											//pdfPopup(this.getAttribute('href'));
	docPopup(this.getAttribute('href')); // LP .. greyed out effect not required										
											}
                                return false;
                                }
                                //return false; 
                        }
                        aLinks[i].onkeypress = aLinks[i].onclick;
                }
}


function imgPopup(url,alt){
        var openIpix='';
        var closeIpix='';
        var isIpix=false;
        urlExtension=url.split(".");
        if(urlExtension[urlExtension.length-1]=='ipx'){isIpix=true;}
        //else{alert('not an ipix, must be an image');}
                                        var imgPopup=window.open('','imgPopup','height=50,width=50,toolbar=no,scrollbars=no,resizable=yes,menubar=no,status=no,directories=no,location=no,50,50');
                                        imgPopup.document.open();
                                        imgPopup.document.writeln('<html><head><title>image</title> \n <style type="text/css"> \n a{color:#3f3479;} p#caption{background-color:#eeeeee;text-align: left;padding-left: 10px;padding-right: 10px;}  \n body {font-family: Tahoma, Arial, Helvetica, sans-serif;text-align: center;} \n p {font-size: 70%;margin-top: 0px;padding-top: 0.5em;padding-bottom: 1em;} \n img {display: block; margin-right: auto; margin-left: auto;} \n  p.close {text-align: center; margin-bottom: 0px;        width: 9em;        float: right;        color: #FFFFFF;           padding: 3px;        font-weight: normal;}  \n </style> \n </head> \n <body>');
                                                                               imgPopup.document.writeln('<img src="' + url + '" alt="' + alt + '" id="lrgimage" />');
                                                                               imgPopup.document.writeln(' \n<p class="close"><a href="javascript:window.close();">Close Window</a></p> \n </body> \n </html>');
                                                                               imgPopup.document.title=alt;
                                                                               var bigImage=imgPopup.document.getElementById('lrgimage');
                                        var captiontxt=imgPopup.document.getElementById('caption');
                                                                                //alert(bigImage.width);
                                        //captiontxt.style.color='#333333';
                                        //captiontxt.style.fontsize='70%';
                                        //1st resize for shitty explorer
                                                var newwidth=bigImage.width+60;
                                                if(!newwidth){newwidth=490;}
                                                var newheight=imgPopup.document.body.scrollHeight+40;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                                
                                        bigImage.onload = function ()
                                        //for firefox
                                        {
                                                newwidth=bigImage.width+40;
                                                newheight=imgPopup.document.body.scrollHeight+60;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                        }
                                                                                window.onload = function ()
                                        //for firefox
                                        {
                                                newwidth=bigImage.width+40;
                                                newheight=imgPopup.document.body.scrollHeight+60;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                        }
                                                                                imgPopup.onblur=imgPopup.window.focus;
}


