// JavaScript Document
// Painstakingly researched and learnt from the internet by Kyle Pritchard :)
// kylepritchard@hotmail.co.uk

//////////////////////////////////////////////////////////////////////////////////////////////
// This script is used to control expanding boxes
//////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function()
{
  //hide the all of the element with class msg_body
  $(".floating_box_content").hide();
  //toggle the componenet with class msg_body
  $(".click_expand").click(function()
  {
    $(".floating_box_content").slideToggle("slow"); 
	$(this).text($(this).text() == 'Show Options...' ? 'Hide Again!!' : 'Show Options...'); 
	$(".click_expand").toggleClass("click_expand_clicked");
  });
});
//////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////
// This script is used to control tabbed pages
//////////////////////////////////////////////////////////////////////////////////////////////
$(function() { 
    // setup ul.tabs to work as tabs for each div directly under div.panes 
    $("ul.tabs").tabs("div#about_pages_contents > div", {effect: 'ajax'}).history(); 

});

$(function() { 
    // setup ul.tabs to work as tabs for each div directly under div.panes 
    $("ul.tabs").tabs("div#user_pages_contents > div", {effect: 'ajax'}); 

});

//////////////////////////////////////////////////////////////////////////////////////////////
// This script controls pop-up modal boxes which can be used to inline edit shit
//////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {

var triggers = $("button.modalInput").overlay({

	// some expose tweaks suitable for modal dialogs
	expose: {
		color: '#333',
		loadSpeed: 200,
		opacity: 0.9
	},

	closeOnClick: false
});


$("#prompt form").submit(function(e) {

	// close the overlay
	triggers.eq(1).overlay().close();

	// get user input
	var input = $("input", this).val();

	// do something with the answer
	triggers.eq(1).html(input);

	// do not submit the form
	return e.preventDefault();
});

});
//////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////
// This script controls navigation drop-down menu
//////////////////////////////////////////////////////////////////////////////////////////////
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#navi_menu > li').bind('mouseover', jsddm_open)
   $('#navi_menu > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;
//////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////
// This script controls tooltips for the forms
//////////////////////////////////////////////////////////////////////////////////////////////

// execute your scripts when the DOM is ready. this is a good habit
$(function() {

// select all desired input fields and attach tooltips to them
$("#comment_form :input").tooltip({

	// place tooltip on the right edge
	position: "center right",

	// a little tweaking of the position
	offset: [-2, 10],

	// use the built-in fadeIn/fadeOut effect
	effect: "fade",

	// custom opacity setting
	opacity: 0.7,

	// use this single tooltip element
	tip: '.tooltip'

});
});

// execute your scripts when the DOM is ready. this is a good habit
$(function() {

// select all desired input fields and attach tooltips to them
$("#member_form :input").tooltip({

	// place tooltip on the right edge
	position: "center right",

	// a little tweaking of the position
	offset: [-2, 10],

	// use the built-in fadeIn/fadeOut effect
	effect: "fade",

	// custom opacity setting
	opacity: 0.7,

	// use this single tooltip element
	tip: '.tooltip'

});
});

// execute your scripts when the DOM is ready. this is a good habit
$(function() {

// select all desired input fields and attach tooltips to them
$("#contact_form :input").tooltip({

	// place tooltip on the right edge
	position: "center right",

	// a little tweaking of the position
	offset: [-2, 10],

	// use the built-in fadeIn/fadeOut effect
	effect: "fade",

	// custom opacity setting
	opacity: 0.7,

	// use this single tooltip element
	tip: '.tooltip'

});
});


//////////////////////////////////////////////////////////////////////////////////////////////
// Blog tooltips
//////////////////////////////////////////////////////////////////////////////////////////////

// execute your scripts when the DOM is ready. this is a good habit
$(function() {

// select all desired input fields and attach tooltips to them
$("#news_footer_tools :img").tooltip({

	// place tooltip on the right edge
	position: "center right",

	// use the built-in fadeIn/fadeOut effect
	effect: "fade",

	// custom opacity setting
	opacity: 0.7,

	// use this single tooltip element
	tip: '.imgtip'

});
});

//////////////////////////////////////////////////////////////////////////////////////////////
// Gallery scrollable
//////////////////////////////////////////////////////////////////////////////////////////////


// execute your scripts when the DOM is ready. this is a good habit 
$(function() { 
 
    // initialize scrollable 
    $("div.gallery_leftcol_scrollable").scrollable({ 
        vertical:true,  
        size: 3 
         
    // use circular plugin 
    }).circular();
     
    $("#photo_footer_tools :img").tooltip({

	// place tooltip on the right edge
	position: "center right",

	// use the built-in fadeIn/fadeOut effect
	effect: "fade",

	// custom opacity setting
	opacity: 0.7,

	// use this single tooltip element
	tip: '.photoimgtip'

});

}); 


//////////////////////////////////////////////////////////////////////////////////////////////
// Gallery image fading
//////////////////////////////////////////////////////////////////////////////////////////////



document.write("<style type='text/css'>#photo {visibility:hidden;}</style>");

function initImage() {
	imageId = 'photo';
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,0);
}
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 5;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 20);
		}
	}
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}
window.onload = function() {initImage()}


$(document).ready(function(){

	//Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide(); 

	//Switch the "Open" and "Close" state per click
	$("a.trigger").toggle(function(){
		$(this).addClass("active");
		}, function () {
		$(this).removeClass("active");
	});

	//Slide up and down on click
	$("a.trigger").click(function(){
		$(this).next(".toggle_container").slideToggle("slow");
	});

});
