var dsTable1 = "#dataList1";//datagrid
var dsTable2 = "#dataList2";
var dsTable3 = "#dataList3";
var dsTable4 = "#layerDataList1";//datagrid
var loadingMsg = "<p align=center style=padding:25px;><img src=../image/loading.gif align=absmiddle /> Loading...</p>";
var recordCount = 0; //레코드갯수
var x=0; 
var y=0; 
var y2=0;
var saveGubun = 0 //insert:0 update:1


$(document).ready(function() {
 	ds1();
	ds2();
 	
 	$('#image1').click(function() { koshow(1); });	
 	$('#image11').click(function() { koshow(1); });	
 	$('#image2').click(function() { koshow(2); });	
 	$('#image21').click(function() { koshow(2); });	
 	
 	$( '#divMenu' ).scrollFollow();

});


function ds1(){

	$('#ds1').html(loadingMsg);
	$('#tableID').val('web_board05');
	//alert($('#form1').serialize());
	$.ajax({
    	type: "POST", timeout: 60000, url: "main_data01.jsp", data: $('#form1').serialize(),
    	complete: function() {
    		//alert("Complete Function!");
    	},
    	success: function(data) {
    		$('#ds1').html(data);

    	},
    	error: function (XMLHttpRequest, textStatus) { 
    		alert("Error: " + textStatus);
    	}
    });		
}

function ds2(){

	$('#ds2').html(loadingMsg);
	$('#tableID').val('web_board01');
	//alert($('#form1').serialize());
	$.ajax({
    	type: "POST", timeout: 60000, url: "main_data02.jsp", data: $('#form1').serialize(),
    	complete: function() {
    		//alert("Complete Function!");
    	},
    	success: function(data) {
    		$('#ds2').html(data);
    	},
    	error: function (XMLHttpRequest, textStatus) { 
    		alert("Error: " + textStatus);
    	}
    });		
}

function onClickRow(){
	var lo_this;
	//IE 계열
	if(event) {	lo_this= window.event.srcElement;}
	//none IE 계열
	else { lo_this= window.e.getTarget();}
	var row_index  = lo_this.parentNode.rowIndex;
	y = row_index; 
	
	var seq = $(dsTable1+' tr:eq('+y+') td:eq(2)').text();
	
	location.href="subPage.jsp?control=job&pageNum=01&exec=view&seq="+seq;
}

function onClickRow2(){
	var lo_this;
	//IE 계열
	if(event) {	lo_this= window.event.srcElement;}
	//none IE 계열
	else { lo_this= window.e.getTarget();}
	var row_index  = lo_this.parentNode.rowIndex;
	y = row_index; 
	
	var seq = $(dsTable2+' tr:eq('+y+') td:eq(2)').text();
	
	location.href="subPage.jsp?control=cs&pageNum=01&exec=view&seq="+seq;
}

function koshow(str)
{
	if(str==1){
		$('#koLayer1').show();
		$('#koLayer2').hide();
	}
	else if(str==2)
	{
		$('#koLayer1').hide();
		$('#koLayer2').show();
	}
	else
	{
		$('#koLayer1').show();
		$('#koLayer2').hide();
	}
}

function getCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie )
		{
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}