/**
 * @author db
 */

//create a dummy console if firebug not installed
if( window.console === undefined  ){
    var console = function(){
        this.time = function(){};
        this.timeEnd = function(){};
        this.group = function(){};
        this.groupEnd = function(){}; 
		this.dir = function(x){};
		this.log = function(){};      
    };
    console = new console();
}

/**  base url  **/
var get_url = window.location.href;
var hold_url = get_url.split("/");
var base_url = '';

hold_url[2] = hold_url[2].replace('www.','');
//alert(hold_url[2]);
if (hold_url[2] == 'tonybuntu' || hold_url[2] == 'localhost' || hold_url[2] == 'clone' || hold_url[2] == 'tachibuntu'|| hold_url[2] == '192.168.1.101') {
	base_url = "http://" + hold_url[2] + "/gold-book.net/";
}else {
	base_url = "http://" + hold_url[2] + "/";
}



$(function() {
	
	//menu
	//var myMenu = new MenuMatic({ orientation:'vertical' });	
	
	//contact
	//$('#contact_stage').hide();
	
	//make clicks work on sub nav
	$('.subnav a').live('click', function(){
		alert('click click');
	});
	
	//Contact Box
	$('#contact_send').live('click', function(e){
		
		var name = $('#contact_box input[name=name]').val();
		var email = $('#contact_box input[name=email]').val();
		var message = $('#contact_box textarea').val();
		//var type = $('#contact_box input[name=contact_type]');
		$('#contact_form').html('<img src="'+base_url+'images/loader.gif" alt="loading.." />');
		$.post(base_url + 'contact', {name:name,email:email,message:message}, function(data){
			$('#contact_box').html(data);
			var g = $('#contact_box .win').length;
			var b = $('#contact_box .fail').length;
			if((g+b)>0){
				$('#contact_stage').show();
			}
			//alert(g+'!~!'+b);
		});
		console.log('send contact for ' + name);
	}); 
	$('#contact_tab').live('click', function(e){
		e.preventDefault();
		$('#contact_stage').slideToggle(400);
	});
	$('#contact_close').live('click', function(){
		
		$.post(base_url + 'contact', {}, function(data){
			$('#contact_box').html();
		});
	});
	$('.content').addClass('box-shadow round tiny');
	$('#nav ul li').addClass('box-shadow round tiny');
	$('.subnav li a').addClass('round small');
	// $('#nav ul li').live('mouseover', function(){ 
	// 	$(this).parent().find('.subnav').stop().slideToggle();
	// });
});

