
var handleSuccess_ChangePage = function(o){
	if(o.responseText !== undefined){
		var maincontent_div = document.getElementById(o.argument.MyTargetDIV);
		maincontent_div.innerHTML = o.responseText;

		window.scrollBy(0,1); window.scrollBy(0,-1); 
	}
}

var handleFailure_ChangePage = function(o){
	if(o.responseText !== undefined){
		var maincontent_div = document.getElementById(o.argument.MyTargetDIV);
		maincontent_div.innerHTML = o.responseText;
	}
}

function MyChangePage(TargetModule, TargetFile, TargetDIV, UserParam01)
{
	
	var callback_ChangePage =
	{
	  success: handleSuccess_ChangePage,
	  failure: handleFailure_ChangePage,
	  argument: {MyTargetDIV: TargetDIV}
	};

	var maincontent_div = document.getElementById(TargetDIV);
	
	if(maincontent_div!=null){ 
		maincontent_div.innerHTML = "<IMG SRC=\"images/icons/loading2.gif\" WIDTH=\"42\"/>";
	}else{
		return;
	}

	var TargetURL = 'subrender/' + TargetModule + '/' + TargetFile + '.php';
	TargetURL=TargetURL+"?sid="+Math.random()
	TargetURL=TargetURL+"&"+UserParam01

	var request = YAHOO.util.Connect.asyncRequest('GET', TargetURL, callback_ChangePage); 
}

function ChangePage(TargetModule, TargetFile, TargetDIV, UserParam01)
{
	MyChangePage(TargetModule, TargetFile, TargetDIV, UserParam01);return;
/*	
	var curdate = new Date()
	var xnum = curdate.getTime();
	var contentparam = ""+TargetModule+"suwcnt"+TargetFile+"suwcnt"+TargetDIV+"suwcnt"+UserParam01+"suwcnt"+xnum;
alert(contentparam);
	YAHOO.util.History.navigate("suwcontent", contentparam);
	//loadSection(contentparam);
	//alert('a');
*/
}

function loadSection(state) {
	// do cut string //
	//alert(state);
	var pageinfoarray=state.split("suwcnt");
	MyChangePage(pageinfoarray[0], pageinfoarray[1], pageinfoarray[2], pageinfoarray[3]);
	//alert(pageinfoarray[0]+" "+pageinfoarray[1]+" "+pageinfoarray[2]+" "+pageinfoarray[3]);

	
}

function CallFunction(FunctionFile, TargetDIV, UserParam01)
{
	var callback_ChangePage =
	{
	  success: handleSuccess_ChangePage,
	  failure: handleFailure_ChangePage,
	  argument: {MyTargetDIV: TargetDIV}
	};

	var maincontent_div = document.getElementById(TargetDIV);
	//maincontent_div.innerHTML = "Wait!";

	var TargetURL = FunctionFile;
	TargetURL=TargetURL+"?sid="+Math.random()
	TargetURL=TargetURL+"&"+UserParam01

	var request = YAHOO.util.Connect.asyncRequest('GET', TargetURL, callback_ChangePage); 
}





var initSection = "contentssuwcntmainvwsuwcntDIV_MAINCONTENTsuwcntundefined";


// Register our only module. Module registration MUST take place
// BEFORE calling initializing the browser history management library!
YAHOO.util.History.register("suwcontent", initSection, function (state) {
        // This is called after calling YAHOO.util.History.navigate,
        // or after the user has trigerred the back/forward button.
        // We cannot distinguish between these two situations.
        loadSection(state);
    });



// Initialize the browser history management library.
try {
	YAHOO.util.History.initialize("yui-history-field", "yui-history-iframe");
} catch (e) {
	// The only exception that gets thrown here is when the browser is
	// not supported (Opera, or not A-grade) Degrade gracefully.
	// Note that we have two options here to degrade gracefully:
	//   1) Call initializeNavigationBar. The page will use Ajax/DHTML,
	//      but the back/forward buttons will not work.
	//   2) Initialize our module. The page will not use Ajax/DHTML,
	//      but the back/forward buttons will work. This is what we
	//      chose to do here:
	alert('Error history initialization');
	//loadSection("Error");
}



