//  GLOBAL SCRIPTS

  nav = navigator.userAgent.toLowerCase()
  var ie4 = document.all  //IE4+
  var ns6 = document.getElementById&&!document.all
  var ns  = nav.indexOf('netscape') != -1 && nav.indexOf('gecko') != -1
  var opr = nav.indexOf('opera/') != -1 | nav.indexOf('opera ') != -1;   // opera identifying opera or other
  var moz = nav.indexOf('gecko')  != -1
  var saf = nav.indexOf('safari') != -1
  var goo = nav.indexOf('chrome') != -1

if (self != top) top.location = self.location


	// NAVIGATION SUB MENUS
function nav_guiding() {
  output = '<li><a href="volunteers.htm">volunteers needed</a></li>'
  output+= '<li><a href="rainbows.htm">rainbows</a></li>'
  output+= '<li><a href="brownies.htm">brownies</a></li>'
  output+= '<li><a href="guides.htm">guides</a></li>'
  output+= '<li><a href="seniors.htm">senior section</a></li>'
  output+= '<li><a href="young-leaders.htm">young leaders</a></li>'
  output+= '<li><a href="adult-leaders.htm">adult leaders</a></li>'
  output+= '<li><a href="guild.htm">trefoil guild</a></li>'
	return output
}
function nav_wnew() {
  output = '<li><a href="whatsnew.htm">Latest News</a></li>'
  output+= '<li class="subhead">event news</li>'
  output+= '<li><a href="btcv_award.htm">BTCV Award</a></li>'
  output+= '<li><a href="centenary.htm">Mountain Top Moment</a></li>'
	return output
}
function nav_accommodation() {
  output = '<li><a href="felin_bach.htm">Felin Bach hostels</a></li>'
  output+= '<li><a href="felin_bach.htm#seiont">&nbsp;&nbsp;&nbsp;Seiont hostel</a></li>'
  output+= '<li><a href="felin_bach.htm#eryri">&nbsp;&nbsp;&nbsp;Eryri hostel</a></li>'
  output+= '<li><a href="felin_bach.htm#campsite">&nbsp;&nbsp;&nbsp;Camping Field</a></li>'
  output+= '<li><a href="_hostels1.htm">Album - Felin Bach</a></li>'
  output+= '<li><a href="_hostels2.htm">Album - Seoint</a></li>'
  output+= '<li><a href="_hostels3.htm">Album - Eryri</a></li>'
  output+= '<li><a href="_hostels4.htm">Album - Campsite</a></li>'
  output+= '<li><a href="_hostels5.htm">Album - Activity Trail</a></li>'
	return output
}
function nav_shop() {
  output = '<li><a href="~shop.htm">---products index---</a></li>'
  output+= '<li><a href="~spoons.htm">wooden spoons</a></li>'
  output+= '<li><a href="~badges-wood.htm">wooden badges</a></li>'
  output+= '<li><a href="~keyfob-wood.htm">key fobs - wooden</a></li>'
  output+= '<li><a href="~keyfob-acrylic.htm">key fobs - acrylic</a></li>'
  output+= '<li><a href="~pencils.htm">HB pencils</a></li>'
  output+= '<li><a href="~notelets.htm">notelets</a></li>'
  output+= '<li><a href="~badge-ribbon.htm">ribbon badge</a></li>'
  output+= '<li><a href="~badge-county.htm">county badge</a></li>'
  output+= '<li><a href="~badge-county-standard.htm">county standard badge</a></li>'
  output+= '<li><a href="~badge-county-centenary.htm">county centenary badge</a></li>'
  output+= '<li><a href="~badge-felin-bach.htm">Felin Bach badge</a></li>'
  output+= '<li><a href="~sweats-county.htm">county sweatshirt</a></li>'
  output+= '<li><a href="~polo-county.htm">county poloshirt</a></li>'
  output+= '<li><a href="~fleece-county.htm">county fleece</a></li>'
  output+= '<li><a href="~activity-packs.htm">activity packs</a></li>'
  output+= '<li><a href="~goforit-guide.htm">Go For It</a></li>'
  output+= '<li><a href="~goforit-badge.htm">Go For It badge</a></li>'
	return output
}
function nav_games() {
  output = '<li><a href="games.htm">games</a></li>'
  output+= '<li><a href="forum.htm">message board</a></li>'
	return output
}
function nav_links() {
  output = '<li><a href="links.htm#glink">guiding links</a></li>'
  output+= '<li><a href="links.htm#olink">guiding resources</a></li>'
  output+= '<li><a href="linktous.htm">link to us</a></li>'
	return output
}

	//  IMAGE ROLLOVERS
