// file was created by eron armstrong
// for task: 26327
// this file is used to store necessary reusable methods


// js method updates the photo_id parameter of page url
// because we need to save the state each time an image
// is clicked. cliclets(digg, delicious, etc) needs to
// know the state of page. this should be put into a class
// but i didnt have time to do it. the class method would
// take paramName, newValue, and the full url with querystring,
// and it would return the new modified url. note: this will
// only work with parameters that are equal to numbers, such as
// photo_id=323432
function modifyStateUrl(urlState, parameterName, newValue, type /* int|string */)
{
  	// if url has photo_id in it, modify it
	if(urlState.indexOf(parameterName) > 0)
 	{
		var regEx;
 	 	if(type == 'int') 
		{
 	  		regEx = new RegExp(parameterName + "=([0-9])*");
 	  	}
		urlState =  urlState.replace(regEx,parameterName+ "=" +newValue)
	}
	// else, add it on
	else
	{
	 	urlState += urlState.indexOf("?") > 0 ? "&" +parameterName+ "=" + newValue : "?"+parameterName+"=" + newValue; 
	}
	
	return urlState;
}