// parse URL for _GET values
var iPage = 125;
var iSet = 0;
var iLinked = 0;

var aTmpValues = self.location.href.split('?');
if (aTmpValues.length > 1)
{
    var strGetValues = aTmpValues[1];
    var aGetValues = strGetValues.split('&');
    for (i=0; i < aGetValues.length; ++i)
    {
    	var aGet = aGetValues[i].split('=');    	
    	if (aGet[0] == 'case') {
			iPage = aGet[1];
			iLinked = 1;
		}
    	if (aGet[0] == 'set') iSet = aGet[1];   	
    }
}

function processCaseStudy(responseText, responseStatus)
{
	if (responseStatus==200)
	{
		if (document.getElementById('get_case_study'))
		{
			document.getElementById('get_case_study').innerHTML=responseText;
			LoadedGalleryEvents();
		}
	} else {
		alert(responseStatus + ' -- Error Processing Request');
	}
}

function IndexEvents()
{
	if (document.getElementById('tab_list'))
	{
		indexLinks = document.getElementById('tab_list').getElementsByTagName('LI');
		for (i = 0; i < indexLinks.length; ++i)
		{
			// remove <a> tags
			linkHTML = indexLinks[i].innerHTML;
			if (linkHTML.indexOf('>') != -1)
				indexLinks[i].innerHTML = linkHTML.substring((linkHTML.indexOf('>') + 1),linkHTML.lastIndexOf('<'));
			
			indexLinks[i].onclick = function()
			{		
				iPage = parseInt(this.id);				
				getCaseStudy = new ajaxObject('get_case_study.php', processCaseStudy);
				getCaseStudy.update('case='+iPage+'&linked='+iLinked+'&js=1');
				
				document.getElementById('case_study_title').innerHTML = 'Case Studies | <strong>' + this.innerHTML + '</strong>';
				
				return false;
			};
		}
	}
}


// Event Handlers
function CaseStudyEvents()
{
	getCaseStudy = new ajaxObject('get_case_study.php', processCaseStudy);
	getCaseStudy.update('case='+iPage+'&linked='+iLinked+'&js=1');
	IndexEvents();	
	PreloadCssImages();

}

PreLoadEvent(CaseStudyEvents);
