/*******************************************************************************
 * User Public Process Unit
 ******************************************************************************/
iReset = {};

/*******************************************************************************
 * UserDIY::Set Header background
 ******************************************************************************/
iReset.setHeaderBackground = function($f, $c) {
	if ($f != '') {
		$bg = 'http://'+R_HOST + '/users/udiy/1024/headers/' + $f;
		$('.header').css( {
			'background' :'url(' + $bg + ') repeat-x'
		});
	}
	if ($c != '') {
		$('.header .name').css( {
			'color' :'#' + $c
		});
	}
}

/*******************************************************************************
 * Show Product Large Image
 ******************************************************************************/
iReset.showProductLargeImage = function(id, title, image) {
	$.showbox.ds('<img src="'
		+ USERS_URI_SERVER_MAIN
		+ 'pub/p/b/'
		+ image
		+ '" width="360" height="360" align="center" '
		+ 'style="background:#F6F6F6 url('+USERS_URI_SERVER_APP + 'images/loader.gif) no-repeat center center;border:1px solid #ddd;" />',
		{
			title :title,
			type :'showbox',
			showCancel :false,
			focus :'.dialog-ok',
			width :380,
			height :380
		}
	);
}

/*******************************************************************************
 * Admin Login submit
 ******************************************************************************/
iReset.adminLoginSubmit = function(f)
{
	if ($('#fld_user').val().length < 3 || $('#fld_user').val().length > 36) {
		sDialog.pds('error', 'Check User Name failure.');
		return false;
	}
	else if ($('#fld_pwd').val().length < 6 || $('#fld_pwd').val().length > 65)
	{
		sDialog.pds('error', 'Check Password failure.');
		return false;
	}
	else if ($('#fld_checkcode').val().length != 4)
	{
		sDialog.pds('error', 'Check Check Code failure.');
		return false
	}

	try {
		$('#fld_pwd').val(hex_md5($('#fld_pwd').val()));
		$('#login').attr('action', $('#postAction').val());
		return true;
	}
	catch (e)
	{
		sDialog.pds('error', 'Security Alert::Security Crypt Failure.');
		return false;
	}
}




/*******************************************************************************
 *  contact us
 ******************************************************************************/
iReset.contactUsSubmit = function()
{
	$url = $('#postAction').val() + '/rnd/' + getStringRandom();
	$data = $('#inquire').serialize();

	$.post($url, $data, function(data) {
		data = eval('(' + data + ')');
		msg = eval(data.msg);
		msg = msg.replaceAll('\n\n', '<br />');
		if (data.status == 'pass') {
			sDialog.pds('success', msg);
			//window.setTimeout("location.reload();", 5000);
		} else {
			sDialog.pds('error', msg);
		}
	});
	return false;
}


