function checkPwString(obj)
{
	val = obj.value;
	pw_length = val.length;

	if(pw_length < 6)
	{
		alert("密碼輸入至少6個字");
		return false;
	}
	return true;
}

function Check_Password(obj)
{
	new_p = document.getElementsByName("password")[0].value;
	col_p = obj.value
	
	if(new_p != col_p )
	{
		alert("密碼二次輸入不一樣，請重新輸入！")
		return false;
	}
	
	return true;	
}

function changeRowColor2(table,color,type)
{
	if (type == undefined)
		type = 0;
	
	if (table == undefined && table != "")
	{
		table = document.getElementById(table);
		tags = Array(1);
		tags[0] = table;
	}
	else
	{
		tags = document.getElementsByTagName("table");
	}
	
	for(i=0;i<tags.length;i++)
	{
		table = tags[i];
		
		if(table.id == "nochange" ||table.id == "table_approdcost")
			continue;
		
		for(var j=1;j<table.rows.length;j++)
		{
			if (j%2 == type)
			{
				
				table.rows[j].style.backgroundColor = color;
			}
		}
	}
}
function changecolorover(obj)
{
	obj.style.backgroundColor = '#FFBB68';
	obj.style.color = 'Black';
}

function changecolorout(obj)
{
	obj.style.backgroundColor = '';
	obj.style.color = 'Black';
}

var idIndex = new Array(500);
var idCount = new Array(500);

function parseRowId(table)
{
	for(var i=0;i<500;i++)
	{
		idIndex[i] = 0;
		idCount[i] = 0;
	}
				
	table = document.getElementById(table);
	for(var i=0;i<table.rows.length;i++)
	{
		if (table.rows[i].id != "")
		{
			id = parseInt(table.rows[i].id);
			
			if (idIndex[id] == 0)
				idIndex[id] = i;
			
			idCount[id] = idCount[id]+1;
		}
	}
}

function check_email(email)
{
	if(email != "")
	{
		email = trim(email);
		//alert("email :"+email);
		var re1 = /^(\w|-|\.|_)+@(\w|_)(\w|-|\.|_)+$/i ;
		// matches emails like 'user@domain.suffix.etc'
		if(re1.test(email)==false)
		{
			alert("請輸入正確的E-Mail格式");
			return false;
		}
		else
			return true;
	}
	else
		return true;
}

function toggleRowId2(table,id)
{
	table = document.getElementById(table);
	
	j = idIndex[id] + idCount[id];
	for(var i=idIndex[id];i<j;i++)
		 toggleDisplay(table.rows[i]);
}

function confirmUrlDelete(url,item)
{
	var msg = LANG["MSG_CONFIRM_DELETE"]  + item + " ?";
	
	if (confirm(msg))
	{
		if (url != null && url != '')
		{
			//alert(url);
			location = url;
		}
	}
	
	return false;
}

function confirmUrlDownload(url,item)
{
	var msg = LANG["MSG_CONFIRM_DOWNLOAD"]  + item + " ?";

	var butt = document.getElementById("del_butt").style.visibility;

	if (confirm(msg))
	{
		if (url != null && url != '')
		{
			document.getElementById("del_butt").style.visibility = 'hidden';
			location = url;
		}
	}
	
	return false;
}

$(function() {
$('#set1 *').tooltip();

$("#foottip a").tooltip({
	bodyHandler: function() {
		return $($(this).attr("href")).html();
	},
	showURL: false
});

$('#tonus').tooltip({
	delay: 0,
	showURL: false,
	bodyHandler: function() {
		return $("<img/>").attr("src", this.src);
	}
});

$('#yahoo a').tooltip({
	track: true,
	delay: 0,
	showURL: false,
	showBody: " - ",
	fade: 250
});

$("select").tooltip({
	left: 25
});

$('#right2 a').tooltip({ showURL: false, positionLeft: true });

$("#block").click($.tooltip.block);

});
