var switchBoolen = new Array();
var dtBtnArray = new Array();
var slideSpeed = 400;
var oldObj = null;
var rowNum = 10;
var divNum = 0;
var page = 0;
var nextgo = null;
var passNum = null;
window.onload = base;
function base(){
	slidDown_con();
	if(browser('MSIE 8.0')){engine();}	
}

function nextpage(){
	page += 1;
	$('#previous').show();
	var showNum = rowNum*page;
	var restNum = 0;
	
	for(i=0; i<dtBtnArray.length; i++){
		dtBtnArray[i].hide();
	}
	
	for(j=0; j<rowNum; j++){
		dtBtnArray[showNum+restNum].show();
		restNum += 1;
		if(showNum+restNum >= dtBtnArray.length) {
			$('#next').hide();
			//passNum = (dtBtnArray.length-1) - (rowNum+(rowNum - restNum));
			passNum = showNum+restNum-(rowNum*2);
			return false;
		}
	}
	passNum = showNum+restNum-(rowNum*2);
}
	
function previous(){
	if(passNum <= 0){
		passNum = 0; $('#previous').hide();
	}
	$('#next').show();
	page -= 1;
	if(page < 0) page = 0;
	for(i=0; i<dtBtnArray.length; i++){
		dtBtnArray[i].hide();
	}
	for(j=0; j<rowNum; j++){
		dtBtnArray[passNum].show();
		passNum += 1;
	}
	passNum = passNum-(rowNum*2);
}

function slidDown_con(){
	$('.news_cont, .eo_cont').each(function (){
		dtBtnArray.push($(this).prev());
		divNum += 1;
		if(divNum > rowNum) {
			$('#next').show(); 
			$(this).prev().hide();
		}		
		$(this).attr('name',divNum);
		if (window.location.hash != '' && window.location.hash == '#'+$(this).attr('id')){
			$(this).show();
			switchBoolen.push(false);
			$(this).prev().addClass('open');
			oldObj = $(this);
		}else{
			$(this).hide();
			switchBoolen.push(true);
		}
		if($(this).attr('name')%2 == 1){
			$(this).prev().addClass('odd');
		}
	});
	
	$('.news_cont, .eo_cont').prev().click(function(){
		var num = $(this).next().attr('name');
		
		if(oldObj){
			if(num != oldObj.attr('name')){
				oldObj.slideUp(slideSpeed);
				$(this).next().slideDown(slideSpeed);				
				$(this).addClass('open');
				
				oldObj.prev().removeClass('open');
				switchBoolen[num] = true;
			}else{
				if(switchBoolen[num] == true){
					$(this).removeClass('open');
					$(this).next().slideUp(slideSpeed);
					switchBoolen[num] = false;
				}else{
					$(this).next().slideDown(slideSpeed);
					$(this).addClass('open');
					switchBoolen[num] = true;
				}
			}
		}else{
			$(this).next().slideDown(slideSpeed);
			$(this).addClass('open');
		}
		oldObj = $(this).next();
	});	
}
	
	
function engine(){
	setInterval(resizeDiv,33);
}
	
function resizeDiv(){
	var eo_box = $("#eo_box");
	var content_company = $("#content_company");
	var eo_box_top = $("#eo_box").offset().top
	var container = $("#container");
	container.css('height',(content_company.height()+390)+'px');
	}
	
function browser(pageName){
	var objURL = new Object();
	if(navigator.userAgent.indexOf(pageName)>-1){
		return objURL = true;
	}else{
		return objURL = false;
	}
}


