function postComments(){
	var url = '/inc/app/postcomment.php';
	var userid = $('userid').value;
	var postid = $('postid').value;
	var comment = $('comment_post').value;
	
	$('pageLoader').startWaiting('blackWaiting');
	if(userid != '' && postid != '' && comment != ''){
		new Ajax.Request(url, {
	  		method: 'post',
	  		parameters: { userid:userid, postid:postid, comment:comment},
	  		onSuccess: function(transport){
	    		var response = transport.responseText || "no response text";
	    		if(response == 'true'){
	    			$('pageLoader').stopWaiting();
	    			$('comment_post').value = "";
	    			window.parent.location.reload();
	    		}
	    		else if(response != 'false'){
	    			url = '/inc/app/send.php';
	    			new Ajax.Request(url, {
	    		  		method: 'post',
	    		  		parameters: { email:response, emailtype:'activation'},
	    		  		onSuccess: function(transport){
	    		  			$('pageLoader').stopWaiting();
	    	    			window.parent.openLightboxActivate('/ui/activate.php',response,'activation');
	    		   		}
	    		  	});
	    		}
	    		else {
	    			$('pageLoader').stopWaiting();
	    			header = 'Adding Comment Failed';
	    			response = 'Your comment could not be added, something went wrong, try again.';
	      			window.parent.openLightboxAlert(header, response);
	    		}
	   		}
	  	});
	}
}

function recommendPost(id){
	var url = '/inc/app/postrecommend.php';
	if(id != ''){
		$('pageLoader').startWaiting('blackWaiting');
		new Ajax.Request(url, {
	  		method: 'post',
	  		parameters: { id:id },
	  		onSuccess: function(transport){
	    		var response = transport.responseText || "no response text";
	    		if(response != 'false'){
	    			$('pageLoader').stopWaiting();
	      			document.getElementById('updateRecommend_'+id).innerHTML = response;
	    		}
	   		}
	  	});
	}
}

function flagPost(id){
	var url = '/inc/app/postflag.php';
	if(id != ''){
		$('pageLoader').startWaiting('blackWaiting');
		new Ajax.Request(url, {
	  		method: 'post',
	  		parameters: { id:id },
	  		onSuccess: function(transport){
	    		var response = transport.responseText || "no response text";
	    		if(response != 'false'){
	    			$('pageLoader').stopWaiting();
	      			document.getElementById('updateFlag_'+id).innerHTML = response;
	    		}
	    		else {
	    			$('pageLoader').stopWaiting();
	    			header = 'Flagging Failed!';
	    			response = "Could Not Flag This Comment, You May Have Flagged Too Many! IP Recorded!";
	      			window.parent.openLightboxAlert(header, response);
	    		}
	   		}
	  	});
	}
}

function buzz(title,url){
	window.open('http://www.google.com/reader/link?title='+encodeURIComponent(title)+'&url='+encodeURIComponent(url),'buzz', 'toolbar=0, status=0, width=626, height=436, scrollbars=1');  
	return false;
}

