$(document).ready(function() {
	$("div[rel]").overlay();
});


//Cufon
//----------------------------------------------------------------------------------
Cufon.replace('h1', {hover:true});
Cufon.replace('#page_title', {hover:true});
Cufon.replace('.feature_title', {hover:true});


//Explore DD
//----------------------------------------------------------------------------------

// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
// This code featured on/availabe at Dynamic Drive code library: http://www.dynamicdrive.com

// ----- Popup Control 
function at_display(x)
{
  win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- Show Aux -----
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  var top  = (c["at_position"] == "y") ? p.offsetHeight : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top-8 +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Show -----
function at_show()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);
  
  document.getElementById('explore_main').style.backgroundPosition='0 -72px';
  
  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}

// ----- Hide -----
function at_hide()
{
  c = document.getElementById(this["at_child"]);
  
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'; document.getElementById('explore_main').style.backgroundPosition='0 -48px'", 333);
  
  ;
}

// ----- Click -----
function at_click()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id);
  else c.style.visibility = "hidden";

  return false;
}

// ----- Attach -----
function at_attach(parent, child, showtype, position, cursor)
{
  p = document.getElementById(parent);
  c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}

// ----- Explore Secondry Menu -----
function showexplore(ele){
	if(ele=="thiscity"){
		document.getElementById(ele).style.display='block';
		document.getElementById('thenation').style.display='none';
		document.getElementById('thenations').style.display='none';
		document.getElementById('aboutus').style.display='none';
		document.getElementById('thiscity_header').style.backgroundPosition='0 -424px';
		document.getElementById('thenation_header').style.backgroundPosition='0 -384px';
		document.getElementById('thenations_header').style.backgroundPosition='0 -384px';
		document.getElementById('aboutus_header').style.backgroundPosition='0 -384px';
	}else if(ele=="thenation"){
		document.getElementById(ele).style.display='block';
		document.getElementById('thiscity').style.display='none';
		document.getElementById('thenations').style.display='none';
		document.getElementById('aboutus').style.display='none';
		document.getElementById('thiscity_header').style.backgroundPosition='0 -384px';
		document.getElementById('thenation_header').style.backgroundPosition='0 -424px';
		document.getElementById('thenations_header').style.backgroundPosition='0 -384px';
		document.getElementById('aboutus_header').style.backgroundPosition='0 -384px';
	}else if(ele=="thenations"){
		document.getElementById(ele).style.display='block';
		document.getElementById('thiscity').style.display='none';
		document.getElementById('thenation').style.display='none';
		document.getElementById('aboutus').style.display='none';
		document.getElementById('thiscity_header').style.backgroundPosition='0 -384px';
		document.getElementById('thenation_header').style.backgroundPosition='0 -384px';
		document.getElementById('thenations_header').style.backgroundPosition='0 -424px';
		document.getElementById('aboutus_header').style.backgroundPosition='0 -384px';
	}else if(ele=="aboutus"){
		document.getElementById(ele).style.display='block';
		document.getElementById('thiscity').style.display='none';
		document.getElementById('thenation').style.display='none';
		document.getElementById('thenations').style.display='none';
		document.getElementById('thiscity_header').style.backgroundPosition='0 -384px';
		document.getElementById('thenation_header').style.backgroundPosition='0 -384px';
		document.getElementById('thenations_header').style.backgroundPosition='0 -384px';
		document.getElementById('aboutus_header').style.backgroundPosition='0 -424px';
	}
}


//Carasol
//----------------------------------------------------------------------------------
function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });

    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Header Carousel
jQuery(document).ready(function() {
    jQuery("#header_carousel").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        auto: 8,
        wrap: 'both',
        animation: 0,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// Home Connect Carousel
jQuery(document).ready(function() {
    jQuery("#connect_home_carousel").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        auto: 10,
        wrap: 'both',
        animation: 500,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

//Connect Carousel
jQuery(document).ready(function() {
    jQuery("#connect_carousel").jcarousel({
        scroll: 3,
        initCallback: mycarousel_initCallback,
        animation: 500
    });
});

//Home Tabs
//----------------------------------------------------------------------------------
$(function () {
	var tabContainers = $('div.tabs > div.tab_content');
	tabContainers.hide().filter(':first').show();
	
	$('div.tabs ul.tabNavigation a').click(function () {
	    tabContainers.hide();
	    tabContainers.filter(this.hash).show();
	    $('div.tabs ul.tabNavigation a').removeClass('selected');
	    $(this).addClass('selected');
	    return false;
	}).filter(':first').click();
});


//Text Box Default value
//----------------------------------------------------------------------------------
jquery_inputDefault=function(){this.init=function(){var a=$("input.inputDef");a.each(function(){$(this).attr('value',$(this).attr('default')).addClass('jqueryInputDefault')});a.focus(function(){if($(this).attr('value')==$(this).attr('default')){$(this).attr('value','').removeClass('jqueryInputDefault')}});a.blur(function(){if($(this).attr('value')==''){$(this).attr('value',$(this).attr('default')).addClass('jqueryInputDefault')}})}};$(document).ready(function(){var a=new jquery_inputDefault();a.init()});



//Twitter
//----------------------------------------------------------------------------------
$(document).ready(function(){
        $(".tweet").tweet({
            username: "christchurchldn",
            count: 2,
            loading_text: "loading tweets..."
        });
    });