function companyinfo_changeStock(){
	var id = document.frm.stockname.options[document.frm.stockname.selectedIndex].value;
	var id2 = document.frm.stockname2.options[document.frm.stockname2.selectedIndex].value;
	var id3 = document.frm.stockname3.options[document.frm.stockname3.selectedIndex].value;

	var location_href = WEBROOT + '/companyinfo/' + id;
	if(id2!=''){
		location_href += ',' + id2;
	}
	if(id3!=''){
		location_href +=  ',' + id3;
	}
	window.location.href=location_href;
}

function stockdaily_frmAction(){
	if(document.frm.date.value!=''){
		var stcid = document.frm.stcid.value;
		var location_href = WEBROOT + '/stockdaily/' + stcid +'/' + document.frm.date.value;
		window.location.href = location_href;
		return false;
	}
	return false;
}

/* index */
function changeNav(stcid, tabid){
	if(stcid==1){
		document.getElementById('ho_percent_asc').className = '';
		document.getElementById('ho_percent_desc').className = '';
		document.getElementById('ho_price_asc').className = '';
		document.getElementById('ho_price_desc').className = '';
		
		document.getElementById(tabid).className = 'active';
		document.frm.ho_nav.value = tabid;
	}
	else{
		document.getElementById('ha_percent_asc').className = '';
		document.getElementById('ha_percent_desc').className = '';
		document.getElementById('ha_price_asc').className = '';
		document.getElementById('ha_price_desc').className = '';
		
		document.getElementById(tabid).className = 'active';
		document.frm.ha_nav.value = tabid;
	}
	
	gotoPage(stcid, 1, 0);
	getData(stcid);
}

function changeSubNav(stcid, tabid){
	if(stcid==1){
		document.getElementById('ho_in_week').className = '';
		document.getElementById('ho_1_week').className = '';
		document.getElementById('ho_2_week').className = '';
		document.getElementById('ho_1_month').className = '';
		document.getElementById('ho_3_month').className = '';
		document.getElementById('ho_6_month').className = '';
		document.getElementById('ho_9_month').className = '';
		
		document.getElementById(tabid).className = 'active';
		document.frm.ho_subnav.value = tabid;
	}
	else{
		document.getElementById('ha_in_week').className = '';
		document.getElementById('ha_1_week').className = '';
		document.getElementById('ha_2_week').className = '';
		document.getElementById('ha_1_month').className = '';
		document.getElementById('ha_3_month').className = '';
		document.getElementById('ha_6_month').className = '';
		document.getElementById('ha_9_month').className = '';
		
		document.getElementById(tabid).className = 'active';
		document.frm.ha_subnav.value = tabid;
	}
		
	gotoPage(stcid, 1, 0);
	getData(stcid);
}

function getData(stcid){
	if(stcid==1){
		document.getElementById('content_hostc').innerHTML = '<div align="center" style="padding-top:100px"><img src="' + PATH_IMAGE + '/loading.gif" alt="" /> &nbsp;<strong align=center>Loading...'+'<'+'/'+'strong>'+'<'+'/'+'div>';
		var nav = document.frm.ho_nav.value;
		var subnav = document.frm.ho_subnav.value;		
	}
	else{
		document.getElementById('content_hastc').innerHTML = '<div align="center" style="padding-top:100px"><img src="' + PATH_IMAGE + '/loading.gif" alt="" /> &nbsp;<strong align=center>Loading...'+'<'+'/'+'strong>'+'<'+'/'+'div>';
		var nav = document.frm.ha_nav.value;
		var subnav = document.frm.ha_subnav.value;	
	}	
	var current_page = document.frm.currentPage.value;
	
	$.ajax({
		type: 'POST',
		data: {
			stcid: stcid,
			dataType: nav,
			dataTime: subnav,
			currentPage: current_page
		},
		url: 'index_ajax.php',
		dataType: "html",
		success: function(stringHTML){
			if(stcid==1)
				document.getElementById('content_hostc').innerHTML = stringHTML;
			else
				document.getElementById('content_hastc').innerHTML = stringHTML;
		}
	})
}
function gotoPage(stcid, ipage, loaddata){
	document.frm.currentPage.value = ipage;
	
	for(i=1; i<=5; i++){
		if(stcid==1)
			document.getElementById('ho_goto_' + i).className = '';
		else	
			document.getElementById('ha_goto_' + i).className = '';
	}
	
	if(stcid==1)
		document.getElementById('ho_goto_' + ipage).className = 'active';
	else
		document.getElementById('ha_goto_' + ipage).className = 'active';
	
	if(loaddata==1){
		getData(stcid);
	}	
}
