
jQuery.noConflict();

		 jQuery(document).ready(function(){

			initHome();

			jQuery('#menu img').click(function() { 
			
			//start function when any link is clicked

			jQuery("#content").fadeOut("fast");
			var content_show = jQuery(this).attr("title");
			
			jQuery.ajax({
							
			method: "get",url: "devstyxpages.php",data: "page="+content_show,

			beforeSend: function(){

			jQuery('#loading').fadeIn('fast');

			},
			//show loading just when link is clicked

			complete: function(){

			jQuery('#loading').fadeOut('fast');

			},
			//stop showing loading when the process is complete

			success: function(html){
						//so, if data is retrieved, store it in html

				//alert(html);

				jQuery('#content').fadeIn('slow'); //animation
				jQuery('#content').html(html); //show the html inside .content div

				refixLinks();
				initLytebox();

					 }
			 }); //close $.ajax(


			 }); //close click(
			 
			 
			 
			 
			 
	
			jQuery('#topleft-03_ img').click(function() { 
			
			//start function when any link is clicked

			jQuery("#content").fadeOut("fast");
			var content_show = jQuery(this).attr("title");
			
			jQuery.ajax({
							
			method: "get",url: "devstyxpages.php",data: "page="+content_show,

			beforeSend: function(){

			jQuery('#loading').fadeIn('fast');

			},
			//show loading just when link is clicked

			complete: function(){

			jQuery('#loading').fadeOut('fast');

			},
			//stop showing loading when the process is complete

			success: function(html){
						//so, if data is retrieved, store it in html

				//alert(html);

				jQuery('#content').fadeIn('slow'); //animation
				jQuery('#content').html(html); //show the html inside .content div

				refixLinks();

					 }
			 }); //close $.ajax(


			 }); //close click(	
	
	
			
			jQuery('#upcomingtourdates img').click(function() { 
			
			//start function when any link is clicked

			jQuery("#content").fadeOut("fast");
			var content_show = jQuery(this).attr("title");
			
			jQuery.ajax({
							
			method: "get",url: "devstyxpages.php",data: "page="+content_show,

			beforeSend: function(){

			jQuery('#loading').fadeIn('fast');

			},
			//show loading just when link is clicked

			complete: function(){

			jQuery('#loading').fadeOut('fast');

			},
			//stop showing loading when the process is complete

			success: function(html){
						//so, if data is retrieved, store it in html

				//alert(html);

				jQuery('#content').fadeIn('slow'); //animation
				jQuery('#content').html(html); //show the html inside .content div

				refixLinks();

					 }
			 }); //close $.ajax(


			 }); //close click(			
			
			
	
	
	
	
			 
		
		
		}); //close $(
		 
		 
function initHome(){

//alert('doing home');

jQuery.noConflict();

jQuery("#content").fadeOut("slow");

jQuery.ajax({
	method: "get",url: "devstyxpages.php",data: "page=home",

	beforeSend: function(){

	jQuery('#loading').fadeIn('fast');

	},
	//show loading just when link is clicked

	complete: function(){

	jQuery('#loading').fadeOut('fast');

	},
	//stop showing loading when the process is complete

	success: function(html){
	//so, if data is retrieved, store it in html

	//alert(html);

	
	jQuery('#content').html(html); //show the html inside .content div
	jQuery('#content').fadeIn('slow'); //animation
			 }
	 }); //close $.ajax(


}


function getNews(thenewsid){

jQuery.noConflict();
	
	//just for testing..
	
	//alert("The variable was: " + thenewsid);
	
	
	//actual news item function
	
	
	
	jQuery("#content").fadeOut("slow");
	
	jQuery.ajax({
	method: "get",url: "devstyxpages.php",data: "page=news&id="+thenewsid ,

	beforeSend: function(){

	jQuery('#loading').fadeIn('fast');

	},
	//show loading just when link is clicked

	complete: function(){

	jQuery('#loading').fadeOut('fast');

	},
	//stop showing loading when the process is complete

	success: function(html){
				//so, if data is retrieved, store it in html

				

				jQuery('#content').fadeIn('slow'); //animation
				jQuery('#content').html(html); //show the html inside .content div\

				refixLinks();


			 }
	 }); //close $.ajax(
}


