function isValidEmail(email) 
{
	var patern=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; 
	if(patern.test(email)) return true;
	return false;
}

function ClosePopDlg()
{
	$(".popdlg").css("display","none");
}

// menu
function popup_menu(event)
{
	$("#product_submenu").slideDown(200);
}

function close_menu(event)
{
	$("#product_submenu").slideUp(200);
}

function add_hover_menu_item()
{
	$(this).addClass("hover_menu_item");
}

//default text for :text and textarea
function del_hover_menu_item()
{
	$(this).removeClass("hover_menu_item");
}

function set_txt_def()
{// blur
	if($(this).val()=="") $(this).val($(this).attr("title"));
}

function clr_txt_def()
{// focus
	if($(this).val()==$(this).attr("title")) $(this).val("");
}

function set_text_attr(items)
{
	items.bind('focus',clr_txt_def);
	items.bind('blur',set_txt_def);
	items.each(set_txt_def);
	items.addClass("input_text");
}

$(function()
{
	$("#product_menu").hover(popup_menu,close_menu);
	$(".menuItem").hover(add_hover_menu_item,del_hover_menu_item);

	set_text_attr($(":text"));
	set_text_attr($("textarea"));
})


//templates page vote
function xajax_vote(id,v)
{
	$.getJSON(
	"/product/album-creator/update_vote.php",{id:id, v:v},
	function(json)
	{
		votes[id]=json.rate;
		ResetImg(id);
		$("#T" + id + "_Text").html(json.text);
	});
}

function ShowImg(id, nstar)
{
	$("#T" + id + "_Img").attr("src", "/images/" + nstar + "star.gif");
}

function ResetImg(id)
{
	ShowImg(id,votes[id]);
}