function swapBg(mo,ab) {
 if (ab=='a'){
        mo.style.backgroundColor = '#ff96b5'
                 mo.style.cursor = 'pointer'}
 if (ab=='b'){
        mo.style.backgroundColor = '#c8016f'}
 if (ab=='a2'){
        mo.style.backgroundColor = '#c8016f'
                 mo.style.cursor = 'pointer'}
 if (ab=='b2'){
        mo.style.backgroundColor = '#ff96b5'}
 if (ab=='a3'){
        mo.style.backgroundColor = '#c8016f'
                  mo.style.color = '#ffffff'
                 mo.style.cursor = 'pointer'}
 if (ab=='b3'){
                  mo.style.color = '#c8016f'
        mo.style.backgroundColor = '#ffe7ee'}
 if (ab=='a4'){
        mo.style.backgroundColor = '#fccccc'
                 mo.style.cursor = 'pointer'}
 if (ab=='b4'){
        mo.style.backgroundColor = '#ffe7ee'}
}

	// COPYRIGHT UPDATE
function copyright() {
	cr      = new Date().getFullYear()+""
	cryear  = cr
	cpright = 'Content <span style="font-size:12pt">&copy;</span> Girlguiding Caernarfonshire 2008-' + cryear + '&nbsp;&#151;&nbsp;Site design <span style="font-size:12pt">&copy;</span> <a class="web2" target="_blank" href="http://www.sibleyfineart.com">MSFA</a> 2008-' + cryear + ' &#151;&nbsp;<script type="text/javascript">document.write(webmaster())</script>'
   return cpright
}

	// AUTO GALLERY NAVIGATION
function galleryNav() {
  var write = ''
gOff = '<div class="galoff">' + gallery + '</div>'
gOn  = '<div class="galon" onMouseOver="swapBg(this,\'a\')" onMouseOut="swapBg(this,\'b\')" onClick="location.href=\'_' + gall_of
gDim = '<div class="galdim">&nbsp;</div>'
    if(gallery==1){write += gOff}else{if(gall_of > 1){write += gOn + '1.htm\'">1</div>'}else{write += gDim}}
    if(gallery==2){write += gOff}else{if(gall_of > 1){write += gOn + '2.htm\'">2</div>'}else{write += gDim}}
    if(gallery==3){write += gOff}else{if(gall_of > 2){write += gOn + '3.htm\'">3</div>'}else{write += gDim}}
    if(gallery==4){write += gOff}else{if(gall_of > 3){write += gOn + '4.htm\'">4</div>'}else{write += gDim}}
    if(gallery==5){write += gOff}else{if(gall_of > 4){write += gOn + '5.htm\'">5</div>'}else{write += gDim}}
    if(gallery==6){write += gOff}else{if(gall_of > 5){write += gOn + '6.htm\'">6</div>'}else{write += gDim}}
    if(gallery==7){write += gOff}else{if(gall_of > 6){write += gOn + '7.htm\'">7</div>'}else{write += gDim}}
	return write
}
function galleryNav2() {
  var write2 = '<table width="150" border=0 cellspacing=2 cellpadding=0 align=center><tr>'

gNavb = '<tr><td align="center" class="nextdim">back</td>'
gNav1 = '<td align="center" class="nextbox" onMouseOver="swapBg(this,\'a3\')" onMouseOut="swapBg(this,\'b3\')" onClick="location.href=\'_' + gall_id + (gallery-1) + '.htm\'">back</td>'
gNav2 = '<td align="center" class="nextbox" onMouseOver="swapBg(this,\'a3\')" onMouseOut="swapBg(this,\'b3\')" onClick="location.href=\'_' + gall_id + (gallery+1) + '.htm\'">next</td>'
gNavn = '<td align="center" class="nextdim">next</td>'
    if(gallery==1){write2 += gNavb; if(gall_of > 1){write2 += gNav2}else{write2 += gNavn}}
    if(gallery==2){write2 += gNav1; if(gall_of > 2){write2 += gNav2}else{write2 += gNavn}}
    if(gallery==3){write2 += gNav1; if(gall_of > 3){write2 += gNav2}else{write2 += gNavn}}
    if(gallery==4){write2 += gNav1; if(gall_of > 4){write2 += gNav2}else{write2 += gNavn}}
    if(gallery==5){write2 += gNav1; if(gall_of > 5){write2 += gNav2}else{write2 += gNavn}}
    if(gallery==6){write2 += gNav1; if(gall_of > 6){write2 += gNav2}else{write2 += gNavn}}
    if(gallery==7){write2 += gNav1 + gNavn}
	write2 += '</tr></table>'
	return write2
}

	// PRELOAD GALLERY ICONS
