function go(dest) {
window.location.href = dest
}

function doClear(theText) {
    if (theText.value == theText.defaultValue) {
    	theText.value = ""
    }
}

function insertMsg(type, msg) {
    $("#msg_img").attr("src","pictures/message/"+type+"_msg.gif");
    $("#msg_txt").html(msg);
    $("#msg").slideDown("slow");
}

/*
AJAX FUNCTIONS
*/

function saveOpinion(opinion, model_type, model_id, user_id){

	if(user_id !== null && user_id != "null" && user_id != "") {
	    
    	if(opinion != "like" && opinion != "unlike") {
    	    Boxy.alert("Your opinion "+opinion+" is unknown!", null, {title: 'Your opinion!'});
    	    return false;
    	}
    	likeclass = model_type+"_"+model_id;
    	$.ajax({
    		type: "POST",
            url: "controller/misc/opinion",
    	    data: "opinion="+opinion+"&model_type="+model_type+"&model_id="+model_id,
    		dataType: "json",
    		timeout: 5000,
    		cache:false,
    		success: function(j){
                if(j) {
                    $("#"+likeclass+"_like_you").toggle();
                    $("#"+likeclass+"_like").toggle(); 
                    $("#"+likeclass+"_unlike").toggle();
                }else {
            	    Boxy.alert("Ooops! We can't process your request at the moment. Please try again later...", null, {title: 'Your opinion!'});
                }
    		},
    		error: function(XMLHttpRequest, textStatus, errorThrown){
        	    Boxy.alert("Error: "+textStatus, null, {title: 'Your opinion!'});
    		}
    	});
    }else {
        Boxy.alert('Please <a href="/">login to like stuff!</a>', null, {title: 'Please login...'});
    	return false;
    }
}

function showLikes(model_type, model_id) {
    text = "You would like to see the people who likes the "+model_type+", but unfortunately this feature is not available yet. We are working hard to create it though... :)"
    Boxy.alert(text, null, {title: 'Feature not available...'});
	return false;    
}