
if(document.getElementById){
	//alert('running menu script');
	//document.writeln('<style type="text/css">ul.bb_menulevel2 {visibility:hidden;}</style>');
	}


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="../../../Scripts/sevenarts/' + url + '" alt="' + alt + '" id="lrgimage" />');
																		  //alert('<img src="' + url + '" alt="' + alt + '" id="lrgimage" />');
     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;
}

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].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();
                                        //if(this.protocol=="file:"){
                                        if(linkex=='jpg' || linkex=='gif' || linkex=='ipx'){
                                                imgPopup(this.getAttribute('href'),this.getAttribute('title') );}
                                        else{docPopup(this.getAttribute('href'));}
                                return false;
                                }
                                //return false;
                        }
                        aLinks[i].onkeypress = aLinks[i].onclick;
                }
}

function toggleAdvancedOptions(){
	x=document.getElementById('advsearch');
	var newcontrol=document.getElementById('newcontrol');
	if (x.style.display=='none')
	{
		x.style.display='block';
		newcontrol.innerHTML='<a href="javascript:toggleAdvancedOptions();" >more options - </a>';
		}
	else{x.style.display='none';
	newcontrol.innerHTML='<a href="javascript:toggleAdvancedOptions();" >more options + </a>';}	
}



function hideAdvancedSearch(){
	if (!document.getElementById('diarysort')) return false;
	var x=document.getElementById('advsearch');
	var newcontrol=document.getElementById('newcontrol');
	newcontrol.innerHTML='<a href="javascript:toggleAdvancedOptions();" >more options + </a>';
	x.style.display='none';
	//alert(x.innerHTML);   
}
function hidedoublelinks(){
var menu, menu2, menu3;
var h1s=document.getElementsByTagName('h1');
for (var i=0;i<h1s.length;i++){
	h1s[i].style.display="block";
	if(h1s[i].className=='sectionheader'){var sectionheader=h1s[i];}
	
}
if(sectionheader){
	var breadcrumbs=sectionheader.getElementsByTagName('a');
		for (var i=1;i<breadcrumbs.length;i++){
		//alert(breadcrumbs[i].innerHTML);
		if(breadcrumbs[i].innerHTML==breadcrumbs[i-1].innerHTML){breadcrumbs[i-1].style.display='none';}
		
		}
	
	//sectionheader.style.display='none';
	
	
	}
	
	var menu=document.getElementById('bb_menus');
	
	if (menu!=null) {
	
		menu2=menu.getElementsByTagName('ul')[0];
		menu3=menu.getElementsByTagName('ul')[1];
	
	}
	
	//var menu3=document.getElementById('menulevel3');
	
	if(menu2){
		if(menu2.getElementsByTagName('li').length<=1 &!menu3 ){menu2.style.visibility='hidden';}
			else{menu2.style.visibility="visible";}
			
	}
	
}

function formval(){
	//alert("running formval");
	if(!document.getElementById('email')){return false;}
		for(var i = 0; i < document.getElementsByTagName("input").length; i++){
		// If of type text
		var inputs = document.getElementsByTagName("input")[i];
		if(document.getElementsByTagName("input")[i].type.toLowerCase() == 'submit'){
			// Add the onclick function
			document.getElementsByTagName("input")[i].onclick = function formcontrol(){
			if(document.getElementById("email").value == "" || document.getElementById("name").value == ""){	 //|| document.getElementById("enquiry").value == "" 
																																		
var error = document.createTextNode("Please ensure all the fields marked with * are filled in correctly");
var div = document.createElement("div");
var p = document.createElement("p");
var contactform = document.getElementById("contactform");
div.style.color = '#ff0000';
div.style.bgcolor = 'pink';
div.setAttribute('id','error');
p.setAttribute('id','errormsg');
p.appendChild(error);
div.appendChild(p);
contactform.appendChild(div);
return false;
				}
			}
		}
	}
}

function loadfunctions(){
	if(document.getElementById('bblitebar'))return false;
	popupLinks();
	hideAdvancedSearch();
	//hidedoublelinks();
	formval();
}
window.onload=loadfunctions;



