var sSection = '';
var sSubSection = '';
var nCounter = 0;
var initialDoOnce = 0;

var sc_project=4676894; 
var sc_invisible=1; 
var sc_partition=56; 
var sc_click_stat=1; 
var sc_security="6f3ac55b"; 

function reloadSection()
{
	var section = self.document.location.hash.substring(1);
	if (section=='')
		loadSection('home');	
	else
		loadSection(section);	
}

function pageInit()
{
	reloadSection();
	window.setInterval(reloadSection,10);
}

function loadSection(section) 
{
	var subSectionDel = section.indexOf('_');
	var subSection = '';
	
	if (subSectionDel > 0)
	{
		subSection = section.substring(subSectionDel+1,section.length);
		section = section.substring(0,subSectionDel);	
	}
	
	if (sSubSection!=subSection)
	{
		//alert(sSubSection+' ' +subSection);
		sSubSection = subSection;
		if (subSection.length > 0)
		{
			if(section == 'store')
			{
				document.getElementById("storeframe").src = '/store/'+subSection;
			}
		}
	}
		
    if (sSection!=section)
    {
		nCounter++;
		if (document.getElementById('sectionid_'+section)==null)
		{
			section = 'home';
			subSection = null;
		}
		
		if (section == 'store')
		{
			document.getElementById("storeframe").src = '/store';	
		}
		
		self.location.href = "#"+section+(sSubSection!=''?"_"+sSubSection:"");
		sSection = section;
	    document.getElementById('section_title').innerHTML = section.toUpperCase();
		handleResize(section,'section_content',document.getElementById('sectionid_'+section).offsetHeight, nCounter)
	}
}

function handleResize(section,target,height,counter)
{
	if (counter==nCounter)
	{
		oTarget = document.getElementById(target); 	
		nHeight = oTarget.offsetHeight;
	  	if (Math.abs(nHeight-height)<=2)
			oTarget.innerHTML = document.getElementById('sectionid_'+section).innerHTML;
	 	else
	  	{
			oTarget.innerHTML = '';
			oTarget.style.height = nHeight-(nHeight-height)/2;
			setTimeout ( 'handleResize("'+section+'","'+target+'",'+height+','+counter+')' , 50 );    
	  	}
	}
}