
function call(type, vote, id)
{
	$.ajax({
	  url: '/_ajax.php?a=vote&type=' + type + '&id=' + id + '&vote=' + vote,
	  success: function(data) {
		if(data != "already")
		{
			$("#idea_actions_"+id).html("Thanks for your vote");
			$('#idea_score_'+id).html(data);
		}
		else
		{
			$("#idea_actions_"+id).html("Sorry, you have already<br /> shown emotion for this shirt.");
		}
	  }
	});	
	
}


function love(type, id)
{
	call(type, 'love', id);
}

function like(type, id)
{
	call(type, 'like', id);
}

function hate(type, id)
{
	call(type, 'hate', id);
}


// --- FIX PNG FOR IE6 --- //
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
	{
	   var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
				  + " style=\"" + "width:" + myImage.width 
				  + "px; height:" + myImage.height 
				  + "px;" + imgStyle + ";"
				  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
	}
}

$(document).ready(function() {
	$(".color_block a").click(function(e) {
		$("body").css("background-color", $(this).css("background-color") );
		$.cookie('bgcolor', $(this).css("background-color"), { expires: 365, path: '/'  });
	});
});


/*  ------------------------------------------------------------------
Plugin/Cookie ---------------------------------------------------- */
$.cookie = function(name, value, options) {
	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
	} else { // only name given, get cookie
		var cookieValue = null;
		if (document.cookie && document.cookie !== '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};

