/*// Default tracker mock
var track = function() {
    log('track: ' + arguments[0]);
};*/

// Init and change handlers
$.address.init(function(event) {
	$('a:not([href^=http])').address();
}).change(function(event) {
	//alert($.address.value());
	var path = $.address.path();
	var query = $.address.queryString();
	
	if (path == '/surfaceeditor/support') {
		window.location = "/surfaceeditor/support/";
	} else if (path == '/surfaceeditor/blog') {
		window.location = "/surfaceeditor/blog/";
	} else if (path == '/forum') {
		window.location = '/forum/';
	} else {
		open(query +"&target="+path.replace(/\/surfaceeditor/gi, ''));
	}
});

// Hides the page during initialization
document.write('<style type="text/css"> .page { display: none; } </style>');

// When the document loads do everything inside here ...
$(document).ready(function(){
	var links = new Array('#download_button a','h2 a', '#spec_button a', '#footer a', '#logo a', '.ajaxLink', '.download_lg_button a');
	
	
	$('#header_container a').click(function() { //start function when any link is clicked
		$(this).toggleClass('active');
	});
	
	var arLen = links.length;
	/*for(var i=0, len=arLen; i<len; i++)
	{
		$(links[i]).live('mouseover mouseout', function() { //start function when any link is clicked
			if (event.type == 'mouseover') {
    			// on mouseover
    			Cufon.refresh();
 			} else {
    			// on mouseout
    			Cufon.refresh();
  			}
		});
	}*/
	
}); //close $(


function open(query)
{
	if(query == "/")
	{
		query = "surface_editor"
	}
	$('#main').slideUp('slow');
   	$.ajax({
   	    method: 'get',url: 'ajax.php',data: query,
   	    beforeSend: function(){
	    }, //show loading just when link is clicked
   	    complete: function(){}, //stop showing loading when the process is complete
   	    success: function(html){ //so, if data is retrieved, store it in html
   	    //alert('a');
   	    $('#main_container').html(html); //show the html inside .content div
   	    $('#main').slideDown('slow'); //animation
   	    //Cufon.refresh();
   	    }
   	}); //close $.ajax(
}
