///============================================
// BOOKMARK
///============================================
function bookmarksite(title, url)
	{
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
	}

///============================================
// CENTER WINDOW POPUP
///============================================
var win = null;
function NewWindow(mypage,myname,w,h,scroll)
	{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
	if(win.window.focus)
		{
		win.window.focus();
		}
	}


///============================================
// CHECK CONTACT FORM
///============================================
function checkContactForm()
	{
	if((document.contactForm.name.value=="")||
(document.contactForm.address.value=="")||
(document.contactForm.town.value=="")||
(document.contactForm.county.value=="")||
(document.contactForm.pc.value=="")||
(document.contactForm.tel_no.value=="")||
(document.contactForm.email.value=="")||
(document.contactForm.query.value==""))
		{
		alert("Please Make sure all required fields are completed, then try again.");
		return (false);
		}
	else
		{
		return (true);
		}
	}
	
function getWindowWidth(){
  var ww = 0;
  d = document;
   if ( typeof window.innerWidth != 'undefined' )
     ww = window.innerWidth;  // NN and Opera version
   else
   {
     if ( d.documentElement
       && typeof d.documentElement.clientWidth!='undefined'
       && d.documentElement.clientWidth != 0 )
       ww = d.documentElement.clientWidth;
     else
       if ( d.body
         && typeof d.body.clientWidth != 'undefined' )
         ww = d.body.clientWidth;
     else alert ("Can't identify window width - please tell me which browser you are using.")
   }
   return ww;
}

function changeimg(imgsize) {
  var imgwidth, imgheight, imgid;

  switch(imgsize) {
    case 800:  imgwidth=smaWidth; imgheight=smaHeight; imgid='1'; break;
    case 1024: imgwidth=medWidth; imgheight=medHeight; imgid='2'; break;
    case 1600:  imgwidth=larWidth; imgheight=larHeight; imgid='3'; break;
    default:     alert('Javascript error');
  }

  for (var n=0; n<imgArr.length; n++)
  { 
    imgElement = 'img'+imgArr[n][iname];
    document.images[imgElement].width = imgArr[n][imgwidth];
    document.images[imgElement].height= imgArr[n][imgheight];
    document.images[imgElement].src = 'img/' + imgArr[n][iname] + imgid + '.jpg';
  }
}

function resizeimg() {
  var ww = getWindowWidth();

  if (ww>0) {
    if (ww<900) changeimg(800)
    else if (ww>1400) changeimg(1600)
    else changeimg (1024);
  }
}

