var _gaq = _gaq || [];
_gaq.push(['GH._setAccount', 'UA-232524-29']);
_gaq.push(['GH._setDomainName', 'none']);
_gaq.push(['GH._setAllowLinker', true]);
_gaq.push(['GH._trackPageview']);
 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();

var mTimer;
var mRollover = false;
var rollover = false;

var hide_m_rollover = function() {
	$('#global-banner .over').fadeOut('fast');
 	mRollover = false;
 	$('#global-banner li a').removeClass('nav-over');
}

function show_locations() {
  $('#global-banner #locations-list').toggle();
  $('#global-banner #locations a').addClass('on');
}

function hide_locations() {
  $('#global-banner #locations-list').toggle();
  $('#global-banner #locations a').removeClass('on');
}

$(document).ready(function() {
if (document.URL.match(/https/)){
	var sprite = "https://c48746.ssl.cf3.rackcdn.com/sprite.png";		
}
else
{
	var sprite = "http://c48746.r46.cf3.rackcdn.com/sprite.png";
}
 $("<style type=\"text\/css\">\
  body {margin-top: 0px;}\
  #global-banner{ background: url(" + sprite + ") no-repeat top left; }\
  #global-banner #network { background: url(" + sprite + ") no-repeat top left; }\
  #global-banner #locations-list { background: url(" + sprite + ") no-repeat top left; }\
  #global-banner #locations a { background: url(" + sprite + ") no-repeat top left; background-position: 4px -296px; }\
  #global-banner #locations-list #uk-flag { background: url(" + sprite + ") no-repeat top left; }\
  #global-banner #locations-list #us-flag { background: url(" + sprite + ") no-repeat top left; }\
  #global-banner li a { background: url(" + sprite + ") no-repeat top left; }  #global-banner .over { background: url(" + sprite + ") no-repeat top left; }\
  #global-banner { z-index:30; position:fixed; width:100%; text-align: left; left:0px; color: #333; font: 62.5%/1.3 Arial, Helvetica, sans-serif; float:left; clear:both; width:100%; background-repeat:repeat-x; z-index: 99999; background-position: 0 -349px; }\
  #global-banner div, #global-banner img { margin: 0; padding: 0; border: 0; font-size: 100%; vertical-align: baseline; background: transparent; }\
  #global-banner h3 { color: #333333; margin: 0; padding: 0; border: 0; font-size: 100%; vertical-align: baseline; background: transparent; }\
  #global-banner ul { margin: 0; padding: 0; border: 0; font-size: 100%; vertical-align: baseline; background: transparent; }\
  #global-banner a {text-decoration: none; }\
  #global-banner #locations-list { position: absolute; width:580px; height:202px; top:22px; left:-2px; z-index: 1; display:none; background-position: 0 -90px; width: 580px; height: 202px; background-repeat:no-repeat; }\
  #global-banner #locations-list #uk-flag { background-position: 0 -415px; height: 18px; padding-left:26px; margin-bottom:1px }\
  #global-banner #locations-list #us-flag { background-position: 0 -443px; height: 18px; padding-left:26px; margin-bottom:1px }\
  #global-banner #locations-wrap { float:left; padding:12px; padding-bottom: 0px;}\
  #global-banner .location { float:left; width:180px; margin:0px; }\
  #global-banner .locations-close { float:left; clear:both; margin-left:12px; display:inline; }\
  #global-banner .locations-close a { color:#666; font-size:11px; }\
  #global-banner .location h3,.location p { font-size:11px; margin-bottom:7px; }\
  #global-banner #locations { float:left; position:relative; z-index:5; width:70px; font-size:11px; color:#999; border-right:1px solid #CCC;  }\
  #global-banner p { margin-top: 0px }\
  #global-banner ul { list-style:none; float:right; position:relative; z-index:120; }\
  #global-banner ul li { float:left; width:120px; font-size:11px; border-left:1px solid #d5d7d7; }\
  #global-banner ul li.first { width:101px; }\
  #global-banner ul li.last { width:92px; }\
  #global-banner li a { color:#333; display:block; margin:0px 0px; padding:4px 3px 0px 4px; height:19px; background-position: 105px -312px; font-size: 11px; text-align: left; }\
  #global-banner a:hover { color:#07426b }\
  #global-banner li a:hover { color:#07426b; background-position: 105px -327px; background-color:#FFF; height:21px; }\
  #global-banner #locations p { margin: 0; padding: 0; border: 0; font-size: 100%; vertical-align: baseline; background: transparent; }\
  #global-banner #locations a { color:#333; display:block; margin:0px 0px; padding:4px 7px 0px 15px; background-position: 4 -296px; }\
  #global-banner #locations a:hover { color:#07426b; background-position: 4 -296px; }  #global-banner #locations a.on { color:#07426b; background-position: 4 -296px; }\
  #global-banner li.selected a { color:#07426b; text-decoration: underline;}\
  #global-banner .over { display:none; position:absolute; z-index:100; top:22px; right:0px; height:80px; background-position: 0 0; width: 350px; height: 80px; background-repeat:no-repeat; }\
  #global-banner .over p { font:12px Helvetica,Arial; color:#666; margin:10px 10px 0px 10px; }\
  #global-banner #network { background-position: 0 -382px; width: 145px; height: 23px; }\
  #global-banner #network a { height: auto; }\
  #global-banner #network a img { vertical-align: top; }\
  #global-banner #network a:hover { background: none; height: auto; }\
  #global-banner #network { float:left; width:145px; }\
</style>\
").appendTo('head');
  $("#global-banner").hide();
  $('#global-banner').html('<div id="locations">\
  <a href="#" onclick="show_locations(); return false">Locations</a>\
  </div>\
  <a href="http://www.nwsystemsgroup.com/index.php?ref=gh"><div id="network"></div></a>\
  <ul>\
    <li id="link-nwsg">\
      <a href="http://www.nwsystemsgroup.com/what-we-do/nw-systems-division.php?ref=gh">NW Security</a>\
    </li>\
    <li id="link-network_webcams">\
      <a href="http://www.networkwebcams.com/index.php?ref=gh">Network Webcams</a>\
    </li>\
    <li id="link-securitystation">\
      <a href="http://www.securitystation.com/index.php?ref=gh">SecurityStation</a>\
    </li>\
    <li id="link-remote_manager">\
      <a href="http://www.remotemanager.co.uk/index.php?ref=gh">RemoteManager</a>\
    </li>\
    <li id="link-streamdays">\
      <a href="http://www.streamdays.com/hostedwebcams/buyawebcam">Streamdays</a>\
    </li>\
  </ul>\
<div id="locations-list">\
  <div id="locations-wrap">\
    <div class="location">\
      <h3 id="uk-flag">Head office</h3>\
      <p>\
        NW Systems Group<br />\
        Claddagh House<br />\
        New Hall Lane<br />\
        Hoylake<br />\
        Wirral<br />\
        CH47 4BP<br />\
        UK\
      </p>\
      <p>\
        Tel: +44 (0)151 633 2111<br />\
        Fax: +44 (0)151 633 2300\
      </p>\
    </div>\
    <div class="location">\
      <h3 id="us-flag">US office</h3>\
      <p>\
        NW Systems Group (US)<br />\
        145 Bedford Road<br />\
        Armonk<br />\
        New York 10504<br />\
        USA\
      </p>\
      <p>\
        Tel: +1-888-813-2267 (toll free)<br />\
        Fax: +1-888-813-6465 (toll free)\
      </p>\
    </div>\
    <div class="location">\
      <h3>Scottish office</h3>\
      <p>\
        NW Systems Group<br />\
        Frances Industrial Park<br />\
        Wemyss Road<br />\
        Kirkcaldy<br />\
        KY1 2XZ<br />\
        UK\
      </p>\
      <p>\
        Tel: +44 (0)1592 650220<br />\
        Fax: +44 (0)1592 650990\
      </p>\
    </div>\
  </div>\
  <div class="locations-close">\
    <p>\
      <a href="#" onclick="hide_locations(); return false">Close</a>\
    </p>\
  </div>\
</div>\
<div class="over" id="over-nwsg">\
  <p>\
    NW Security is our security integration arm, providing network-based CCTV and remote monitoring solutions. Contact us for design, installation &amp; maintenance services.\
  </p>\
</div>\
<div class="over" id="over-network_webcams">\
  <p>\
    Network Webcams is our IP camera store, offering specialist advice, free technical suppport and an unparalleled level of service. Buy online or call us.\
  </p>\
</div>\
<div class="over" id="over-securitystation">\
  <p>\
    Video Surveillance as a Service (VSaaS) - SecurityStation offers web-based video monitoring and recording. It\'s extremely easy to set up and use. Sign up for a free account.\
  </p>\
</div>\
<div class="over" id="over-remote_manager">\
  <p>\
    RemoteManager is our web-based camera system for construction projects, providing progress monitoring, time lapse movies and online promotion. Find out more...\
  </p>\
</div>\
<div class="over" id="over-streamdays">\
  <p>\
    Streamdays is our live video webcam hosting service for the tourism and leisure sector. Enhance your website with a live webcam to increase traffic. Watch a webcam demo.\
  </p>\
</div>');
	var link;
	if (document.URL.match(/nwsystemsgroup.com/)){
		link = "nwsg";
	}
	else if (document.URL.match(/networkwebcams.com/) || document.URL.match(/networkwebcams.co.uk/) || document.URL.match(/networkwebcams.eu/)){
		link = "network_webcams";
	}
	else if (document.URL.match(/streamdays.com/)){
		link = "streamdays";
	}
	else if (document.URL.match(/remotemanager.co.uk/)){
		link = "remote_manager";
	}
	else if (document.URL.match(/securitystation.com/)){
		link = "securitystation";
	}
	if (typeof link != "undefined"){
		$("#global-banner #link-" + link).addClass("selected");
	}
	if(!($.browser.msie && $.browser.version == 6.0)) {
		if($.browser.msie && link == "network_webcams"){
			if((document.URL.match(/forum/)) || (document.URL.match(/blog/)) || (document.URL.match(/ip-camera-learning-center/))){ 
				$("#global-banner").next().css("padding-top", "23px");
  				$("#global-banner").show();
			}
			else{
  				$("#global-banner").show();
			}
		}
		else{
			$("#global-banner").next().css("padding-top", "23px");
  		$("#global-banner").show();
		}
	}
		$('#global-banner li').hover(function() {    
		$('#global-banner li a').removeClass('nav-over');
    clearTimeout(mTimer);
    $('#global-banner .over').hide();
    var over = $(this).attr('id').replace('link','over');
    var o = $(this).offset();
    var po = $('#global-banner #'+over).parent().offset();
    var diff = o.left > ($(document).width() - 260) ? 227 : 2;
    if ($.browser.msie) {
      if($(this).attr('id')=='link-remote_manager') {
        var diff = 227;
      }
      if(($(this).attr('id')=='link-streamdays') && ($('#link-remote_manager').hasClass('selected') || $('#link-network_webcams').hasClass('selected'))) {
        var diff = 230;
      }
    }
    mRollover = true;
    $('#global-banner #'+over).css('left',o.left - diff);
    $('#global-banner #'+over).hide();
    $('#global-banner #'+over).show();
  }, function() {
    mTimer = setTimeout('hide_m_rollover()',100);
  });
  $('#global-banner .over').hover(function() {
    var over = $(this).attr('id').replace('over','link');
    $('#global-banner #'+over).addClass('nav-over');
    clearTimeout(mTimer);
  }, function() {   
    mTimer = setTimeout('hide_m_rollover()',100);
  });
});

