$(document).ready(function(){
   
	/*
   $('.accordion div').hide(); 
   $('.accordion a.link').live("click",function() {
      $(this).siblings('.active').removeClass('active');
      $(this).toggleClass('active');
      $(this).next('div').slideToggle('fast')
      .siblings('div:visible').slideUp('fast');
      return false;
   })
	*/
   
   $("a[class*='external']").click(function(){
      this.target = "_blank";
   });
   
   //$("a[rel='gallery1']").colorbox();
   
   //mail obfuscation
   $('span.mailme').mailme();
   
   $(document).pngFix(); 
   
   /*
   if (bgimage == "0") {
      bgimage = Math.ceil(Math.random()*parseInt(bgimages));
   }
   $("body").ezBgResize({
        img : "/_img/bg/background_"+bgimage+".jpg"
    });
    */
    
    $('input, textarea').placeholder();
    
    $("#subscribe-form").validate();
    $("#storyform").validate();

	/*
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	*/

});

function updateList(val) {
	//remove options
	$('#city').html('');
	setProvList(val);
}

function setProvList(prov) {
	$('#prov a').removeClass('active');
	$('#prov a#link-'+prov).addClass('active');
	//update the city
	var arr = cityListArr[prov];
	var len = arr.length;
	for (var i=0; i<len; i++) {
		$('#city').append('<a href="javascript:showCity(\''+arr[i][0]+'\')" id="link-'+arr[i][0]+'">'+arr[i][1]+'</a><br />');
	}
	//show default city
	setCity(arr[0][0]);
}

function showCity(val) {
	//show the city div
	setCity(val);
}

function setCity(city) {
	//hide all city divs
	$('.city').hide();
	$('#city a').removeClass('active');
	$('#city a#link-'+city).addClass('active');
	$('#'+city).show();
}
