$('div.side_col_tab a').corner('8px bottom');
$('div.newspanel_status').corner('8px bottom');
$('h1.title').corner('8px top');
$('div.newspanel_right h1').corner('8px tr');
$('div.right_header').corner('8px top');
$('div.rightbox').corner('8px bottom');
$('div.fp_header').corner('8px top');
$('div.fpost_bottom').corner('8px bottom');
$('div.list_title').corner('8px');
$('div.topper_curve').corner('8px top');
$('div.bottomcurve').corner('8px bottom');



function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

function noDisp(idDiv) {
var div = document.getElementById("sb_" + idDiv);
var header = document.getElementById("hb_" + idDiv);
var the_div = "sb_" + idDiv;

if (div.style.display == "none") {
	$(div).slideDown('normal'); header.setAttribute('class','side_col_header');
	$.post("/showpanels.php",{the_div:the_div});
} else {
	$(div).slideUp('normal'); header.setAttribute('class','side_col_header_alt');
	$.post("/hidepanels.php",{the_div:the_div});
}

}

function hidethepanel(id){
  var o = document.getElementById(id);
  var panelID = "#" + id;
  if (o) {$(panelID).hide(); } else {
}
}


function hideExtradiv(iddiv) {
	var div = document.getElementById(iddiv);
	if (div.style.display == "none") {	
	$(div).slideDown('normal');
	} else {
	$(div).slideUp('normal');
	}
}

function swaplistdivs(div1, div2, div3) {
	var d1 = document.getElementById(div1);
	var d2 = document.getElementById(div2);
	var d3 = document.getElementById(div3);	
	
	var d1but = div1 + "_but";
	d1butc = document.getElementById(d1but);
	d1butc.setAttribute('class','tab_a');
	
	var d2but = div2 + "_but";
	d2butc = document.getElementById(d2but);
	d2butc.setAttribute('class','tab_b');	

	var d3but = div3 + "_but";
	d3butc = document.getElementById(d3but);
	d3butc.setAttribute('class','tab_b');

	$(d2).hide();
	$(d3).hide();
	$(d1).fadeIn("slow");

}

function logmein() {
	var user = document.loginform.username.value;
	var pass = document.loginform.password.value;
	
      $("#login_box").fadeOut("slow", function (){
		$("#login_box").show();
		$("#login_box").html("<img src='/imagesv9/loading.gif' style='margin: 40px 0px 0px 16px' />");											
    });
	  
	 
	 $.post("/nblogin.php",
    {user:user,pass:pass},
    function(data)
    {
	userp = "a."+ user + "_links";
	userp2 = "div."+ user + "_panel";
     $("#login_box").html(data);
	 $("p.usernm").html(user);
	 $(userp).show();
	 $(userp2).show();
	 $("div.pan_user").show();
	 $("div.pan_anon").hide();
    });
}

function logmemout(user) {
	 $("#login_box").fadeOut("slow", function (){
		$("#login_box").show();
		$("#login_box").html("<img src='/imagesv9/loading.gif' style='margin: 40px 0px 0px 16px' />");											
    });

	$.post("/nblogout.php",{},function(data)
    {
	userp = "a."+ user + "_links";
	userp2 = "div."+ user + "_panel";
	 $("#login_box").html(data);
	 $("p.usernm").html("Guest");
	 $(userp).hide();
	 $(userp2).hide();
	 $("div.pan_user").hide();
	 $("div.pan_anon").show();
	 document.location = "/index.php";
    });
}

function processPoll(poll_id, topic_id) {
	for( i = 0; i < document.poll_form.vote.length; i++ ) {
		if( document.poll_form.vote[i].checked == true ) {
		vote = document.poll_form.vote[i].value;
		break; }}
		
	 $("#pollvote").fadeOut("slow", function (){
		$("#pollvote").show(); $("#pollvote").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
    });

	$.post("/readvote.php",{poll_id:poll_id, vote:vote, topic:topic_id},function(data)
    { $("#pollvote").html(data); });	
}

function processPoll_side(poll_id, topic_id) {
	for( i = 0; i < document.poll_form2.vote.length; i++ ) {
		if( document.poll_form2.vote[i].checked == true ) {
		vote = document.poll_form2.vote[i].value;
		break; }}
		
	 $("#pollvote1").fadeOut("slow", function (){
		$("#pollvote1").show(); $("#pollvote1").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
    });

	$.post("/readvote.php",{poll_id:poll_id, vote:vote, topic:topic_id},function(data)
    { document.location='/topic/' + topic_id; });	
}

