// JavaScript Document
// Switch form input stuff
function checkTextFocus(thefield){
if (thefield.defaultValue==thefield.value) {
thefield.className = "focused textinput";
thefield.value = "";
}
} 

function checkTextBlur(thefield){
if (thefield.value=="") {
thefield.className = "blurred textinput";
thefield.value = thefield.defaultValue;
}
} 


// AJAX - Thanks to Rasmus

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function juicyFact(currID) {
	var mytime= new Date().getTime();
    http.open('POST', 'juicery_fact_ajax.php?time='+mytime+'&curr_id='+currID);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
		Cufon.refresh();
    }
}


