// Hide all errors
//onerror=handleErr
function handleErr()
{
    return true
}

function popinfo(thepagetitle,thepagename,thewidth,theheight,thetop,theleft)
{
    var windowprops = "left="+theleft+",top="+thetop+",resizable=yes,scrollbars=yes,width="+thewidth+",height="+theheight
    var nW = window.open("My Bar", "theinfo", windowprops); 
    nW.location.href = thepagename; 
    nW = null;
}


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 makepublic(userid)
{
	document.getElementById("makepublic").src = "/areas/makepublic.asp?user_id="+userid
}
function makeprivate(userid)
{
	document.getElementById("makepublic").src = "/areas/makeprivate.asp?user_id="+userid
}
function opencomment()
{
    document.getElementById("addcomment").style.visibility = "visible";
    document.getElementById("addcomment").style.display = "block";
}
function doad()
{
    document.getElementById("adimage").src = "http://www.collegehumor.com"
}
function addcomment(drinkid)
{
	document.getElementById("commentframe").src = "../drinks/addcomment.asp?drinkid="+drinkid+"&commenttitle="+escape(document.getElementById("commenttitle").value)+"&commentdescription="+escape(document.getElementById("commentdescription").value);
    document.getElementById("addcomment").innerHTML = "<br>Thank you for your comment! We will add it soon...";
}

var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;

// Rollover for image Stars //
function rating(num){
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	if(!rated){
		s = num.id; // Get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				document.getElementById(i).className = "on";
				document.getElementById("rateStatus").innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				document.getElementById(i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off(me){
	if(!rated){
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				document.getElementById(i).className = "";
				document.getElementById("rateStatus").innerHTML = me.parentNode.title;
			}
		}else{
			rating(preSet);
			document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML;
		}
	}
}

// Send the rating information somewhere using Ajax or something like that.
function sendRate(sel){
	alert("Your rating was: "+sel.title);
}

