/*************************************************************************
SAMPLES LIFTED FROM http://msdn2.microsoft.com/en-us/library/bb398998.aspx

GN 2/8/2008 : I don't get why they're passing names of OnSucceeded and 
              failed to a function that accepts fewer parameters
**************************************************************************/

var initialPopupContent;

function displayWork(clientId){
    //setup
	$get("clientWorkPopupPosition").style.display = "block";
	initialPopupContent = $get("clientWorkInnerHtml").innerHTML
	//actually do it
	queryForPortPieces(clientId);
	current_client_name = getClient(clientId).name;
	invoke_tracking(current_client_name);
}
function hideWork(){
	$get("clientWorkPopupPosition").style.display = "none";
	$get("clientWorkInnerHtml").innerHTML = initialPopupContent;
}

//Retrieves client work from database for specified client
function queryForPortPieces(clientId) {
    PageMethods.PullPortfolioPiecesForClient(clientId, OnPortSucceeded, OnPortFailed);
}

// Callback function invoked on successful completion of the page method.
function OnPortSucceeded(result) {
	// PARSE DEFAULT CATEGORY
	var defaultCategory = result.substr(0,30).trim();
	if(!(defaultCategory&&$('mnuCategories').value()=='All')){
		defaultCategory = $('mnuCategories').value();
	}
	
	// PARSE HTML DATA
	var htmlData = result.substr(30);
	$get("clientWorkInnerHtml").innerHTML = htmlData;
		
		// OPERA WORKAROUND FOR SCROLLING DIV
		if(isOpera){
			$('workThumbsScrollArea').style.overflow = 'auto';
		}
		
	slimTab_init();
	slimTab_showTab('workAreaTabs', defaultCategory);
	monitorThumbnails();
	$$('td.footer')[0].scrollIntoView();
}

// Callback function invoked on failure of the page method.
function OnPortFailed(error, userContext, methodName) {
    if(error !== null) {
        $get("clientWorkInnerHtml").innerHTML = "An error occurred: " + error.get_message();
    }
}

/*
//CASE STUDIES ATTEMPT
function displayNextCase(caseID){
    PageMethods.getCaseStudyInfo(caseId, OnCaseSucceeded, OnCaseFailed);
}
function OnCaseSucceeded(result) {

    $get("caseStudyArea").innerHTML = result;
    slideShow.resetSlides();
    Event.observe($('slideshowOverlayFader'),'mouseover',function(){pauseSlideshow=true;});
    Event.observe($('slideshowOverlayFader'),'mouseout',function(){pauseSlideshow=false;});
    slideShow_start();
    slideShow_init();
    
alert(result);
    
}
function OnCaseFailed(error, userContext, methodName) {

    if(error !== null) {
        $get("caseStudyArea").innerHTML = "An error occurred: " + error.get_message();
    }

alert(error.get_message());
}
*/

// REFERENCE regarding the following line (I was curious) -GN 2/9/08 
// http://asp.net/ajax/documentation/live/clientreference/Sys/ApplicationClass/SysApplicationNotifyScriptLoadedMethod.aspx
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();