/*
*
*
*	REFIX LINKS.
*	
*	This function scans through the DOM looking for 'a' tags, and rewrites them with
*	javascript:doLink in front, so that instead of going to the link..
*	it fires that url to the ajax script, that populates the content div instead.
*
*/



function refixLinks()
  {
    if (!document.getElementsByTagName) {
      return null;
    }
    
    var anchors = document.getElementsByTagName("a");
    
    for(var i=0; i < anchors.length; i++){
    
     	var a = anchors[i];
     	//alert(a);
     	var href = a.href;
      
	//var index = href.indexOf("#") + 1;
	var index = 0;
	
	//alert ("for link "+href+" index is " + href.indexOf("http://"));
	
	

	if (href.indexOf("http://") == -1){
	
	//alert('href is short: '+href);
	
	// this is a short link, so we need to prepend the site url/ onto it..
	
	//href = "http://www.styxworld.com/SilverStripe/"+href;
	
	//href = "http://174.143.76.176/"+href;
	
	}
	

	//	DO NOT MAKE INTO SELF-PORTING JS LINK....
	//	IF:
	//	GALLERIES PIC
	//	RSS LINK
	//	IS STORE, MEMBERS OFF-SITE LINK..
	//	IS !SILVERSTRIPE
	//	
		

	if (href.indexOf("galleries") != -1){
		
	// this IS a gallery page....
		
	} else if (href.indexOf("rss") != -1){
	
	//is an rss link..
	
	} else if (href.indexOf("doLink") != -1){
		
	//is already a doLink..
	
	} else if (href.indexOf("#") != -1){
	
	//is some form of Javascript, eg Lightbox;
	
	} else if (href.indexOf("store.styxworld.com") != -1){
	
	// is store...
	
	} else if (href.indexOf("members") != -1){
	
	//is members lounge
	
	} else if (href.indexOf("http://www.styxworld.com") == -1){
	
	
	
	
	} else {	
	
	href = "javascript:doLink('" +
	href.substring(index) + "');";
	a.setAttribute("href",href);
	
	}
        
     }   	

    
  }
  
  
  
 function doLink(theurl){
 
//alert ("sending "+theurl+" to the ajax script");

jQuery.noConflict();
 
 jQuery("#content").fadeOut("fast");
 
 jQuery.ajax({
 	method: "get",url: "devstyxpages.php",data: "innerpage="+theurl,
 
 	beforeSend: function(){
 
 	jQuery('#loading').fadeIn('fast');
 
 	},
 	//show loading just when link is clicked
 
 	complete: function(){
 
 	jQuery('#loading').fadeOut('fast');
 	
 	//alert('loading complete');
 
 	},
 	//stop showing loading when the process is complete
 
 	success: function(html){
 	//so, if data is retrieved, store it in html
 
 	//alert(html);
 
 	jQuery('#content').fadeIn('slow'); //animation
 	jQuery('#content').html(html); //show the html inside .content div
 	
 	refixLinks();
 
 
 
 			 }
	 }); //close $.ajax(
 
 
 }
 
 
 function doTourButton(){
 
//start function when any link is clicked

jQuery("#content").fadeOut("fast");

jQuery.ajax({

	method: "get",url: "devstyxpages.php",data: "page=tour",

	beforeSend: function(){

	jQuery('#loading').fadeIn('fast');

	},
	//show loading just when link is clicked

	complete: function(){

	jQuery('#loading').fadeOut('fast');

	},
	//stop showing loading when the process is complete

	success: function(html){
				//so, if data is retrieved, store it in html

		//alert(html);

		jQuery('#content').fadeIn('slow'); //animation
		jQuery('#content').html(html); //show the html inside .content div

		//refixLinks();

			 }
	 }); //close $.ajax(


 
 }
