// JavaScript Document

// Melody Dialogue Functions 


							
jQuery(document).ready(function($) {
								
								
var home_url = 'http://www.melodydialogue.org/wp-content/themes/melody/'; 		
		
		$("h2.trigger").toggle(function(){
		$(this).addClass("active");
		}, function () {
		$(this).removeClass("active");
			});
	
	
	$("h2.trigger").click(function(){
		$("#welcome-text").slideToggle("slow");
	});
								
								
								


//Tabs
$("#tabs").tabs();

$('.highlight-photo, .photo-box').cycle('fade');


$('.scroll-pane').jScrollPane();

//Artists

$(".artist-thumb img").hover(
	  function(){
		$(this).fadeTo("fast", 0.25);
		//$(this).find("div.landing-caption").fadeIn(400);
	  },
	  function(){
		   $(this).fadeTo("fast", 1);

		//$(this).find("div.landing-caption").fadeOut(400);
	  }
	);


/*$("a.artist-thumb").click(function(){ 
	

		//loadurl('wp-content/themes/melody/AJAX/artist-info.php?id='+$(this).attr("id").slice(11)+'');
		return false;

}); */


var url_param = $(document).getUrlParam('id');

if(url_param != null) {
loadurl(home_url+'AJAX/artist-info.php?id='+url_param+'');
}
//Get our elements for faster access and set overlay width
  var div = $('div.sc_menu'),
               ul = $('ul.sc_menu'),
               // unordered list's left margin
               ulPadding = 15;

  //Get menu width
  var divWidth = div.width();

  //Remove scrollbars
  div.css({overflow: 'hidden'});

  //Find last image container
  var lastLi = ul.find('li:last-child');
  
  //When user move mouse over menu
  div.mousemove(function(e){

    //As images are loaded ul width increases,
    //so we recalculate it each time
    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
    div.scrollLeft(left);
  });

});




//Ajax
function loadurl(dest) { 

 
try { 
        // Moz supports XMLHttpRequest. IE uses ActiveX. 
        // browser detction is bad. object detection works for any browser 
        xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); 
} catch (e) { 
        // browser doesn't support ajax. handle however you want 
} 
 
// the xmlhttp object triggers an event everytime the status changes 
// triggered() function handles the events 
xmlhttp.onreadystatechange = triggered; 
 
// open takes in the HTTP method and url. 
xmlhttp.open("GET", dest); 
 
// send the request. if this is a POST request we would have 
// sent post variables: send("name=aleem&gender=male) 
// Moz is fine with just send(); but 
// IE expects a value here, hence we do send(null); 
xmlhttp.send(null); 
} 
 
function triggered() { 
// if the readyState code is 4 (Completed) 
// and http status is 200 (OK) we go ahead and get the responseText 
// other readyState codes: 
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive 
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { 
        // xmlhttp.responseText object contains the response. 
        document.getElementById("output").innerHTML = xmlhttp.responseText;
			$.scrollTo( document.getElementById("output"), 600);

		

	} 
} 




