<?php
define('IN_JEBAN', true);

header("Content-type: application/x-javascript");
 

$jeban_root_path = '../';

include($jeban_root_path.'extension.inc');
include($jeban_root_path.'common.'.$phpEx);


?>
// JavaScript Document
function redirectPage() {
	var sURL = '';
	
	// get all the inputs into an array.
	var inputs = $('#formFilter input');

	// not sure if you wanted this, but I thought I'd add it.
	// get an associative array of just the values.
	var values = '';
	inputs.each(function(i, el) {
		if ($(el).is(':checked')) {
			values = values + ',' + $(el).val();
		}
	});
	
	if ( (values.substring(1) == '') || (values.substring(1) == '9') ) {
		sURL = 'board_ask.php';
	} 
	if ( (values.substring(1) == '') || (values.substring(1) == '27,28,29') ) {
		sURL = 'board_salon.php';
	} 
	if ( (values.substring(1) == '') || (values.substring(1) == '1') ) {
		sURL = 'board_howto.php';
	}
	if ( (values.substring(1) == '') || (values.substring(1) == '2') ) {
		sURL = 'board_review.php';
	}
	if ( (values.substring(1) == '') || (values.substring(1) == '6') ) {
		sURL = 'board_her.php';
	}
	if ( (values.substring(1) == '') || (values.substring(1) == '10') ) {
		sURL = 'board_other.php';
	}
	else {
		sURL = 'webboard.php?forums=' + values.substring(1);
	}

	if ($('#topicSorting').val() == 'post') {
		if (sURL == 'board_ask.php') {
			sURL = sURL + '?sort=post';
		} else {
			sURL = sURL + '&sort=post';
		}
	}
	
	location.replace(sURL);
	return false;
}

$(function () {
	$('.pageNo').editInPlace(
		{	url:'ajaxProxy.php?mode=webboardPage',
			saving_image:'images/ajaxLoader_circleBall.gif',
			value_required:true
		}
	);

	$('.pageArchive').editInPlace(
		{	url:'ajaxProxy.php?mode=archivePage',
			saving_image:'images/ajaxLoader_circleBall.gif',
			value_required:true
		}
	);

	$('#formFilter').submit(function() {
		return redirectPage();
	});
	
	$('#topicSorting').change(function() {
		return redirectPage();
	});
	 

$('img.lazy').lazyload({
        effect : "fadeIn",
        skip_invisible : false
    });
});	
 
