Event.observe(window, 'load', init, false);

function hashCheck()
{
	//alert(window.location.hash);
	var strURL = window.location.hash;
	var strURL_array=strURL.split("/");
	var strLocation;
	var strPage;
	if (strURL_array.length==2) {
		strLocation = strURL_array[0];
		strLocation = strLocation.replace("#", "");
		strPage = strURL_array[1];
		
		
		var strReplaceAll = strPage;
		var intIndexOfMatch = strReplaceAll.indexOf( "%20" );

		// Loop over the string value replacing out each matching
		// substring.
		while (intIndexOfMatch != -1){
			// Relace out the current instance.
			strReplaceAll = strReplaceAll.replace( "%20", " " )

			// Get the index of any next matching substring.
			intIndexOfMatch = strReplaceAll.indexOf( "%20" );
		}
		
		
		if(strLocation == 'detail')
		{
			thumbs(strReplaceAll);
		}
		
	}
}

function init(){
	hashCheck();
}


function fetch(target,page){
	var url = '/pages/gallery_rpc.php';
	var pars = 'task='+target+'&page='+page;
	var myAjax = new Ajax.Updater(target, url, { method: 'get',	parameters: pars });
}


function thumbs(sku){
	var target = 'gallery_detail';
	var url = '/pages/gallery_thumb_rpc.php';
	var pars = 'sku='+escape(sku);
	var myAjax = new Ajax.Updater(target, url, { method: 'get',	parameters: pars, evalScripts: true });
}
