/*
Name: utils.js
Required: 
	+ cookielib.js
Author: Natthawut Kulnirundorn
Project: Intania Web Project
Date: 17.10.2005
Contact: m3rlinez@gmail.com
Description: General functions used by Intania Web
*/

var currentSizeContent = 1; /* Store current size of font */
var currentIconIndex = 1; /* Store current index of icon for News*/
var submenuList = new Array('ise','departments','internal','general');

function changeCurrentSizeContent(){
	currentSizeContent++;
	if(currentSizeContent == 4)currentSizeContent = 1;
	Set_Cookie('main_sizeContent',currentSizeContent,'','/','','');
}

function changeCurrentIconIndex(){
	currentIconIndex++;
	if(currentIconIndex == 5)currentIconIndex = 1;
}

function getSizeClassContent(){
	if(currentSizeContent == 1)return "smallfont";
	if(currentSizeContent == 2)return "mediumfont";
	if(currentSizeContent == 3)return "largefont";
}

function getIconName(){
	return "images/IntaniaIcon" + currentIconIndex + ".jpg";
}

function setImage(oImage){
	oImage.src = getIconName();
	changeCurrentIconIndex();
}

function changeFontSizeContent(){
	var oCell = document.getElementsByName("pagecont");
	changeCurrentSizeContent();
	for(var i = 0 ; i < oCell.length ; i++)
	  oCell.item(i).className = getSizeClassContent();
}

function initSizeContent(){
	var csize = Get_Cookie('main_sizeContent');
	if(csize!=null){
		currentSizeContent = csize;
		var oCell = document.getElementsByName("pagecont");
		for(var i = 0 ; i < oCell.length ; i++)
			oCell.item(i).className = getSizeClassContent();
	}
}

function preloadIconNE(){
	var o1 = new Image();
	var o2 = new Image();
	var o3 = new Image();
	var o4 = new Image();
	o1.src = "images/IntaniaIcon1.jpg";
	o2.src = "images/IntaniaIcon2.jpg";
	o3.src = "images/IntaniaIcon3.jpg";
	o4.src = "images/IntaniaIcon4.jpg";
}

function initIconNE(){
	var oNews = document.getElementsByName("neicon");
	for(var i = 0 ; i < oNews.length ; i++)
		setImage(oNews.item(i));
}

function neSetActive(oRow){
	oRow.style.backgroundColor = "#F8F8F8";
}

function neSetInactive(oRow){
	oRow.style.backgroundColor = "#FFFFFF";
}

function onreadytest(){
	alert("test");
}

function toggleSubMenu(idSubMenu){
	var oSubMenu = document.getElementById(idSubMenu);
	if(oSubMenu.style.display != "none")oSubMenu.style.display = "none";
	else oSubMenu.style.display = "block";
	Set_Cookie('main_'+idSubMenu,oSubMenu.style.display,'','/','','');
}

function restoreSubMenuState(){
	var i;
	for(i=0;i<submenuList.length;i++){
		var oSub = document.getElementById(submenuList[i]);
		if(oSub!=null){
			var saveStyle = Get_Cookie('main_'+submenuList[i]);
			if(saveStyle!=null){
				oSub.style.display = saveStyle;
			}else{
				oSub.style.display = "block";
			}
		}
	}
}

function fillColorRow(strName){
	var oBoardRow = document.getElementsByName(strName);
	for(var i = 0 ; i < oBoardRow.length ; i++)
	    if(i%2==0)
	      oBoardRow.item(i).style.backgroundColor = "#F8F8F8";
}

function makeSelection(oInput){
	if(oInput.value == oInput.title)oInput.select();
}

function submitGoogle(){
	var oForm = document.getElementById("frmGoogle");
	oForm.submit();
}

function sendmailSubmit(){
	var oForm = document.getElementById("frmSendmail");
	oForm.submit();
}
