/*
*
* (C) BrillianceHosting 2007
*
**/

/**
* get the page with the ajax handler
*/
function ajaxGo (url) {
	
	var contentDiv  = 'ajax-content';
	var contentElem = document.getElementById(contentDiv);
	
	Effect.BlindUp(contentElem, {duration: 0.5, queue: 'end', afterFinish: function() { ajaxHandling(contentDiv, url); } } );

	// display the load indicator
	Effect.Appear('ajax-indicator', {duration: 0.3} );
	
	// change the site banner
	
	
}

/**
* execute the ajax call
*/
function ajaxHandling (contentDiv, url) {
	
	new Ajax.Updater(contentDiv, url, 
		{
			onComplete:function(){ 
				new Effect.Fade('ajax-indicator', {duration: 0.5} );
				new Effect.BlindDown(contentDiv, {duration: 0.5});
			},
			asynchronous:true, 
			evalScripts:true
		}
	);
	
}

/**
* change the site banner
*/
function ajaxChangeBanner () {
	
	bannerDiv  = 'ajax-banner';
	bannerElem = document.getElementById(bannerDiv);
	getBanner(bannerDiv);
	//Effect.Fade(bannerDiv, {duration: 0.0, queue: 'end', afterFinish: function() { getBanner(bannerDiv); } } );
	
}

/**
* get the site banner
*/
function getBanner (bannerDiv) {
	
	var url = base_URI+'/static/changeBanner.php';
	
	new Ajax.Updater(bannerDiv, url, 
		{
			onComplete:function() { 
				new Effect.Appear(bannerDiv, {duration: 0.5});
			},
			asynchronous:true, 
			evalScripts:true
		}
	);
	
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function doPost(target, url, params) {

$.post(url,
   { debit: params },
   function(data){

     if ( data == '' ) {
     	document.enquete.submit();
     } else {
 	    document.getElementById(target).innerHTML = data;
 	 }
     
     
     
   }
 );

}

function activate(element, lm) {
	['shared', 'business', 'reseller', 'exchange', 'dedigo'].each(function(elm) {
		$(elm+'_link').setStyle( { 'font-weight' : 'normal', 'text-decoration' : 'none' } );
		$(elm).hide();
	});
	$(lm).setStyle( { 'font-weight' : 'bold', 'text-decoration' : 'underline' } );
	$(element).show();
}