function processPost_review(topic_id, page_counter, review_id, colour) {

	var post_text = document.form.post_text.value;
	
	if (post_text == "") {
		alert("Please type something...");
	} else {

	$("#reply_box").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/processpost_review.php",{topic_id:topic_id, page_counter:page_counter, post_text:post_text, review_id:review_id, color:colour},function(data)
    {
		$("#reply_box").hide();
		data = stripslashes(data);
		$("#reply_box").html(data);
$('div.fpost_bottom').corner('bottom');
$('div.fp_header').corner('top');		
		
		$("#reply_box").show();

		});	
	
	}
}

function process_status() {

	var status = document.status_form.status.value;
	
	if (status == "") {
		alert("Please type something...!");
	} else {

	$("#statusbox").html("<center><img src='/imagesv9/loading.gif' style='margin: 10px auto' /></center>");											

	$.post("/process_status.php",{status:status},function(data)
    {
		$("#statusbox").hide();
		$("#statusbox").html(data);
		$("#statusbox").fadeIn("slow");
    });	
	
	}
}


function switchVid(id) {
	$("#vidbox").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
	
	$.post("/switchvid.php",{id:id},function(data)
    {
	$("#vidbox").html(data);
	$("#vidbox").show();
    });	
	
}

function processPost_preview(topic_id, page_counter, preview_id, colour) {

	var post_text = document.form.post_text.value;
	
	if (post_text == "") {
		alert("Please type something...");
	} else {


	 $("#reply_box").fadeOut("slow", function (){
		$("#reply_box").show();
		$("#reply_box").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
    });

	$.post("/processpost_preview.php",{topic_id:topic_id, page_counter:page_counter, post_text:post_text, preview_id:preview_id, color:colour},function(data)
    {
		$("#reply_box").hide();
		data = stripslashes(data);
		$("#reply_box").html(data);
$('div.fpost_bottom').corner('bottom');
$('div.fp_header').corner('top');		
		$("#reply_box").fadeIn("slow");
    });	
	
	}
}

function changeNews(npage) {
	$("#newsybox").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/changenews.php",{npage:npage},function(data)
    {
	 $("#newsybox").hide();
	 $("#newsybox").html(data);
     $("#newsybox").slideDown ("slow");
    });	
	
}


function processPost_blog(topic_id, page_counter, blogid, colour) {

	var post_text = document.form.post_text.value;
	
	if (post_text == "") {
		alert("Please type something...");
	} else {


	$("#reply_box").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/processpost_blog.php",{topic_id:topic_id, page_counter:page_counter, post_text:post_text, blogid:blogid, color:colour},function(data)
    {
		$("#reply_box").hide();
		data = stripslashes(data);
		$("#reply_box").html(data);
$('div.fpost_bottom').corner('bottom');
$('div.fp_header').corner('top');		
		$("#reply_box").fadeIn("slow");
    });	
	
	}
}

function processPost_readerrev(topic_id, page_counter, rid, colour) {

	var post_text = document.form.post_text.value;
	
	if (post_text == "") {
		alert("Please type something...");
	} else {


	$("#reply_box").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/processpost_readerrev.php",{topic_id:topic_id, page_counter:page_counter, post_text:post_text, rid:rid, color:colour},function(data)
    {
		$("#reply_box").hide();
		data = stripslashes(data);
		$("#reply_box").html(data);
$('div.fpost_bottom').corner('bottom');
$('div.fp_header').corner('top');		
		$("#reply_box").fadeIn("slow");
    });	
	
	}
}

function processPost_tourney(topic_id, page_counter, tid, colour) {

	var post_text = document.form.post_text.value;
	
	if (post_text == "") {
		alert("Please type something...");
	} else {


	$("#reply_box").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/processpost_tourney.php",{topic_id:topic_id, page_counter:page_counter, post_text:post_text, tid:tid, color:colour},function(data)
    {
		$("#reply_box").hide();
		data = stripslashes(data);
		$("#reply_box").html(data);
$('div.fpost_bottom').corner('bottom');
$('div.fp_header').corner('top');		
		$("#reply_box").fadeIn("slow");
    });	
	
	}
}

function changefeed(type) {
	
	$("#feedbox").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/show_feeds.php",{type:type},function(data)
    {
		$("#feedbox").hide();
		$("#feedbox").html(data);
		$("#feedbox").fadeIn("slow");
    });	
	
}

