function openCloud() {
	var link, url = window.location.href;
	var pieces = new Array(); 
	pieces = url.split('#');
	if (pieces.length==1) link = 'home';
	else link = pieces[pieces.length-1];
	cloud(link);
}
function tail(element, show) {
	var elm = document.getElementById(element);
	if (show == true) {
		elm.style.display = 'none'; //block
	} else {
		elm.style.display = 'none';
	}
}
function cloud(element) {
	var cloud = document.getElementById('cloud');
	var tail = document.getElementById('tail');
	cloud.style.display = 'block';
	tail.style.display = 'block';
	
	document.getElementById('home').style.display = 'none';
	document.getElementById('why').style.display = 'none';
	document.getElementById('references').style.display = 'none';
	document.getElementById('licenses').style.display = 'none';
	document.getElementById('get').style.display = 'none';
	document.getElementById('demo').style.display = 'none';
	document.getElementById('contact').style.display = 'none';
	
	switch (element) {
		case 'home':
			cloud.style.height = '135px';
			tail.style.left = '150px';
			tail.style.bottom = '113px';
			tail.style.height = '158px';
		break;
		case 'why':
			cloud.style.height = '230px';
			tail.style.left = '212px';
			tail.style.bottom = '85px';
			tail.style.height = '91px';
		break;
		case 'references':
			cloud.style.height = '230px';
			tail.style.left = '286px';
			tail.style.bottom = '85px';
			tail.style.height = '91px';
		break;
		case 'licenses':
			cloud.style.height = '230px';
			tail.style.left = '365px';
			tail.style.bottom = '85px';
			tail.style.height = '91px';
		break;
		case 'get':
			cloud.style.height = '230px';
			tail.style.left = '440px';
			tail.style.bottom = '85px';
			tail.style.height = '91px';
		break;
		case 'demo':
			cloud.style.height = '165px';
			tail.style.left = '440px';
			tail.style.bottom = '85px';
			tail.style.height = '156px';
		break;
		case 'contact':	
			cloud.style.height = '185px';
			tail.style.left = '510px'; 
			tail.style.bottom = '85px';
			tail.style.height = '136px';
		break;
	}
	element = document.getElementById(element); 
	
	element.style.display = "block";
	
	
	var content = element.children;
	for (var i = 1; i < (content.length -1); i++) {	
		content[i].style.display = 'none';
	}
	element.children[0].style.display = "block";
}
function refTxt(elm, n) {
	var content = document.getElementById(elm).getElementsByTagName('div');
	var elm = 0;
	for (var i = 0; i < (content.length -1); i++) {	
		if (content[i].style.display == 'block') { 
			content[i].style.display = 'none';
			elm = i;
		}
	}
	elm = elm + n;
	$('.pagenb .nb').text(elm+1);
	if (elm < 0) elm = (content.length -2);
	if (elm > (content.length -2)) elm = 0;
	content[elm].style.display = 'block';
}

function setOpacity(domId, val) {
	obj = document.getElementById(domId);
	obj.style.MozOpacity = val;
	obj.style.opacity = val/10;
	obj.style.filter = 'alpha(opacity=' + val*10 + ')';
}

function fade(domId){
	obj = document.getElementById(domId); //Get the Element 
	if(obj.style.display == "none") return false; //Return false if the element is already hidden 
	var alpha = 10; //Set the initial value of alpha to 10 (Opaque) 
	
	function f(){ //Internal function  
		alpha--;  //Decrement the alpha value  
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha  
		if(alpha > -1){ //If alpha is still bigger than -1 then..   
			setTimeout(f, 10); //..then call the function again after 100 milliseconds  
		} else { //otherwise..   
			obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it  
			return true;
		}
	}
	setTimeout(f, 10); 
	//This is where we call the f() function for the first time
}

function appear(domId){
	obj = document.getElementById(domId); //Get the element 
	if(obj.style.display != "none") return false; //Return if it is already being displayed 
	obj.style.display = ''; //Un-hide the object before its animation 
	var alpha = 0; //Set the initial value of alpha to 0 (invisible) 
	function a(){ //Internal function  
		alpha++; //Increment alpha  
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha  
		if(alpha < 11)setTimeout(a, 10);
		
		/*Till alpha is 10, keep calling thea() function after 100 milliseconds */
	}
	setTimeout(a, 10); //This is where we call the a() function for the first time
}
