function doOnLoad(){
	document.getElementById("searchbox").focus();
	search();
	var say=["How may I help you?","Welcome!","Hey! Whats up?","Green is Likely to Go Up!","Start Typing..."];
	bubble(say[Math.floor(Math.random()*say.length)]);
	bubblefloat();
}


function productLoad(){
	bubble("Take a Gander!");
	bubblefloat();
}

function loginLoad(){
//alert("s");
	bubble("Not so Fast!");
	bubblefloat();
	checkOldBrowser();
}

function registerLoad(){
	bubble("Just Sign Here!");
	bubblefloat();
	checkOldBrowser();
}

function aboutpremiumLoad(){
	bubble("Join the cool kids");
	bubblefloat();
}

function contactLoad(){
	bubble("Yes?");
	bubblefloat();
}

function thankyouLoad(){
	bubble("We will respond asap!");
	bubblefloat();
}

function changeBubble(texttochange){
	t1 = new OpacityTween(document.getElementById("bubble"),Tween.strongEaseOut, 100, 0, 1.5);
	t1.start();
	t1.onMotionFinished = function(){
		if(texttochange==""){
			return;
		}
		setTimeout("bubble('"+texttochange+"')",1000);
	};
}



var searchRares = true;
var searchNorms = false;
var searchSeasonals = false;
var searchSupers = false;

function clickCheck(whichCheck){

	if(whichCheck=="checkbox1"){
		if(searchRares==true){
			searchRares=false;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkbox.png)";
		}else{
			searchRares=true;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkboxChecked.png)";
		}
	}else if(whichCheck=="checkbox2"){
		if(searchNorms==true){
			searchNorms=false;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkbox.png)";
		}else{
			searchNorms=true;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkboxChecked.png)";
		}
	}else if(whichCheck=="checkbox3"){
		if(searchSeasonals==true){
			searchSeasonals=false;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkbox.png)";
		}else{
			searchSeasonals=true;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkboxChecked.png)";
		}
	}else if(whichCheck=="checkbox4"){
		if(searchSupers==true){
			searchSupers=false;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkbox.png)";
		}else{
			searchSupers=true;
			document.getElementById(whichCheck).style.backgroundImage = "url(images/checkboxChecked.png)";
		}
	}

	search();
	document.getElementById("searchbox").focus();
}

function search(){

	document.getElementById("loadingContainer").style.visibility="visible";
	document.getElementById("searchresults").innerHTML="";
	
	xmlhttp=new XMLHttpRequest();
		
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status==200) {
			document.getElementById("searchresults").innerHTML=xmlhttp.responseText;
			document.getElementById("loadingContainer").style.visibility="hidden";
		}
	}
	
	var searchRequest=document.getElementById("searchbox").value;
	
	var url="getValues.php?searchRequest="+searchRequest+"&searchRares="+searchRares+"&searchNorms="+searchNorms+"&searchSeasonals="+searchSeasonals+"&searchSupers="+searchSupers;
	xmlhttp.open("GET",url, true);
	xmlhttp.send();
	clicksTextbox=false;
}

function bubble(textInBubble){
	t1 = new OpacityTween(document.getElementById("bubble"),Tween.strongEaseOut, 0, 100, 3);
	t1.start();
	document.getElementById("bubble").innerHTML=textInBubble;
}

function bubblefloat(){
	t2 = new Tween(document.getElementById("bubbleContainer").style,'top',Tween.regularEaseOut,160,170,1.5,'px');
	t3 = new Tween(document.getElementById("bubbleContainer").style,'top',Tween.regularEaseOut,170,160,1.5,'px');
	t2.onMotionFinished = function(){
			setTimeout("t3.start();",600);
	};
	t3.onMotionFinished = function(){
			setTimeout("t2.start();",600);
	};	
	t2.start();
}


function getFavs(){
	document.getElementById("loadingContainer").style.visibility="visible";
	document.getElementById("searchresults").innerHTML="";
	
	xmlhttp=new XMLHttpRequest();
		
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status==200) {
			document.getElementById("searchresults").innerHTML=xmlhttp.responseText;
			document.getElementById("loadingContainer").style.visibility="hidden";
		}
	}
		
	var url="getFavs.php";
	xmlhttp.open("GET",url, true);
	xmlhttp.send();
	clicksTextbox=false;
}

function login(){

	xmlhttp=new XMLHttpRequest();
		
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status==200) {
			if(xmlhttp.responseText>""){
				wrongpass("Not Found!");
			}else{
				window.location="index.php";
			}
		}
	}
	
	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
	
	if(document.getElementById("username").value=="Username"){
		username="";
	}
	if(document.getElementById("password").value=="Password"){
		password="";
	}

	var url="loginScript.php?username="+username+"&password="+password;

	xmlhttp.open("GET",url, true);
	xmlhttp.send();
	clicksTextbox=false;
}

function wrongpass(texttochange){
	document.getElementById("bubble").innerHTML=texttochange;
	setTimeout("wrongpass('Try Again!');",1500);
}

function register(){
	
	xmlhttp=new XMLHttpRequest();
		
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status==200) {
			if(xmlhttp.responseText>""){
				wrongpass(xmlhttp.responseText);
			}else{
				window.location="index.php";
			}
			
		}
	}
	
	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
	var habboname = document.getElementById("habboname").value;
	var email = document.getElementById("email").value;
	
	if(document.getElementById("username").value=="Username"){
		username="";
	}
	if(document.getElementById("password").value="Password"){
		password="";
	}
	if(document.getElementById("habboname").value="Habbo Name (optional)"){
		habboname="";
	}
	if(document.getElementById("email").value="Email (optional)"){
		email="";
	}

	var url="registerScript.php?username="+username+"&password="+password+"&habboname="+habboname+"&email="+email;

	xmlhttp.open("GET",url, true);
	xmlhttp.send();
	clicksTextbox=false;
}

function favorite(itemName){

	xmlhttp=new XMLHttpRequest();
		
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status==200) {
			if(xmlhttp.responseText>""){
				alert(xmlhttp.responseText);
			}
			search();
		}
	}
	
	var url="favorite.php?itemName="+itemName;

	xmlhttp.open("GET",url, true);
	xmlhttp.send();

}

function favoritePage(itemName){

	xmlhttp=new XMLHttpRequest();
		
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status==200) {
			if(xmlhttp.responseText>""){
				alert(xmlhttp.responseText);
			}
			getFavs();
		}
	}
	
	var url="favorite.php?itemName="+itemName;

	xmlhttp.open("GET",url, true);
	xmlhttp.send();

}






















