/**
 * This javascript code is included in all pages.
 * 
 * @author 	fabian.kuenzler@bookyto.com
 * @version $Id$
 */

//var environment = 'dev';
//var environment = 'int';
var environment = 'prod';

/**
 * Constants
 */

// cf. MasterConfiguration.php
switch(environment)
{
	case 'dev': 
		var WEB_ROOT_URL = 'http://192.168.1.33/bookyto/httpdocs/';
		break;
	case 'int':
		var WEB_ROOT_URL = 'http://www.fabiankuenzler.ch/bookyto/';
		break;
	case 'prod':
		var WEB_ROOT_URL = 'http://www.bookyto.ch/';
		break;
		
}

var IMAGE_URL = WEB_ROOT_URL + 'images/';


/**
 * google analytics 
 */
/*
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-13223586-1");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}
*/


/**
 * Misc
 */
$(document).ready(
	
	/**
	 * Check if IE6
	 */	
	function() 
	{
		if(isIE6())
		{
			// add html to side if the user has javascript activated 
			alert('no ie');
		}
		// remove this
		else
		{
			$("#ie6InfoPanel").hide();
		}		
	}
	
	
	
	
	
);

$(document).ready
(
    function()
    {
        // make submenu clickable
        $('.topicCategory').hover
        (
            function() 
            {
               $(this).css('cursor', 'pointer');
            }
        );
        $('.topicCategory').click
        (
            function()
            {
                window.location = $(this).find("a").attr("href");
                return false;
            }
        );        
    }
    
);


/**
 * Remove default string "Betrag" 
 */
function removeAmountText(element)
{
	if(element.value == 'Betrag')
	{
	   element.value = '';
	}
}


/**
 * Contact form dialog
 *
 * http://www.packtpub.com/article/jquery-ui-the-dialog-part2
 */
/*

$(document).ready
(
	function()
    {		 
		// define config object
		var dialogOpts = 
		{
			modal: true,
			overlay: 
			{
		 		background: "url(img/modal.png) repeat"
			},
			buttons: 
			{
				// "Ok!": doOk 
			},
			// height: "400px", 
			autoOpen: false
		};
	 
		// create the dialog
		$("#myDialog").dialog(dialogOpts);
		
		//define click handler for the button
		$("#NewsletterButton").click(
			function() 
			{
				//open the dialog
				$("#myDialog").dialog("open");
				
				// prevent the default action, e.g., following a link
				return false;
			}
		);
    }
);
*/


/*
$(document).ready(function() {
	var $dialog = $('<div></div>')
		.html('This dialog will show every time!')
		.dialog({
			autoOpen: false,
			title: 'Basic Dialog'
		});

	
	//define config object
	 var dialogOpts = {
		hide: true,
		modal: true,
		autoOpen: false,
		resizable: false,
	 };
	 
	 //create the dialog
	 
	
	
	var newsLetterDialog = $("#myDialog").dialog(dialogOpts);
	
	$('#NewsletterButton').click(function() {
		newsLetterDialog.dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
});
*/




//----------------------------------------------------------------------------------------------------------------------
// Library functions
//----------------------------------------------------------------------------------------------------------------------

/**
 * Checks if given var/object is existing (not null
 */
function exists(object)
{
    if(typeof(object) !== 'undefined' && object != null) {
       return true;
    }
    else
    {
        return false;
    }
}


/**
 * 
 * @param elementId
 * @param CSSClass
 * @return
 */
function changeCSSClass(elementId, CSSClass)
{
	document.getElementById(elementId).className = CSSClass;
}


/**
 * Highlight the form element which is in focus by changing its css clss.
 * 
 * Pages:
 * - about
 */
function highlightFormElement(elementId)
{
	document.getElementById(elementId).className = "highlight";  
}

/**
 * ... by changing its css clss.
 * 
 * Pages:
 * - about
 */
function resetFormElement(elementId)
{
 document.getElementById(elementId).className = "reset";  
}


function isIE6()
{
    return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined));
}




