/* common.js */
// allows multiple functions attached to the window.onload event
if ( typeof( addLoadEvent ) == "undefined" ) {
	function addLoadEvent(f) { var old = window.onload; if (typeof window.onload != 'function') { window.onload = f; } else { window.onload = function onloadHandler() { old(); f();} } }
}

function showRecaptcha(element, submitButton, themeName) {
  Recaptcha.create("6LdisAMAAAAAAD6MMhKmHDPFq6dR8Qg2XHXnT85t", element, {
        theme: themeName,
        tabindex: 0,
        callback: Recaptcha.focus_response_field
  });
  }


function setLoader( state , loaderEl ){
	
	var loadingObj;
	var loadingImg = "/images/loader-rectangle.gif";
	var loadingImgTag = "Please Wait... <img src='" + loadingImg + "' border='0' /> ";
	
	if( typeof(loaderEl) == "string" ) loadingObj = document.getElementById(loaderEl);
	else if( typeof(loaderEl) == "object" ) loadingObj = loaderEl;
	
	loadingObj.innerHTML = loadingImgTag;
	
	if( state == 'on' ) loadingObj.style.display = 'block';
	else loadingObj.style.display = 'none';
}



//function iAmLoading(where ,	containerEl, contentUrl){
//	setLoader( 'on' , where );
//	setTimeout("Spry.Utils.updateContent('"+containerEl+"', '"+contentUrl+"',function() { setLoader( 'off' , '"+where+"' ); })",1);
//	$("#feeds").load("feeds.html");
//
//}

function iAmLoading(where ,	containerEl, contentUrl){
	setLoader( 'on' , where );
	$("#"+containerEl).load(contentUrl,function() { setLoader( 'off' , where ); });
}


function AjaxRating(collection_id, release_id, rating){
	Spry.Utils.updateContent('','/mytown/mymovies-incl/details.php?release-id=' + release_id + '&collection-id=' + collection_id + '&rating=' + rating);
	document.getElementById(collection_id + "_rating").className = 'r' + rating;
}

function AjaxCollection(collection_id, release_id){
	
	Spry.Utils.updateContent('','/mytown/mymovies-incl/details.php?release-id=' + release_id + '&collection-id=' + collection_id + '&CollectionAdd=1');
	
	var myEl = document.getElementById(release_id + 'addCollection' + collection_id);
	myEl.className = 'Collection' + collection_id + 'Added';
	
	if (collection_id == 1)
	{
		myEl.setAttribute('href','/mytown/mymovies');
	}
	else
	{
		myEl.setAttribute('href','/mytown/mymovies/mywishlist/2');
	}
	
	//myEl.removeAttribute('onclick');
	myEl.setAttribute('onclick','return true;');
	
}