function getChildElementsByClassName(parentElement, className)
{
	var i, childElements, pattern, result;
	result = new Array();
	pattern = new RegExp("\\b"+className+"\\b");


	childElements = parentElement.getElementsByTagName('*');
	for(i = 0; i < childElements.length; i++)
	{
		if(childElements[i].className.search(pattern) != -1)
		{
			result[result.length] = childElements[i];
		}
	}
	return result;
}

var ulElement;
function BuildTabs(containerId)
{
	var i, tabContainer, tabContents, tabHeading, title, tabElement;
	var divElement,  liElement, tabLink, linkText;
	// assume that if document.getElementById exists, then this will work...
	if(! eval('document.getElementById') ) return;
	
	tabContainer = document.getElementById(containerId);
	if(tabContainer == null)
		return;
	if(containerId=="tab-containerNews")
	{
		tabContents = getChildElementsByClassName(tabContainer, 'tab-content1');
		
	}
	else
		tabContents = getChildElementsByClassName(tabContainer, 'tab-content');
	//alert("tabContents"+tabContents.length);
	if(tabContents.length == 0)
		return;

	divElement = document.createElement("div");
	if(containerId=="tab-containerNews")
  		divElement.className = 'tab-header1';
	else
		divElement.className = 'tab-header';
		
  	divElement.id = containerId + '-header';
	ulElement = document.createElement("ul");
  	ulElement.className = 'tab-list'

	tabContainer.insertBefore(divElement, tabContents[0]);
	divElement.appendChild(ulElement);

	for(i = 0; i < tabContents.length; i++)
	{
		tabHeading = getChildElementsByClassName(tabContents[i], 'tab');
		title = tabHeading[0].childNodes[0].nodeValue;
		
		// create the tabs as an unsigned list
		liElement = document.createElement("li");
		liElement.id = containerId + '-tab-' + i;

		tabLink = document.createElement("a");
		linkText = document.createTextNode(title);

		tabLink.className = "tab-item";
		
		tabLink.setAttribute("href","javascript://");
		//add by pawan
		//tabLink.setAttribute("id",containerId+"tab"+i);
		tabLink.setAttribute( "title", tabHeading[0].getAttribute("title"));
		
		if(containerId=="tab-container")
			tabLink.onclick = new Function ("ActivateTab('" + containerId + "', " + i + ")");
		else
			tabLink.onclick = new Function ("ActivateTab('" + containerId + "', " + i + ")");

		ulElement.appendChild(liElement);
		
		liElement.appendChild(tabLink);
		
		tabLink.appendChild(linkText);

		// remove the H1
		tabContents[i].removeChild
	}
}

function ActivateTab(containerId, activeTabIndex)
{
	
	var i, tabContainer, tabContents;
try{
	tabContainer = document.getElementById(containerId);
	if(tabContainer == null)
		return;
	if(containerId=="tab-containerNews")
		tabContents = getChildElementsByClassName(tabContainer, 'tab-content1');
	/*
	else
		tabContents = getChildElementsByClassName(tabContainer, 'tab-content');
	*/	
	if(tabContents.length > 0)
	{
		for(i = 0; i < tabContents.length; i++)
		{
			//tabContents[i].className = "tab-content1";
			tabContents[i].style.display = "none";
		}

		tabContents[activeTabIndex].style.display = "block";


    	tabList = document.getElementById(containerId + '-list');
		tabs = getChildElementsByClassName(tabContainer, 'tab-item');
		if(tabs.length > 0)
		{
			for(i = 0; i < tabs.length; i++)
			{
				tabs[i].className = "tab-item";
			}
			
			tabs[activeTabIndex].className = "tab-item tab-active";
			document.getElementById("Particular_news").innerHTML="";
			document.getElementById("Particular_news").style.display="none";
			tabs[activeTabIndex].blur();
			
		}
	}
	
}catch(e){alert("problem in activate");}
}

BuildTabs('tab-containerNews');
ActivateTab('tab-containerNews', 0);
/*
BuildTabs('tab-container');
ActivateTab('tab-container', 0);
*/
/*
try{

var TabTimer=null;
TabTimer=setInterval("switchTabs()",30000);
//var TabTimer=null;
//for geez announcement
var cnt1=0;
function switchTabs()
{
		try
		{
			
			tabList = document.getElementById('tab-container');
			var size=tabList.childNodes.length;
			if(cnt1==size-1)
			{	cnt1=0;}
			ActivateTab('tab-container', cnt1);
			cnt1++;
		}
		catch(e)
		{
			//alert("problem="+e);
		}
}
function SleepTimer(CNT)
{
	//alert("set interval null");
	cnt1=CNT;
	if( TabTimer!=null)
	{
		clearInterval(TabTimer);
		TabTimer=null;
	}
	
	setTimeout("StartSwitchTabs()",1000);
	
}
function StartSwitchTabs()
{
	if( TabTimer!=null)
	{
		clearInterval(TabTimer);
		TabTimer=null;
	}
	
	TabTimer=setInterval("switchTabs()",30000);
}

}catch(e){alert("Problem"+e);}

try{
//for news
var TabTimer1=setInterval("switchTabs1()",45000);
//var TabTimer=null;

var cnt=0;
function switchTabs1()
{
		try
		{
			
			tabList = document.getElementById('tab-containerNews');
			var size=tabList.childNodes.length;
			if(cnt==size-1)
			{	cnt=0;}
			ActivateTab('tab-containerNews', cnt);
			cnt++;
		}
		catch(e)
		{
			//alert("problem="+e);
		}
}
function SleepTimer1(CNT)
{
	//alert("set interval null");
	cnt=CNT;
	if( TabTimer1!=null)
	{
		clearInterval(TabTimer1);
		TabTimer1=null;
	}
	
	setTimeout("StartSwitchTabs1()",1000);
	
}
function StartSwitchTabs1()
{
	if( TabTimer1!=null)
	{
		clearInterval(TabTimer1);
		TabTimer1=null;
	}
	TabTimer1=setInterval(switchTabs1,45000);
}

}catch(e){alert("Problem"+e);}
*/
function callSubmit(LoginForm)
{	
	if (validateLoginFormData(LoginForm)==true)
		LoginForm.submit();
}
function validateLoginFormData(LoginForm)
{
	if(LoginForm.user_id.value=="")
	{	
		alert("Please Enter the User ID!");
		LoginForm.user_id.focus();
		return false;
	}
	else {
		if(LoginForm.password.value=="") {
			alert("Please Enter the Password!");
			LoginForm.password.focus();
			return false;
		} else {
			return true;			
		}
	}
}

function fnKeyPress(event)	// On press the Enter Key
{
	var charCode = (event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);
	if (charCode ==13) 	// Enter/Return Keypress.
		callSubmit(document.LoginForm);
}

