function comments(id, setStatus, isInline) {
	var o = 'comments-'+id;
	newselect = HttpRequest("http://www.rabatta.se/comments.php?id="+id);
	document.getElementById(o).innerHTML = newselect;
	if (!document.layers) {
		var currentObj = document.getElementById(o);
		if (setStatus) {
			currentObj.style.display = setStatus;
		} else {
			if (currentObj.style.display != 'block' && currentObj.style.display != 'inline') {
				if (isInline) { currentObj.style.display = 'inline'; }
				else { currentObj.style.display = 'block';return false;}
			} else {
				currentObj.style.display = 'none';
				return false;
			}
		}
	}
}
function rate(rating,id) {
	var o = 'coupon-'+id;
	newselect = HttpRequest("http://www.rabatta.se/rate.php?rating="+rating+"&id="+id);
	document.getElementById(o).innerHTML = newselect;
	if (rating == 1) document.getElementById(o).className = 'spr i-r-yes2';
	else if (rating == 0) document.getElementById(o+'b').className = 'spr i-r-no2';
}
function HttpRequest( url ) {
	var pageRequest = false
/*@cc_on
	 @if (@_jscript_version >= 5)
			try {
			pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e){
				 try {
				 pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
				 }
				 catch (e2){
				 pageRequest = false
				 }
			}
	 @end
@*/
	if (!pageRequest && typeof XMLHttpRequest != 'undefined')
		pageRequest = new XMLHttpRequest()
	
	if (pageRequest){
		pageRequest.open('GET', url, false);
		pageRequest.send(null);
		return( embedpage(pageRequest) );
	}
}

function embedpage(request) {
	if (window.location.href.indexOf("http")==-1 || request.status==200)
	return(request.responseText);
}

function showhide(id) {
	 var e = document.getElementById(id);
	 if(e.style.display == 'block') {
			e.style.display = 'none';
			//setcookiejs('stug_showoptions', '0', 365, '/', '', '');
			document.getElementById("box-search-options-text").innerHTML="Frivilliga uppgifter &raquo;";
	 } else {
			e.style.display = 'block';
			//setcookiejs('stug_showoptions', '1', 365, '/', '', '');
			document.getElementById("box-search-options-text").innerHTML="&laquo; Frivilliga uppgifter";
		}
}

function jada(post_type){
	if (post_type == 'store') {
		var div_suffix = '_store';
	} else {
		var div_suffix = '';
	}
	var name = $("#name"+div_suffix).val();
	var spam = $("#spam"+div_suffix).val();
	var email = $("#email"+div_suffix).val();
	var comment = $("#comment"+div_suffix).val();
	var post_id = $("#commentid"+div_suffix).val();
		
	var dataString = 'name='+ escape(name) + '&spam=' + escape(spam) + '&email=' + email + '&comment=' + escape(comment) + '&post_id=' + post_id + '&post_type=' + post_type;
	if(name=='' || email!='' || comment=='')
	{
			$("#flash"+div_suffix).show();
			$("#flash"+div_suffix).fadeIn(400).html('Fel!');
			return false;
	}
	else
	{
		$("#flash"+div_suffix).show();
		$("#flash"+div_suffix).fadeIn(400).html('<img src="http://www.rabatta.se/img/loading.gif" style="padding-right:8px;" />Laddar..');
		$.ajax({
		type: "POST",
		url: "http://www.rabatta.se/comments-save.php",
		data: dataString,
		cache: false,
		success: function(html){
		$("div#update"+div_suffix).append(html);
		$("div#update"+div_suffix).fadeIn("slow");
		$("#flash"+div_suffix).hide();
		if (post_type == 'store') {
			document.comment_store.reset();
		} else {
			document.comment.reset();
		}
	}
	});
	}return false;

}