function setview(type) {
		$.post("/setview.php",{type:type},function(data)
		{
		alert("Your default homepage view has been set for this computer. Thanks!");
		});			
}

function redobox(feed,box) {
		var rbox = "#" + box;
		$(rbox).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
		setTimeout("",2000);
		$.post("/redobox.php",{feed:feed, box:box},function(data)
		{
		$(rbox).html(data);		
		$(rbox).fadeIn("slow");		
		});			
}

function redofeed(box,file) {
		var rbox = "#" + box;
		$(rbox).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
		$.post(file,{box:box},function(data)
		{
		$(rbox).html(data);		
		$(rbox).fadeIn("slow");		
		});			
}

function processAnon(topic_id) {

	var post_text = document.form.post_text.value;
	var anon_name = document.form.anon_name.value;
	
	if (anon_name == "") {
		alert("Please enter your name.");
		return;
	}
	
	if (post_text == "") {
		alert("Please type something...");
	} else {
		$("#reply_txtarea").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
		$.post("/process_anon.php",{topic_id:topic_id, post_text:post_text, anon_name:anon_name},function(data) {
		data = stripslashes(data);
		$("#reply_txtarea").html(data);
		$("#reply_txtarea").show();
		});
		}

}

function processPost(topic_id, page_counter, forum, colour) {

	var post_text = document.form.post_text.value;
	
	if (post_text == "") {
		alert("Please type something...");
	} else {
		
		$("#reply_box").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

		$.post("/processpost.php",{topic_id:topic_id, page_counter:page_counter, post_text:post_text, forum:forum, color:colour},function(data)
		{
		$("#reply_box").hide();
		data = stripslashes(data);
		$("#reply_box").html(data);
$('div.fpost_bottom').corner('bottom');
$('div.fp_header').corner('top');		
		$("#reply_box").fadeIn("slow");
		});	
		
		$.post("/upsidecols.php",{},function(data) { $("#sb_general").html(data); } );
		$.post("/upsidecols2.php",{},function(data) { $("#sb_offtopic").html(data); } );	
		$.post("/upsidecols3.php",{},function(data) { $("#sb_wifi").html(data); } );											  
		$.post("/c3news_internal.php",{},function(data) { $("#sb_allnews").html(data); } );
		$.post("/c3topnews.php",{},function(data) { $("#sb_topnews").html(data); } );
		$.post("/sb_comments.php",{},function(data) { $("#sb_comments").html(data); } );
	
	}
}

function processPost_edit(ed_text, post_id) {
	post_text = document.getElementById(ed_text).value;
	
	edt_subs = "edtit_" + post_id;
	
	if (document.getElementById(edt_subs)) {
	etext = document.getElementById(edt_subs).value;
	}else{
	etext = "0";
	}
			
	var oritext = post_text;
	
	var rpdiv = "#pt_" + post_id;
	var eddiv = "#ed_" + post_id;
	$(eddiv).slideUp('normal');

	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");	
	
	
	$.post("/processpost_edit.php",{post_id:post_id, post_text:post_text, edit_title:etext},function(data)
    {
	 $(rpdiv).hide();
	 data = stripslashes(data);
	 $(rpdiv).html(data);
	 $(rpdiv).fadeIn("slow");
	 
	});	

}


function editPost(id) {
	
panel = document.getElementById("ed_" + id); 
if (panel.style.display == 'none') {
$(panel).slideDown('normal');
} else {
$(panel).slideUp('normal');
}

}

function sendPM(to_userid, form, rpdiv) {
	 pform = document[form].pmmsg.value; subject = document[form].subject.value;

	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/process_pm.php",{to_user:to_userid, subject:subject, msg_text:pform},function(data)
    {
	$(rpdiv).hide(); $(rpdiv).html(data); $(rpdiv).fadeIn("slow");
	});	
}


function update_reader_score(game_id) {
	box = document.game_score.score;
	score = box.options[box.selectedIndex].value;
	
	rpdiv = "#reader_score";
	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 10px auto' /></center>");											

	$.post("/readerscore.php",{score:score, gid:game_id},function(data)
    {
	$(rpdiv).html(data);
	});	
}


function show_game_list(letter,format,mode) {
	search = document.searchform.search.value;
	
	if (search == ""){	
	}

	box = document.genreform.genre;
	genre = box.options[box.selectedIndex].value;
		
	 $("#game_list").fadeOut("slow", function (){
		$("#game_list").show();
		$("#game_list").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
    });

	$.post("/show_games.php",{letter:letter, format:format, search:search, mode:mode, genre:genre},function(data)
    {
	$("#game_list").hide();
	$("#game_list").html(data);
	$("#game_list").slideDown("slow");
	});	
}