icon0 = new Image();icon0.src = "images/icon_info.gif"
icon1 = new Image();icon1.src = "images/icon_info2.gif"
icon2 = new Image();icon2.src = "images/icon_zoom.gif"
icon3 = new Image();icon3.src = "images/icon_zoom2.gif"
icon4 = new Image();icon4.src = "images/icon_zoom_out.gif"
icon5 = new Image();icon5.src = "images/icon_zoom_out2.gif"
icon6 = new Image();icon6.src = "images/type_icon_print.gif"
icon7 = new Image();icon7.src = "images/type_icon_orig.gif"
icon8 = new Image();icon8.src = "images/type_icon_cards.gif"
icon9 = new Image();icon9.src = "images/type_icon_cards_small.gif"
icon10= new Image();icon10.src = "images/type_icon_keyfob.gif"

	//  DROPDOWN MENUS
//Adapted from SuckerTree Horizontal Menu - Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids=["menu1"] //Enter id(s) of UL menus separated by commas
var adj ='';  adj=0; if(ns){adj=180}

function submenus(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
   for (var t=0; t<ultags.length; t++){
    if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
        ultags[t].style.top=ultags[t].parentNode.offsetHeight+adj+"px" //dynamically position first level submenus to be height of main menu item
//        ultags[t].parentNode.getElementsByTagName("a")[0].className="mainicon"
	}
	else{ //else if this is a sub level menu (ul)
        ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
        ultags[t].parentNode.getElementsByTagName("a")[0].className="subicon"
	}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
   }
  }
}

if (window.addEventListener)
window.addEventListener("load",submenus,false)
else if (window.attachEvent)
window.attachEvent("onload",submenus)