function delicious(url, title, subtitle, tags){
	window.open('http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&notes='+subtitle+'&tags='+tags,'delicious', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false;
}

function digg(url, title, description, media){
	window.open('http://digg.com/submit?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title) + '&&media='+media,'digg', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false;
}

function facebook(url, title) {  
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'facebook', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false; 
} 

function google(url,title,content){
	window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&annotation='+content,'google', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false; 
}

function myspace(title, content, url, location){
	window.open('http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(title)
	    + '&c=' + encodeURIComponent(content) + '&u=' + encodeURIComponent(url) + '&l=' + location,'myspace', 'toolbar=0, status=0, width=626, height=436, scrollbars=1');
    return false;
}

function stumbleupon(url, title){
	window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title),'stumbleupon', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false;
}

function reddit(url){
	window.open('http://www.reddit.com/submit?url='+encodeURIComponent(url),'reddit', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false;
}

function technorati(url){
	window.open('http://technorati.com/faves?add='+encodeURIComponent(url),'technorati', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false;
}

function tweet(title){
	window.open('http://twitter.com/home?status='+encodeURIComponent(title),'twitter', 'toolbar=0, status=0, width=626, height=436, scrollbars=1'); 
	return false;
}

function postProduct(){
	var url = '/inc/app/productcomment.php';
	var userid = $('userid').value;
	var productid = $('productid').value;
	var comment = $('comment_post').value;
	
	$('pageLoader').startWaiting('blackWaiting');
	if(userid != '' && productid != '' && comment != ''){
		new Ajax.Request(url, {
	  		method: 'post',
	  		parameters: { userid:userid, productid:productid, comment:comment},
	  		onSuccess: function(transport){
	    		var response = transport.responseText || "no response text";
	    		if(response == 'true'){
	    			$('pageLoader').stopWaiting();
	    			$('comment_post').value = "";
	    			window.parent.location.reload();
	    		}
	    		else if(response != 'false'){
	    			url = '/inc/app/send.php';
	    			new Ajax.Request(url, {
	    		  		method: 'post',
	    		  		parameters: { email:response, emailtype:'activation'},
	    		  		onSuccess: function(transport){
	    		  			$('pageLoader').stopWaiting();
	    	    			window.parent.openLightboxActivate('/ui/activate.php',response,'activation');
	    		   		}
	    		  	});
	    		}
	    		else {
	    			$('pageLoader').stopWaiting();
	    			header = 'Adding Comment Failed';
	    			response = 'Your comment could not be added, something went wrong, try again.';
	      			window.parent.openLightboxAlert(header, response);
	    		}
	   		}
	  	});
	}
}

function myOnRateAdmin(event){
	var pid = $('productid').value;
	var url = '/inc/app/rateproduct.php?pid='+pid;
	
	$('pageLoader').startWaiting('blackWaiting');
	new Ajax.Request(url, {
	    parameters: event.memo,
	    onSuccess: function(xhr) {
			$('pageLoader').stopWaiting();
	    }
	});
}

function myOnRateUser(event){
	var pid = $('productid').value;
	var url = '/inc/app/rateproduct.php?pid='+pid;
	
	$('pageLoader').startWaiting('blackWaiting');
	new Ajax.Request(url, {
	    parameters: event.memo,
	    onSuccess: function(xhr) {
			$('pageLoader').stopWaiting();
	    }
	});
}

function pullproduct(id){
	var url = '/inc/app/addproduct.php';
	
	$('pageLoader').startWaiting('blackWaiting');
	new Ajax.Request(url, {
		method: 'post',
  		parameters: { id:id, mode:'pull'},
  		onSuccess: function(transport){
  			var response = transport.responseText || "no response text";
  			if(response != "false"){
  				html = '<img src="http://www.thenerdstop.com/images/buttons/pulled_product.png" />';
  				document.getElementById('pull_image').innerHTML = html;
  				document.getElementById('count_pulls').innerHTML = response;
  				$('pageLoader').stopWaiting();
  			}
  			else {
  				$('pageLoader').stopWaiting();
  			}
	    }
	});
}

function subscribeproduct(seriescode){
	var url = '/inc/app/addproduct.php';
	
	$('pageLoader').startWaiting('blackWaiting');
	new Ajax.Request(url, {
		method: 'post',
  		parameters: { seriescode:seriescode, mode:'subscribe'},
  		onSuccess: function(transport){
  			var response = transport.responseText || "no response text";
  			if(response == "true"){
  				html = '<img src="http://www.thenerdstop.com/images/buttons/product_subscribe_edit.png" />';
  				document.getElementById('subscribe_image').innerHTML = html;
  				$('pageLoader').stopWaiting();
  			}
  			else {
  				$('pageLoader').stopWaiting();
  			}
	    }
	});
}

function pullremove(id){
	var url = '/inc/app/addproduct.php';
	
	$('pageLoader').startWaiting('blackWaiting');
	new Ajax.Request(url, {
		method: 'post',
  		parameters: { id:id, mode:'removepull'},
  		onSuccess: function(transport){
  			var response = transport.responseText || "no response text";
  			if(response != "false"){
  				html = '<a href="javascript:void(0)" onclick="pullproduct(\''+id+'\');"><img src="http://www.thenerdstop.com/images/buttons/pull_product.png" /></a>';
  				document.getElementById('pull_image').innerHTML = html;
  				document.getElementById('count_pulls').innerHTML = response;
  				$('pageLoader').stopWaiting();
  			}
  			else {
  				$('pageLoader').stopWaiting();
  			}
	    }
	});
}