function show_preview_list(letter,format,mode) {
	search = document.searchform.search.value;
	
	if (search == ""){	
	}
	
	box = document.genreform.genre;
	genre = box.options[box.selectedIndex].value;
	
	 $("#game_list").fadeOut("slow", function (){
		$("#game_list").show();
		$("#game_list").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
    });

	$.post("/show_previews.php",{letter:letter, format:format, search:search, mode:mode, genre:genre},function(data)
    {
	$("#game_list").hide();
	$("#game_list").html(data);
	$("#game_list").slideDown("slow");
	});	
}

function show_exstimg() {
	search = document.form.search.value;
	
	$("#exstimg").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/show_exstimg.php",{search:search},function(data)
    {
	$("#exstimg").hide();
	$("#exstimg").html(data);
	$("#exstimg").slideDown("slow");
	});	
}


function show_directory_list(letter,format,mode) {
	search = document.searchform.search.value;
	if (search == ""){	
	}
	
	box = document.genreform.genre;
	genre = box.options[box.selectedIndex].value;
	
	$("#game_list").html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/show_gameslist.php",{letter:letter, format:format, search:search, mode:mode, genre:genre},function(data)
    {
	$("#game_list").hide();
	$("#game_list").html(data);
	$("#game_list").slideDown("slow");
	});	
}

function showPreview(rpdiv, field, script) {
	field = document.form[field].value;
	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post(script,{field:field},function(data)
    {
	data = stripslashes(data);
	 $(rpdiv).hide(); $(rpdiv).html(data); $(rpdiv).fadeIn("slow");
	});	

}

function showPreview2(form, rpdiv, field, script) {
	field = document[form][field].value;
	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post(script,{field:field},function(data)
    {
	data = stripslashes(data);		
	 $(rpdiv).hide(); $(rpdiv).html(data); $(rpdiv).fadeIn("slow");
	});	

}

function saveDraft(rpdiv, field, topic_id, type, topic_title) {
	field = document.form[field].value;
	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	var savescript = "/savedraft.php";

	$.post(savescript,{field:field, topic_id:topic_id, type:type, topic_title:topic_title},function(data)
    {
	data = stripslashes(data);
	 $(rpdiv).hide(); $(rpdiv).html(data); $(rpdiv).fadeIn("slow");
	});	

}

function nameCheck() {
	field = document.form.uname.value; rpdiv = "div.nameCheck";

	$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											

	$.post("/namecheck.php",{field:field},function(data) { $(rpdiv).hide(); $(rpdiv).html(data);$(rpdiv).fadeIn("normal"); });	
}



function processPost_delete(post_id, topic_id) {
	if (confirm("Are you sure you want to delete?")) {
	var rpdiv = "#pt_" + post_id;
	var cpdiv = "div.cp_" + post_id;

	 $(rpdiv).fadeOut("slow", function (){
		$(rpdiv).show();
		$(rpdiv).html("<center><img src='/imagesv9/loading.gif' style='margin: 20px auto' /></center>");											
    });

	$.post("/processpost_delete.php",{post_id:post_id, topic_id:topic_id},function(data)
    {
	 $(rpdiv).hide();
	 $(cpdiv).slideUp("normal");
	});	
	}
}

function processPost_rating(post_id, type) {
	var ratediv = "#rate_" + post_id;
	$(ratediv).html("<center><img src='/imagesv9/loading.gif' style='margin: 0px auto' /></center>");											

	$.post("/readrating.php",{post_id:post_id, type:type},function(data)
    {
	 $(ratediv).html(data); 
	});	
}


function show_ft(one) {
	switch(one)	{
	case 1: two = 3; three = 2; break;    
	case 2: two = 1; three = 3; break;
	case 3: two = 2; three = 1; break;
	}
	
	ctr = one;
	
	box1 = "#ft_box" + 	one; box2 = "#ft_box" + two; box3 = "#ft_box" + three;
	des1 = "#ft_des" + 	one; des2 = "#ft_des" + two; des3 = "#ft_des" + three;
	$(des3).hide(); $(box3).hide();	
	$(des1).hide();
	
	$(des2).slideUp("slow", function (){

	$(box2).fadeOut("slow", function (){

	$(box1).fadeIn("slow", function (){	
	$(des1).slideDown("slow");
	$(des1).show();	
	$("#ft_link" + one).addClass("selected"); $("#ft_link" + two).removeClass("selected"); $("#ft_link" + three).removeClass("selected");

	});
	});
	
	});
}

