/**
 * file to handle the JS driven features of SAMA Sports, Business, Technology page
 *
 * @author Karthikeyan
 * @since Jun 20, 2007
 */

//function to show a block of element
//param : id - this id's element will be shown to user
function ShowSectionTab(tobeshownid, ImgName, ImgName2)
{
	if (document.getElementById){
		var tabValue = document.getElementById(tobeshownid+'Anchor').innerHTML;
		if (tobeshownid == "SectionTab4" && tabValue == "Scorecard") {
			document.location.href = "http://sports.samachar.com/scorecard/index.php";
			//return false;
		} else {
			var docDomain = document.location;
			//alert("Domain "+docDomain);
			var regExScorecardPattern = /http:\/\/(.*)\/(.*)\/(.*)/i;
			var arrMatches = new Array();
			if (regExScorecardPattern.test(docDomain)) {
				arrMatches = regExScorecardPattern.exec(docDomain);
				if (arrMatches[2] == "scorecard") {
					var tabName = tobeshownid+"Anchor";
					//alert("HELLO i m going to call sports");
					document.location.href = "http://sports.samachar.com/index.php?tab="+tabName;
					//return false;
				} 
			} else {
				TopBlockobj		= document.getElementById(tobeshownid+'Top');
				BottomBlockobj		= document.getElementById(tobeshownid+'Bottom');
				TDObj	= document.getElementById(tobeshownid+'TD');
				AObj	= document.getElementById(tobeshownid+'Anchor');
				if (TopBlockobj){
					TopBlockobj.style.display		= "";
					if(BottomBlockobj)
					BottomBlockobj.style.display		= "";
					TDObj.attributes.getNamedItem('background').nodeValue	= ImgName;
					AObj.className			= 'tahomabold11white';
				}
				//alert("HELLO i m going to call HideSectionTab");
				HideSectionTabs(tobeshownid, ImgName2);	
			}
		}
	}
}

//function to hide a block of form element
//param : id - other related element other than this id's element
//will be hidden from user
function HideSectionTabs(nottobehideid, ImgName)
{
	//alert("HELLO i m HideSectionTab");
	var divs = document.getElementsByTagName('div');

	for(i=0;i<divs.length;i++){
		var elementid = divs[i].id.replace(/\d/,'');
		var elementid = elementid.replace(/Top/,'');
		var passedid = nottobehideid.replace(/\d/,'');
		
		if ( divs[i].id != nottobehideid+'Top' && passedid == elementid ){
			if (document.getElementById){
				nottoshowelement	= divs[i].id.replace(/Top/,'');

				TopBlockobj = document.getElementById(nottoshowelement+'Top');
				BottomBlockobj = document.getElementById(nottoshowelement+'Bottom');
				//alert(nottoshowelement+' | '+TopBlockobj);
				TDObj	= document.getElementById(nottoshowelement+'TD');
				AObj	= document.getElementById(nottoshowelement+'Anchor');
				if ( TopBlockobj ){
					TopBlockobj.style.display = "none";
					if(BottomBlockobj)
						BottomBlockobj.style.display = "none";
					TDObj.attributes.getNamedItem('background').nodeValue	= ImgName;
					AObj.className			= 'tahomanormal11b';
				}
			}
		}
	}
}
