//
// Default Javascript Functions
//
// toadDesign Web Studio
// Author: Toad Xu <toad@toad.com.tw>
//

// setting

window.defaultStatus = "";

// template writeln

function tpl_linesquare()
{
	if ( arguments.length==0 )
		return;

	var oPart = arguments[0];
	var oWidth = ( arguments[1]!=undefined ) ? arguments[1] : "100%";
	var oHeight = ( arguments[2]!=undefined ) ? arguments[2] : "300";

	document.open();
	switch ( oPart )
	{
		case "start":
			document.writeln( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\""+ oWidth + "\" height=\"" + oHeight + "\">" );
			document.writeln( "	<tr>" );
			document.writeln( "		<td rowspan=\"2\" colspan=\"2\" width=\"5\" height=\"5\"><img src=\"images/squareset_0/topleft.gif\" border=\"0\"></td>" );
			document.writeln( "		<td bgcolor=\"#a5a5a5\" height=\"1\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\"></td>" );
			document.writeln( "		<td rowspan=\"2\" colspan=\"2\" width=\"5\" height=\"5\"><img src=\"images/squareset_0/topright.gif\" border=\"0\"></td>" );
			document.writeln( "	</tr>" );
			document.writeln( "	<tr>" );
			document.writeln( "		<td bgcolor=\"#ffffff\" height=\"1\"><img src=\"images/spacer.gif\" width=\"1\" height=\"4\" border=\"0\"></td>" );
			document.writeln( "	</tr>" );
			document.writeln( "	<tr>" );
			document.writeln( "		<td bgcolor=\"#a5a5a5\" width=\"1\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\"></td>" );
			document.writeln( "		<td bgcolor=\"#ffffff\" width=\"4\"><img src=\"images/spacer.gif\" width=\"4\" height=\"1\" border=\"0\"></td>" );
			document.writeln( "		<td align=\"left\" valign=\"top\" style=\"padding:10px;\">" );
			break;
		case "end":
			document.writeln( "		</td>" );
			document.writeln( "		<td bgcolor=\"#ffffff\" width=\"4\"><img src=\"images/spacer.gif\" width=\"4\" height=\"1\" border=\"0\"></td>" );
			document.writeln( "		<td bgcolor=\"#a5a5a5\" width=\"1\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\"></td>" );
			document.writeln( "	</tr>" );
			document.writeln( "	<tr>" );
			document.writeln( "		<td rowspan=\"2\" colspan=\"2\" width=\"5\" height=\"5\"><img src=\"images/squareset_0/bottomleft.gif\" border=\"0\"></td>" );
			document.writeln( "		<td bgcolor=\"#ffffff\" height=\"1\"><img src=\"images/spacer.gif\" width=\"1\" height=\"4\" border=\"0\"></td>" );
			document.writeln( "		<td rowspan=\"2\" colspan=\"2\" width=\"5\" height=\"5\"><img src=\"images/squareset_0/bottomright.gif\" border=\"0\"></td>" );
			document.writeln( "	</tr>" );
			document.writeln( "	<tr>" );
			document.writeln( "		<td bgcolor=\"#a5a5a5\" height=\"1\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\"></td>" );
			document.writeln( "	</tr>" );
			document.writeln( "</table>" );
			break;
		default:
			break;
	}
	document.close();
}

function tpl_separator()
{
	var oStyle = ( arguments[0]!=undefined ) ? arguments[0] : "normal";
	document.open();
	switch ( oStyle )
	{
		case "normal":
			document.writeln( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">" );
			document.writeln( "	<tr>	<td bgcolor=\"#c0c0c0\" height=\"1\"><img src=\"images/pixel/blank.gif\" border=\"0\" width=\"1\" height=\"1\"></td></tr>" );
			document.writeln( "	<tr>	<td bgcolor=\"#f0f0f0\" height=\"1\"><img src=\"images/pixel/blank.gif\" border=\"0\" width=\"1\" height=\"1\"></td></tr>" );
			document.writeln( "	<tr>	<td bgcolor=\"#f9f9f9\" height=\"2\"><img src=\"images/pixel/blank.gif\" border=\"0\" width=\"1\" height=\"2\"></td></tr>" );
			document.writeln( "</table>" );
			break;
		default:
			break;
	}
	document.close();
}

function tpl_button()
{
	if ( arguments.length<3  || ( arguments.length % 2 ) != 1 )
	{
		with ( document )
		{
			writeln( "<font style=\"color:red;font-size:11px;font-family:'Times New Roman';font-weight:bold;\">" );
			writeln( "Warning: Arguments number should be odd & greater than two for JavaScript function 'tpl_button'." );
			writeln( "</font>" );
		}
		return;
	}

	var buttonStyle = ( arguments[0]!=undefined && arguments[0]!="" && arguments[0]!=null ) ? arguments[0] : "aqua";
	var buttonNumber = parseInt( arguments.length ) - 1;
	var oColspan = 3 * buttonNumber;
	var buttonText;

	document.writeln( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" );
	document.writeln( "	<tr>" );

	/* generating buttons */
	var buttonText, buttonLink, clickAction, cellEvent, textcellEvent;
	for ( var i=1; i<arguments.length; i=i+2 )
	{
		buttonText = arguments[i];
		buttonLink = arguments[ (i+1) ];
		cellEvent = "";
		textcellEvent = " class=\"button_normal\"";
		if ( buttonLink!="" )
		{
			if ( buttonLink.toLowerCase().indexOf("javascript")!=-1 )
			{
				clickAction = " onClick=\"" + buttonLink + "\"";
			} else {
				clickAction = " onClick=\"document.location.href='" + buttonLink + "';\"";
			}
			cellEvent = clickAction + " style=\"cursor:hand;\"";
			textcellEvent += " onMousedown=\"this.className='button_pressed';\" onMouseup=\"this.className='button_normal';\"" + clickAction;
		}
		document.writeln( "<td" + cellEvent + "><img src=\"images/buttonset/" + buttonStyle + "_left.gif\" border=\"0\"></td>" );
		document.writeln( "<td background=\"images/buttonset/" + buttonStyle + "_bg.gif\">" );
		document.writeln( "<div" + textcellEvent + ">" + buttonText + "</div>" );
		document.writeln( "</td>" );
		document.writeln( "<td" + cellEvent + "><img src=\"images/buttonset/" + buttonStyle + "_right.gif\" border=\"0\"></td>" );
	}

	document.writeln( "	</tr>" );
	document.writeln( "</table>" );

}

// locale

function sw_locale( localeFrom, localeTo )
{
	uri = location.href;
	newuri = eval( "uri.replace('/" + localeFrom + "/',\"/" + localeTo + "/\")" );
	location.href = newuri;
}