function rotateFeatured() {
ctr++;
if(ctr > 3) {
ctr = 0;
}
show_ft(ctr);
}

function showpanel(txt) {
panel = document.getElementById(txt); 

if (panel.style.display == '') {
panel.style.display = 'none';
} else {
panel.style.display = '';
}

}

function quickedit(txt, txt2) {
editpanel = document.getElementById(txt2); 
normalpanel = document.getElementById(txt); 

if (editpanel.style.display == 'none') {
editpanel.style.display = '';
normalpanel.style.display = 'none';
} else {
editpanel.style.display = 'none';
normalpanel.style.display = '';
}

}

function validatecomment() {

if (document.form.post_text.value == '') {
alert("Please enter a comment!!");
return false;
} else {
return true;
}

}

function imageinput2(field) {

var image = prompt("Please type or paste the URL (address) for your image. Make sure it is prefixed with http://", "");
var imagewidth = prompt("Align image? Type left, right or leave blank.", "");

 if ( (imagewidth=='') || (imagewidth==null) ) 
 { 
   var width = ""; 
 } 
 else 
 {
   var width = "align=" + imagewidth + "";
 }

if (imagewidth=='') {
image = "[img]" + image + "[/img]";
} else {
image = "[img " + width + "]" + image + "[/img]";
}


if ((image==null) || (imagewidth==null)) {

} else {
document.form[field].value += image;

}

}

function urlinput2(field) {


var url = prompt("Please type or paste the URL (website address) Make sure it is prefixed with http://", "");
var title = prompt("Please enter the text that will be linked - e.g. the website name. Leave blank to paste in the full address instead...", "");

 if ( (title=='') || (title==null) ) 
 { 
   title = url; 
 } else {
 }

urlin = "[url=" + url + "]" + title + "[/url]";


if ((url==null) || (url==null)) {

} else {
	document.form[field].value += urlin;
}

}


function imageinput() {

var image = prompt("Please type or paste the URL (address) for your image. Make sure it is prefixed with http://", "");
var imagewidth = prompt("If your image is larger than 500px in width, please enter a value below so it does not stretch the page. If it is below 500, leave this bit blank and press Ok ", "");

 if ( (imagewidth=='') || (imagewidth==null) ) 
 { 
   var width = ""; 
 } 
 else 
 {
   var width = "width=" + imagewidth + "";
 }

if (imagewidth=='') {
image = "[img]" + image + "[/img]";
} else {
image = "[img " + width + "]" + image + "[/img]";
}

if ((image==null) || (imagewidth==null)) {

} else {
document.form.post_text.value += image;

}

}

function urlinput() {


var url = prompt("Please type or paste the URL (website address) Make sure it is prefixed with http://", "");
var title = prompt("Please enter the text that will be linked - e.g. the website name. Leave blank to paste in the full address instead...", "");

 if ( (title=='') || (title==null) ) 
 { 
   title = url; 
 } else {
 }

urlin = "[url=" + url + "]" + title + "[/url]";


if ((url==null) || (url==null)) {

} else {
	document.form.post_text.value += urlin;

}

}

function smilie(text,field) {
	document.form[field].value += text;	
}


function quote(ed_text,uname) {
	post_text = document.getElementById(ed_text).value;
	post_text = "[quote][b]" + uname + " said:[/b]<br/>" + post_text + "[/quote]";
	document.form.post_text.value += post_text;
}

function showUpanel() {
	$("div.pan_user").show();  
	$("div.pan_anon").hide();
}

function close_pop() {

if (self.parent.tb_remove) {
self.parent.tb_remove();
} else {
history.go(-1);
}
}

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to delete?");
if (agree)
	return true ;
else
	return false ;
}

function confirmSubmit2()
{
var agree=confirm("WARNING: Are you sure you want to delete your entire inbox?");
if (agree)
	return true ;
else
	return false ;
}

function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}

function maketabtop(tab) { var tabhl = document.getElementById(tab); tabhl.style.background = '#4A76A6'; tabhl.style.color = '#FFF';}
function maketabtop_out(tab) { var tabhl = document.getElementById(tab); tabhl.style.background = ''; tabhl.style.color = '#395B82'; }
function maketabtop_out2(tab) { var tabhl = document.getElementById(tab); tabhl.style.background = '#416792'; tabhl.style.color = '#395B82'; }
