	/*
	* File: common.js
	*/

	$(document).ready(function () {

		$("#popupLoginLink").click(function () {
			$("#popup_login").slideDown("fast");
		});

		$("#popupLoginClose").click(function () {
			$("#popup_login").slideUp("fast");
		});

		$("#divePhotoGuidePortal").html($("#divePhotoGuide").html());

		$("#brtt a").click(function () {
			$("#brtt a").removeClass("on");
			$(this).addClass("on");

			$(".brttc").hide();
			$("#" + $(this).attr("id") + "_content").show();
		});
		
	});


	////
	// redirecting to user account page
	//
	function readFullNewsfeed()
	{
		window.location = accountUrl;
		return false;
	} // /readFullNewsfeed

	var location_hash = document.location.hash.length > 0 ? document.location.hash.substr(1) : "";

	////
	// shows big product image
	//
	function showImage(imgFileName)
	{
		if (imgFileName != "" && (imgElm = document.getElementById('box_image')))
		{
			imgFile = '/images/products/b/' + imgFileName;

			if (imgFile != "")
			{
				imgElm.style.backgroundImage = 'url(/img/clear.gif)';
				imgElm.style.backgroundImage = 'url(' + imgFile + ')';
			}
		}

		return true;
	} // showBigImage()


	function hide()
	{
		if(hide.arguments.length > 0)
		{
			var el = hide.arguments[0];
			el = (typeof(el) == "string") ? document.getElementById(el) : el;
			if(el && typeof(el) == "object") el.style.display = "none";
		}
		return false;
	}

	function show()
	{
		var display = "block";
		if(show.arguments.length > 0)
		{
			if(show.arguments.length > 1)
			{
				display=show.arguments[1];
			}
			var el = show.arguments[0];
			el = (typeof(el) == "string") ? document.getElementById(el) : el;
			if(el && typeof(el) == "object")el.style.display = display;
		}
		return false;
	}

	function remove()
	{
		if(remove.arguments.length > 0)
		{
			var el = remove.arguments[0];
			el = (typeof(el) == "string") ? document.getElementById(el) : el;
			if(el && typeof(el) == "object") el.parentNode.removeChild(el);
		}
		return false;
	}

	function include(filename)
	{
		var scripts = document.getElementsByTagName("script");
		for(var i in scripts) if(scripts[i].src == filename) return false;

    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', filename);
    html_doc.appendChild(js);
    return false;
	}//include
	
	


	function displayRate(stars, rate){
		rate = parseFloat(rate);

		var rate1 = parseInt(rate);
		var rate2 = rate1 + 0.5;
		if(rate2 <= rate){
			rate1 = rate2;
			rate2 = rate1 + 0.5;
		}

		rate = (rate - rate1 <= rate2 - rate) ? rate1 : rate2;
		
		var star;
		$(stars).each(function(i,e){e = $(e);i++;
			if(i - 0.5 == rate) star = '_half';
			else if(i <= rate) star = '_full';
			else star = '_empty';
			e.attr("src", e.attr("src").replace('_empty', star).replace('_half', star).replace('_full', star));
		});
			
		return false;
	}//displayRate