//------------------------ TERMS & CONDITIONS ----------------------
function termsOn(x) {
	termsOff()
	el =   document.getElementById(x)
	el.style.display = 'block' 
  term = ''
  term+= '<div id="tprCloser">'
  term+= '<a class="tprClose" href="#" onClick="termsOff()">Close</a></div></div>'

  term+= '<div id="tprhead">'
    if (x=='t'){term+= 'Terms &amp; Conditions'
	      el.style.height = '200px'}
    if (x=='p'){term+= 'Postage'
	      el.style.height = '240px'}
    if (x=='r'){term+= 'Returns'
	      el.style.height = '400px'}
  term+= '</div><div style="clear:both">'
  term+= '<ul>'
    if (x=='t'){
  term+='<li>All goods remain the property of Girlguiding Caernarfonshire until paid for in full.</li>'
  term+='<li>Prices apply only to goods purchased directly online from Girlguiding Caernarfonshire.</li>'
	}
    if (x=='p'){
  term+= '<li>All prices are plus postage and packing - estimates can be quoted on request.</li>'
  term+= '<li>All goods are charged at a worldwide price and may be shipped internationally at the lowest cost.</li>'
  term+= '<li>For your convenience, all postage prices are displayed on the page as you select your choice of product. There are no additional charges levied.</li>'
  term+= '<li>Delivery times are not guaranteed but will be as expedient as possible.</li>'
	}
    if (x=='r'){
  term+= '<li>If you are not delighted with your purchase please return it for full credit of your original payment.</li>'
  term+= '<li>The UK\'s Distance Selling Regulations entitle you to the right to cancel the contract for the purchase of any goods ordered within 7 days of delivery. To cancel, inform us by email, telephone or mail and return your goods, within 7 working days, in the packaging in which you received them, to Girlguiding Caernarfonshire, 51 High Street, Llanberis, Gwynedd, LL55 4EV, United Kingdom.</li>'
  term+= '<li>Please use reistered mail for your protection.</li>'
  term+= '<li>We will refund the purchase price for all items that you are returning as soon as we receive the goods.</li>'
  term+= '<li>The return postage will not be refunded, unless we delivered the item to you in error.</li>'
  term+= '<li>It is your responsibility to return the goods in perfect condition. If the goods are damaged in transit you may only receive a partial refund at our discretion.</li>'
	}
  term+= '</ul></div>'
 el.innerHTML = term
}
function termsOff() {
  document.getElementById('t').style.display = 'none' 
  document.getElementById('p').style.display = 'none' 
  document.getElementById('r').style.display = 'none' 
}

	// OPEN GALLERY IMAGE from LINK
	// Fires "viewThis()" from link + feeds LinkGenerator

function gotoImage() {
       var idx = document.URL.indexOf('?')
  if (idx != -1) {
     imgId = document.URL.substring(idx+1,document.URL.length)
//     imgId = 'test'  // Testing only
        post = document.getElementById(imgId).innerHTML
      params = post.substring(post.indexOf('viewThis'),post.indexOf(';return'))
eval(params)
	}
}

	// EXTERNAL LINK GENERATOR
  var copy = 1
function linkGen() {
	imgId = imgId
	btn = document.getElementById('linkG')
	genD= document.getElementById('linkData')
	genD.style.border = '1px solid #aeaeae'
	genD.value = 'www.girlguiding-caernarfonshire.org/_' +category +gallery+ '.htm?' +imgId
  if(copy==0) {
	btn.innerHTML = '<a href="#" onClick="linkClr();return false">clear</a>'
	genD.focus()
	genD.select()
	}else{
	btn.innerHTML = '<a href="#" onClick="linkCopy();return false">copy</a>'
	} 
}
function linkCopy() {
	btn = document.getElementById('linkG')
	genD= document.getElementById('linkData')
	genD.focus()
	genD.select()
  if(ie4){
window.clipboardData.clearData()
window.clipboardData.setData('Text',genD.value)
  if(window.clipboardData.setData != -1) {
	genD.value = 'Link succesfully copied to CLIPBOARD'
	btn.innerHTML = '<a href="#" onClick="linkClr();return false">clear</a>'
	copy = 1  }
  if(window.clipboardData.setData == -1) {
	genD.value = 'COPY FAILED - click button to restore link - right-click link to copy manually - click button to clear'
	btn.innerHTML = '<a href="#" onClick="linkGen();return false">link</a>'
	copy = 0	}
    }
  if(!ie4){
	btn.innerHTML = '<a href="#" onClick="linkClr();return false">clear</a>'
	copy = 1 
     }
}
function linkClr() {
	btn = document.getElementById('linkG')
	genD= document.getElementById('linkData')
	genD.style.border = 'none'
	genD.value = ''
	btn.innerHTML = '<a href="#" onClick="linkGen();return false">link</a>' 
	copy = 1
}







