/*
	Preload functions
*/
jQuery(function()  
{
	loadPage();
	if(typeof internalLoadPage == 'function') 
	{
		internalLoadPage();
	}
	
});
/********************************************************************************************************************************
* 
********************************************************************************************************************************/

function loadPage()
{
	var CurrentStatus
	/********************************************************************************************************************************
	* Action for change color when select on theck box in mange page
	********************************************************************************************************************************/
	$("input[id='ckCheckAll']").bind("click", function()
	{
		var checked_status = this.checked;
		$("input[name='id[]']").each(function() {selectRow(this,checked_status, true)});
		//Select for or header footer checkbox too
		$("input[name='ckCheckAll']").each(function()
		{
			this.checked = checked_status;
		});
	});
	$("input[name='id[]']").bind("click", function()
	{
		var checked_status = !this.checked; //Because the tr checked too
		//alert(checked_status);
		selectRow(this, checked_status, true);
		
	});
	function selectRow(target, checked_status, isChecked)
	{
		if(isChecked)
		{
			$(target).attr("checked",checked_status);
		}
		//target.checked = checked_status;
		
		//change the color of tr
		if(checked_status)
		{
			$(target).parent().parent().addClass("selected");
		}
		else
		{
			$(target).parent().parent().removeClass("selected");
		}
	}
	/********************************************************************************************************************************
	* End of Action for change color when select on theck box in mange page
	********************************************************************************************************************************/
	/********************************************************************************************************************************
	* Hover row when mouse over in manage page
	********************************************************************************************************************************/
	$(".manage tbody tr").hover(manageRowHover, manageRowOut);
	function manageRowHover()
	{
		//$(this).addClass("hover");
		var actionRow = $(this).find("div[class='row_action']");
		//alert("Hover");
		/*
		if(!$(this).find("div[class='row_action']").size())
		{
			var updateLink = "<a href=\"#\">Edit</a>";
			var deleteLink = "<a href=\"#\">Delete</a>";
			var quickUpdate = "<a href=\"#\">Quick Edit</a>";
			var actionHtml = "<div class=\"row_action\">" + updateLink + " | " + deleteLink + " | " + quickUpdate + "<div>";
			nameRow.append(actionHtml);
			
		}
		*/
	}
	function manageRowOut()
	{
		$(this).removeClass("hover");
		
		/*
		if($(this).find("div[class='row_action']").size())
		{
			$(this).find("div[class='row_action']").remove();
		}
		*/
		//document.write('Mouse out');
	}
	
	
	$(".manage tbody tr td table, .manage tbody tr td a, .manage tbody tr td input[type=button]").bind("click", function(event)
	{
		event.stopPropagation();
	});
	
	$(".manage tbody tr").bind("click", function()
	{
		var checkbox = $(this).find("input[name='id[]']");
		var isChecked = !checkbox.attr("checked");
		//alert(isChecked);
		//checkbox.attr("checked",isChecked);
		selectRow(checkbox, isChecked, true);
	});
	/********************************************************************************************************************************
	* End of Hover row when mouse over in manage page
	********************************************************************************************************************************/	
	toggleCss();
	toggleMenu("options");
	toggleMenu("seoinfo");
	initUI();
	
	initControl();

}
/********************************************************************************************************************************
* 
********************************************************************************************************************************/
function initUI()
{
	try
	{
	$("#PublishedDate").datepicker();
	$("#ExpireDate").datepicker();
	//$('#PublishedDate').datepicker('option', {dateFormat: 'dd/mm/yy'}); for formating
	}
	catch(e){}
	
	if(typeof initInternalUI == 'function')  //check is there a trigger fucntion when upload done
	{
		initInternalUI();
	}
	displayDialog();
}
/********************************************************************************************************************************
* 
********************************************************************************************************************************/
function displayDialog()
{
	
	$("a[name='show_dialog']").click
	(
		function()
		{
			var loadLink = $(this).attr("title") + "&from=ajax";
			var loadControl = $(this).attr("href");
			var title = $(loadControl).attr("title");
			$(loadControl).load(loadLink).dialog({
				modal: true,
				bgiframe: true,
				autoOpen: false,
				height: 500,
				width: 500,
				draggable: true,
				resizeable: true
		 	}); 
			$(loadControl).dialog("open");
			return false;
		}
	);

	
}

/********************************************************************************************************************************
* 
********************************************************************************************************************************/

function toggleObject(objectName, isShow, appendHide, appendShow)
{
	if(isShow)
	{
		$("#" + objectName).show(300);
		if((appendHide != null) && (appendHide != ""))
		{
			$("#" + objectName + appendHide).hide();
		}
		if((appendShow != null) && (appendShow != ""))
		{
			$("#" + objectName + appendShow).show();
		}
	}
	else
	{
		$("#" + objectName).hide(300);
	}
	return false;
}
/********************************************************************************************************************************
* 
********************************************************************************************************************************/

function appendObject(aName, objectName, isShow)
{
	if(isShow)
	{	
		$("#" + aName).after($("#" + objectName));
		$("#" + objectName).show(300);
	}
	else
	{
		$("#" + objectName).hide(300);
	}
	return false;
}



/********************************************************************************************************************************
* 
********************************************************************************************************************************/

function toggleMenu(objectName)
{
	$("#" + objectName + "_detail").toggle(300);
	$("#" + objectName).toggle(
	function()
	{
		$("#" + objectName + "_detail").show(300);
		$("#" + objectName + " a").css('background','url(/includes/images/left_arrow.gif) no-repeat right');
	}, 
	function()
	{	
		$("#" + objectName + "_detail").hide(300);
		$("#" + objectName + " a").css('background','url(/includes/images/down_arrow.gif) no-repeat right');
	});
	return false;
}
/********************************************************************************************************************************
* 
********************************************************************************************************************************/

function toggleCss()
{
	$(".toggle").each(function() 
	{
		var id = $(this).attr("id");
		toggleMenu(id)
		 
	});
	
	 
	
	
	return false;
}

/********************************************************************************************************************************
* 
********************************************************************************************************************************/

function toggleAttributeMenu(objectName)
{
	$("#" + objectName + "_detail").toggle(300);
	if($("#" + objectName).attr("class")=="product_attribute_collapse")
	{
		$("#" + objectName).attr("class", "product_attribute_expand");
	}
	else
	{
		$("#" + objectName).attr("class", "product_attribute_collapse");
	}
	 
	return false;
}


/********************************************************************************************************************************
* 
********************************************************************************************************************************/
function initControl()
{
	//init for upload files
	$($(".javascript_off")).each(function()
	{
		var javascriptOffControl=$(this);
		javascriptOffControl.hide();
	});
	$($(".javascript_on")).each(function()
	{
		var javascriptOnControl=$(this);
		javascriptOnControl.show();
	});
	
	$("input[type='file']").each(function()
	{
		var fileControl=$(this);
		
		if(fileControl.attr("class") != "real_fileupload_control")
		{
			fileControl.hide();
		}
	});
	$($(".file_upload_control_title")).each(function()
	{
		var controlTitle=$(this);
		controlTitle.hide();
	});
	$(".file_upload_control_item").each(function()
	{
		var btnUpload=$(this);
		btnUpload.show();
		var uploadControlName = btnUpload.attr("id");
		var fileNameControl = uploadControlName.replace(/_AjaxControl/gi,"");
		uploadControlName = fileNameControl + "_Control";
		var responseControl = fileNameControl + "_Response";
		var status=$("#" + responseControl);
		var oldFileName = $("#" + fileNameControl).val();
		var actionUrl = window.location + "&from=ajax&uploadfile=1&controlname=" + uploadControlName + "&oldfilename=" + oldFileName + "&responsename=" + responseControl;
		
		//get the validation extension
		var acceptExtension = "";
		
		$(btnUpload).parent().find("input[type='hidden']").each(function()
		{
			
			if($(this).attr("id").indexOf("." + fileNameControl) >= 0)
			{
				acceptExtension = $(this).val();
				
			}
		});
		//alert(acceptExtension);
		actionUrl = actionUrl + "&acceptextension=" + acceptExtension;
		//alert(actionUrl);
		new AjaxUpload(btnUpload, {
			action: actionUrl,
			name: uploadControlName,
			onSubmit: function(file, ext)
			{
				
				//get the validation message
				var validationMessage = "";
				if((acceptExtension != "") && (acceptExtension != ""))
				{
					$(btnUpload).parent().find("span").each(function()
					{
						if($(this).attr("id").indexOf("." + fileNameControl) >= 0)
						{
							validationMessage = $(this).attr("title");
						}
					});
					if(!checkFile(file, acceptExtension))
					{
						alert(validationMessage);
						//status.html("<div class=\"error\">" + validationMessage + "</div>");
						return false;
					}
				}
				status.text('Uploading...');
			},
			dataType: "xml",
			onComplete: function(file, response)
			{
				status.text("");
			 
			 	
				$('Field',response).each(function(i)
				{
					var name = $(this).attr("name");
					//var dataValue = $(this).html();
					var dataValue = $(this).text();
					
					dataValue = dataValue.replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g, '$1');
					dataValue = dataValue.replace(/<!--\[CDATA\[([\s\S]+)\]\]>/g, '$1');
					dataValue = dataValue.replace(/&lt;!--\[CDATA\[([\s\S]+)\]\]--&gt;/g, '$1');
					dataValue = dataValue.replace(/<!--\[CDATA\[([\s\S]+)\]\]--&gt;/g, '$1');
					
					
				
					switch(name)
					{
						case "filename":
							$("#" + fileNameControl).val(dataValue);
							break;
						case "response":
							status.html(dataValue);
							break;
						default:
							//for other
							if(($('#' + name).is('input')) || ($('#' + name).is('textarea')) || ($('#' + name).is('select')) || ($('#' + name).is('input')))
							{
								$('#' + name).val(dataValue.toString());
							}
							else
							{
								$('#' + name).html(dataValue);
								$('#' + name + "_View").html(dataValue);
								
							}
							break;
					}
					
				});
				//initControl(); //Disable this to make the uplaod can be upload after upload
				if(typeof uploadDoneTrigger == 'function')  //check is there a trigger fucntion when upload done
				{
					uploadDoneTrigger(fileNameControl, response);
				}
				
			}
		});
	});
	//End of init for upload files

}
/*
	End of Preload functions
*/
/*
	AJAX functions
*/

/********************************************************************************************************************************
* Function Name: ajaxSubmit
* Description: Perform a submit form using ajax
********************************************************************************************************************************/
function ajaxSubmitXML(formName, buttonName, validationGroup, waitingMessage, websiteUrl)
{
	
	var validate = validateForm(validationGroup);
	//alert(buttonName);
	var continueAfterError = false;
	if(validate)
	{
		//Do ajax submit
		var form = $('#' + formName);
		var actionUrl = form.attr("action");
		
		var postData = form.serialize();
		postData = postData + "&" + buttonName + "=submit";
		if(actionUrl.indexOf("?") >= 0)
		{
			actionUrl = actionUrl + "&from=ajaxxml";
		}
		else
		{
			actionUrl = actionUrl + "?from=ajaxxml";
		}
		
		//prompt('aaa',actionUrl + "\r\n" + form.serialize());
		$.ajax(
		{
			type: "POST",
			url: actionUrl,
			data: postData,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
				$("#PageMessage").html(waitingIdicator);
			},
			dataType: "xml",
			success: function(data)
			{
				 
				$('Field',data).each(function(i)
				{
					var name = $(this).attr("name");
					var value = $(this).text();
					//alert(name + "-----" + value);
					if(($('#' + name).is('input')) || ($('#' + name).is('textarea')) || ($('#' + name).is('select')) || ($('#' + name).is('input')))
					{
						$('#' + name).val(value.toString());
					}
					else
					{
						
						$('#' + name).html(value);
					}
					$('#' + name + "_View").html(value);
				});
				if(typeof submitFormDoneTrigger == 'function')  //check is there a trigger fucntion when upload done
				{
					
					submitFormDoneTrigger();
				}
				//Remove the waiting Idicator
				//$("#PageMessage").html("");
				loadPage();
				//alert(data.PageMessage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
		
	}
	return continueAfterError;
}

/********************************************************************************************************************************
* Function Name: ajaxSubmit
* Description: Perform a submit form using ajax
********************************************************************************************************************************/
function ajaxSubmitJSON(formName, buttonName, validationGroup, waitingMessage, websiteUrl)
{
	var validate = validateForm(validationGroup);
	var continueAfterError = false;
	if(validate)
	{
		//Do ajax submit
		var form = $('#' + formName);
		var actionUrl = form.attr("action");
		//alert(form.serialize());
		var postData = form.serialize();
		postData = postData + "&" + buttonName + "=submit"
		if(actionUrl.indexOf("?") >= 0)
		{
			actionUrl = actionUrl + "&from=ajax";
		}
		else
		{
			actionUrl = actionUrl + "?from=ajax";
		}
		
		$.ajax(
		{
			type: "POST",
			url: actionUrl,
			data: postData,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
				$("#PageMessage").html(waitingIdicator);
				if(x && x.overrideMimeType) 
				{
					x.overrideMimeType("application/j-son;charset=UTF-8");
				}
			},
			dataType: "json",
			success: function(data)
			{
				
				//Remove the waiting Idicator
				$("#PageMessage").html("");
				$.each(data, function(entryIndex, entry) 
				{
					//alert('#' + entryIndex + "|" + ($('#' + entryIndex).is('select')) + "|" + entry);
					if(($('#' + entryIndex).is('input')) || ($('#' + entryIndex).is('textarea')) || ($('#' + entryIndex).is('select')) || ($('#' + entryIndex).is('input')))
					{
						$('#' + entryIndex).val(entry.toString());
					}
					else
					{
						
						$('#' + entryIndex).html(entry);
					}
					$('#' + entryIndex + "_View").html(entry);
				});
				//alert(data.PageMessage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
		
	}
	return continueAfterError;
}

/********************************************************************************************************************************
* Function Name: ajaxSubmit
* Description: Perform a submit form using ajax
********************************************************************************************************************************/

function ajaxSubmitDiv(divName, buttonName, validationGroup, responseObjectName, waitingObjectName, displayRow, actionUrl, waitingMessage, websiteUrl)
{
	var validate = validateForm(validationGroup);
	var continueAfterError = false;
	if(validate)
	{
		//Do ajax submit
		if(responseObjectName == "")
		{
			responseObjectName = "l_content";
		}
		if(waitingObjectName == "")
		{
			waitingObjectName = "PageMessage";
		}
		var appendDisplayRow = "";
		if(displayRow > 0)
		{
			appendDisplayRow = "&displayrow=" + displayRow;
		}
		var postData = $("#" + divName + " *").serialize();
		//alert(postData);
		postData = postData + "&" + buttonName + "=submit"
		actionUrl = actionUrl + appendDisplayRow + "&from=ajax";
		$.ajax(
		{
			type: "POST",
			url: actionUrl,
			data: postData,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<div class=\"waitingmessage\" name=\"waitingMessage\"><img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage + "</div>";
				$("#" + waitingObjectName).prepend(waitingIdicator);
			},
			dataType: "html",
			success: function(data)
			{
				//return false;
				//Remove the waiting Idicator
				$("#" + waitingObjectName).html("");
				
				$("#" + responseObjectName).html(data);
				loadPage();
				//alert(data.PageMessage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
		
	}
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: ajaxSubmit
* Description: Perform a submit form using ajax
********************************************************************************************************************************/

function ajaxSubmitDivXML(divName, buttonName, validationGroup, actionUrl, isResetForm, waitingMessage, websiteUrl, displayType, displayErrorType)
{
	var continueAfterError = false;
	if(displayErrorType == null)
	{
		displayErrorType = 1;
	}
	var validate = validateForm(validationGroup, displayErrorType);
	
	if(displayType == null)
	{
		displayType = 1;
	}
	if(validate)
	{
		//Do ajax submit
		var postData = $("#" + divName + " *").serialize();
		//alert(actionUrl);
		//alert(postData);
		postData = postData + "&" + buttonName + "=submit";
		if(actionUrl.indexOf("?") >= 0)
		{
			actionUrl = actionUrl + "&from=ajaxxml";
		}
		else
		{
			actionUrl = actionUrl + "?from=ajaxxml";
		}
		
		 
		$.ajax(
		{
			type: "POST",
			async: false,
			url: actionUrl,
			data: postData,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<div class=\"waitingmessage\" name=\"waitingMessage\"><img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage + "</div>";
				switch(displayType)
				{
					case 1:
						$("#" + divName).prepend(waitingIdicator);
						break;
					case 2:
						$("#" + divName).html(waitingIdicator);
						break;
				}
			},
			dataType: "xml",
			success: function(data)
			{
				
				//$("#" + waitingObjectName).html("");
				$("#" + divName).parent().find('.waitingmessage').remove();
				$('Field',data).each(function(i)
				{
					var name = $(this).attr("name");
					var value = $(this).text();
					//alert(name + "-----" + value);
					if(($('#' + name).is('input')) || ($('#' + name).is('textarea')) || ($('#' + name).is('select')) || ($('#' + name).is('input')))
					{
						$('#' + name).val(value.toString());
					}
					else
					{
						
						$('#' + name).html(value);
					}
					
					if(isResetForm)
					{
						$("#" + divName).find("input[type=text]").each(function()
						{
							$(this).val("");
						});
					}
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
		
	}
	//alert(continueAfterError);
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: ajaxDeleteItem
* Description: delete 1 item
********************************************************************************************************************************/
function ajaxActionItem(confirmMessage, waitingMessage, strDeleteUrl, websiteUrl)
{
	var continueAfterError = false;
	if(confirm(confirmMessage))	
	{
		var actionUrl = strDeleteUrl;
		if(actionUrl.indexOf("?") >= 0)
		{
			actionUrl = actionUrl + "&from=ajax";
		}
		else
		{
			actionUrl = actionUrl + "?from=ajax";
		}
		actionUrl = actionUrl + "&confirm=yes";
		//alert(actionUrl);
		$.ajax(
		{
			type: "GET",
			url: actionUrl,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
				$("#PageMessage").html(waitingIdicator);
			},
			dataType: "html",
			success: function(data)
			{
				//Remove the waiting Idicator
				$("#PageMessage").html("");
				
				$("#l_content").html(data);
				
				//alert(data.PageMessage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
	}
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: ajaxLink
* Description: 
********************************************************************************************************************************/
function ajaxView(containerObject, strUrl, waitingMessage, websiteUrl, isDisplayCancel, cancelTitle)
{
	var continueAfterError = false;
	var actionUrl = strUrl;
	if(actionUrl.indexOf("?") >= 0)
		{
			actionUrl = actionUrl + "&from=ajax";
		}
		else
		{
			actionUrl = actionUrl + "?from=ajax";
		}
	//alert(strUrl);
	
	$.ajax(
	{
		type: "GET",
		url: actionUrl,
		timeout: 50000,
		beforeSend: function(x) 
		{
			var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
			$("#" + containerObject).html(waitingIdicator);
		},
		dataType: "html",
		success: function(data)
		{
			$("#" + containerObject).hide();
			$("#" + containerObject).show(300);
			//Remove the waiting Idicator
			if(isDisplayCancel)
			{
				data = data + "<div><input type=\"button\" value=\"" + cancelTitle + "\" onclick=\"toggleObject('" + containerObject + "', false);\" /><div>";
			}
			$("#" + containerObject).html(data);
			loadPage();
			//alert(data.PageMessage);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
	});
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: ajaxLink
* Description: 
********************************************************************************************************************************/
function ajaxGetUrlContent(strUrl)
{
	var strReturnValue = "";
	$.ajax(
	{
		type: "GET",
		url: strUrl,
		async:false,
		timeout: 50000,
		dataType: "html",
		success: function(data)
		{
			strReturnValue = data;
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
	});
	return strReturnValue;
}
/********************************************************************************************************************************
* Function Name: ajaxChangeCombo
* Description: 
********************************************************************************************************************************/
function ajaxChangeCombo(target, urlparams, strUrl, waitingMessage, websiteUrl)
{
	return changeCombo(target, urlparams, strUrl);
	$.each(urlparams, function(queryKey, queryValue) 
	{
		if(strUrl.indexOf("&" + queryKey + "=") > 0)
		{
			strUrl = strUrl.replace("&" + queryKey + "=" + queryValue, "&" + queryKey + "=" + target.value);
		}
		else
		{
			strUrl = strUrl + "&" + queryKey + "=" + target.value
		}
	});
	ajaxLink(strUrl, waitingMessage, websiteUrl);
}
/********************************************************************************************************************************
* Function Name: ajaxChangeCombo
* Description: 
********************************************************************************************************************************/
function changeCombo(target, urlparams, strUrl)
{
	$.each(urlparams, function(queryKey, queryValue) 
	{
		if(strUrl.indexOf("&" + queryKey + "=") > 0)
		{
		
			strUrl = strUrl.replace("&" + queryKey + "=" + queryValue, "&" + queryKey + "=" + target.value);
		}
		else
		{
			strUrl = strUrl + "&" + queryKey + "=" + target.value
		}
	});
	//alert(strUrl);
	window.location.href = strUrl;
}
/********************************************************************************************************************************
* Function Name: ajaxChangeCombo
* Description: 
********************************************************************************************************************************/
function ajaxControlAction(target, urlparams, strUrl, waitingMessage, websiteUrl, responseObjectName, waitingObjectName, isHiddenLoading)
{
	$.each(urlparams, function(queryKey, queryValue) 
	{
		
		if(strUrl.indexOf("&" + queryKey + "=") > 0)
		{
			strUrl = strUrl.replace("&" + queryKey + "=" + queryValue, "&" + queryKey + "=" + target.value);
			//alert(strUrl  + "--------&" + queryKey + "=" + queryValue + "------"  + "&" + queryKey + "=" + target.value);
		}
		else
		{
			strUrl = strUrl + "&" + queryKey + "=" + target.value;
		}
		
	});
	ajaxLinkControl(strUrl, waitingMessage, websiteUrl, responseObjectName, waitingObjectName, isHiddenLoading);
}
/********************************************************************************************************************************
* Function Name: ajaxTabLinkControl
* Description: 
********************************************************************************************************************************/
function ajaxTabLinkControl(tabID, target, strUrl, waitingMessage, websiteUrl, responseObjectName, waitingObjectName)
{
	ajaxLinkControl(strUrl, waitingMessage, websiteUrl, responseObjectName, waitingObjectName);
	$("#" + tabID + " li").removeAttr("class");
	$(target).parent().attr("class", "selected");
	return false;
}
/********************************************************************************************************************************
* Function Name: ajaxLink
* Description: 
********************************************************************************************************************************/
function ajaxLinkControl(strUrl, waitingMessage, websiteUrl, responseObjectName, waitingObjectName, isHiddenLoading)
{
	var continueAfterError = false;
	var actionUrl = strUrl;
	
	if(actionUrl.indexOf("?") >= 0)
	{
		actionUrl = actionUrl + "&from=ajaxcontrol";
	}
	else
	{
		actionUrl = actionUrl + "?from=ajaxcontrol";
	}
	 
	//Do ajax submit
	if((responseObjectName == null) || (responseObjectName == ""))
	{
		responseObjectName = "l_content";
	}
	if((waitingObjectName == "") || (waitingObjectName == null))
	{
		waitingObjectName = "PageMessage";
	}
	if(isHiddenLoading == null)
	{
		isHiddenLoading = false;
	}
	//alert(actionUrl);
	$.ajax(
	{
		type: "GET",
		url: actionUrl,
		timeout: 50000,
		beforeSend: function(x) 
		{
			if(!isHiddenLoading)
			{
				var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
				$("#" + waitingObjectName).html(waitingIdicator);
			}
		},
		dataType: "html",
		success: function(data)
		{
			//Remove the waiting Idicator
			$("#" + waitingObjectName).html("");
			//alert("-------" + data);
			$("#" + responseObjectName).html(data);
			loadPage();
			//alert(data.PageMessage);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
	});
	return continueAfterError;
}

/********************************************************************************************************************************
* Function Name: ajaxLink
* Description: 
********************************************************************************************************************************/
function ajaxLink(strUrl, waitingMessage, websiteUrl, responseObjectName, waitingObjectName)
{
	var continueAfterError = false;
	var actionUrl = strUrl;
	if(actionUrl.indexOf("?") >= 0)
	{
		actionUrl = actionUrl + "&from=ajax";
	}
	else
	{
		actionUrl = actionUrl + "?from=ajax";
	}
	//Do ajax submit
	if((responseObjectName == null) || (responseObjectName == ""))
	{
		responseObjectName = "l_content";
	}
	if((waitingObjectName == "") || (waitingObjectName == null))
	{
		waitingObjectName = "PageMessage";
	}
	
	$.ajax(
	{
		type: "GET",
		url: actionUrl,
		timeout: 50000,
		beforeSend: function(x) 
		{
			var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
			$("#" + waitingObjectName).html(waitingIdicator);
		},
		dataType: "html",
		success: function(data)
		{
			//Remove the waiting Idicator
			$("#" + waitingObjectName).html("");
			$("#" + responseObjectName).html(data);
			loadPage();
			//alert(data.PageMessage);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
	});
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: ajaxLinkXML
* Description: Perform an ajax link and return as xml format
********************************************************************************************************************************/
function ajaxLinkXML(strUrl, waitingMessage, websiteUrl, confirmMessage, waitingObjectName)
{
	var continueAfterError = false;
	var actionUrl = strUrl;
	if(actionUrl.indexOf("?") >= 0)
	{
		actionUrl = actionUrl + "&from=ajaxxml";
	}
	else
	{
		actionUrl = actionUrl + "?from=ajaxxml";
	}
	if((waitingObjectName == null) || (waitingObjectName == ""))
	{
		waitingObjectName = "PageMessage";
	}
	var bConfirm = true;
	if(confirmMessage != "")
	{
		bConfirm = confirm(confirmMessage);
	}
	if(bConfirm)
	{
		$.ajax(
		{
			type: "GET",
			url: actionUrl,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
				$("#" + waitingObjectName).html(waitingIdicator);
			},
			dataType: "xml",
			success: function(data)
			{
				$("#" + waitingObjectName).html("");
				$('Field',data).each(function(i)
				{
					var name = $(this).attr("name");
					var value = $(this).text();
					if(($('#' + name).is('input')) || ($('#' + name).is('textarea')) || ($('#' + name).is('select')) || ($('#' + name).is('input')))
					{
						$('#' + name).val(value.toString());
					}
					else
					{
						$('#' + name).html(value);
						$('#' + name + "_View").html(value);
						
					}
				});
				
				//Remove the waiting Idicator
				//$("#PageMessage").html("");
				 
				//alert(data.PageMessage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
	}
	return continueAfterError;
}

/********************************************************************************************************************************
* Function Name: ajaxActionItemAll
* Description: delete item base on checkbox
********************************************************************************************************************************/
function ajaxActionItemAll(formName,  buttonName, controlName, action, confirmMessage, notSelectMessage, waitingMessage, websiteUrl)
{
	var continueAfterError = false;
	var count = 0;
	$("input[name='id[]']").each(function() 
	{
		if($(this).attr("checked"))
		{
			count++;
		}
	});
	confirmMessage = confirmMessage.replace("{count}", count);
	if(count > 0)
	{
		if(confirm(confirmMessage))	
		{
			var form = $('#' + formName);
			var actionUrl = form.attr("action");
			actionUrl = actionUrl + "&action=" + action;
			if(actionUrl.indexOf("?") >= 0)
			{
				actionUrl = actionUrl + "&from=ajax";
			}
			else
			{
				actionUrl = actionUrl + "?from=ajax";
			}
			actionUrl = actionUrl + "&confirm=yes";
			var postData = form.serialize();
			postData = postData + "&" + buttonName + "=submit"
			var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
			$("#PageMessage").html(waitingIdicator);
			$.ajax(
			{
				type: "POST",
				url: actionUrl,
				timeout: 50000,
				beforeSend: function(x) 
				{
					var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
					$("#PageMessage").html(waitingIdicator);
				},
				data: postData,
				dataType: "html",
				success: function(data)
				{
					//Remove the waiting Idicator
					$("#PageMessage").html("");
					$("#l_content").html(data);
					loadPage();
					//alert(data.PageMessage);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
			});
		}
	}
	else
	{
		alert(notSelectMessage);
	}
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: changeAction
* Description: change action
********************************************************************************************************************************/
function changeAction(target, formName,  arrConfirmMessage, arrNotSelectMessage, arrWaitingMessage, websiteUrl)
{
	var continueAfterError = false;
	var count = 0;
	$("input[name='id[]']").each(function() 
	{
		if($(this).attr("checked"))
		{
			count++;
		}
	});
	var selectedIndex = target.selectedIndex;
	confirmMessage = arrConfirmMessage[selectedIndex];
	notSelectMessage = arrNotSelectMessage[selectedIndex];
	waitingMessage = arrNotSelectMessage[arrWaitingMessage];
	
	confirmMessage = confirmMessage.replace("{count}", count);
	var buttonName = "btn" + target.value;
	var action = target.value.toLowerCase();
	if(count > 0)
	{
		var bIsConfirm = true;
		if(confirmMessage != "")
		{
			bIsConfirm = confirm(confirmMessage);
		}
		if(bIsConfirm)	
		{
			switch(action)
			{
				case "":
					$("input[name='id[]']").each(function() 
					{
						if($(this).attr("checked"))
						{
							toggleObject('quickEdit_' + $(this).attr("value"), false, "", " table tfoot");
						}
					});
					$('#btnSaveAll').hide();
					 
					break;
				case "quickedit":
					$("input[name='id[]']").each(function() 
					{
						if($(this).attr("checked"))
						{
							toggleObject('quickEdit_' + $(this).attr("value"), true, " table tfoot");
						}
					});
					 $('#btnSaveAll').show();
					break;
				default:
						var form = $('#' + formName);
						var actionUrl = form.attr("action");
						actionUrl = actionUrl + "&action=" + action;
						if(actionUrl.indexOf("?") >= 0)
						{
							actionUrl = actionUrl + "&from=ajax";
						}
						else
						{
							actionUrl = actionUrl + "?from=ajax";
						}
						actionUrl = actionUrl + "&confirm=yes";
						var postData = form.serialize();
						postData = postData + "&" + buttonName + "=submit"
						var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
						$("#PageMessage").html(waitingIdicator);
						$.ajax(
						{
							type: "POST",
							url: actionUrl,
							timeout: 50000,
							beforeSend: function(x) 
							{
								var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
								$("#PageMessage").html(waitingIdicator);
							},
							data: postData,
							dataType: "html",
							success: function(data)
							{
								//Remove the waiting Idicator
								$("#PageMessage").html("");
								$("#l_content").html(data);
								loadPage();
								//alert(data.PageMessage);
							},
							error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
						});
					break;
			}

		}
		
	}
	else
	{
		alert(notSelectMessage);
	}
	target.selectedIndex = 0;
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: ajaxSubmit
* Description: perform submit form using ajax & display html
********************************************************************************************************************************/
function ajaxSubmit(formName,  buttonName, controlName, validationGroup, waitingMessage, completeMessage, websiteUrl, urlparams)
{
	var continueAfterError = false;
	var validate = true;
	if(validationGroup != '')
	{
		validate = validateForm(validationGroup);
	}
	if(validate)
	{
		var form = $('#' + formName);
		var actionUrl = form.attr("action");
		if(actionUrl.indexOf("?") >= 0)
		{
			actionUrl = actionUrl + "&from=ajax";
		}
		else
		{
			actionUrl = actionUrl + "?from=ajax";
		}
		
		actionUrl = addToUrl(actionUrl, urlparams);
		var postData = form.serialize();
		postData = postData + "&" + buttonName + "=submit"
		
		$.ajax(
		{
			type: "POST",
			url: actionUrl,
			timeout: 50000,
			beforeSend: function(x) 
			{
				var waitingIdicator = "<img src=\"" + websiteUrl + "includes/images/ajax-loader.gif\" align=\"left\" hspace=\"6\" />" + waitingMessage;
				$("#PageMessage").html(waitingIdicator);
			},
			data: postData,
			dataType: "html",
			success: function(data)
			{
				//Remove the waiting Idicator
				$("#PageMessage").html("<div class=\"messagebox\">" + completeMessage + "</div>");
				$("#l_content").html(data);
				loadPage();
				//alert(data.PageMessage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){continueAfterError = displayError(XMLHttpRequest, textStatus, errorThrown);} 
		});
	}
	return continueAfterError;
}
/********************************************************************************************************************************
* Function Name: displayError
* Description: handle ajax error
********************************************************************************************************************************/
function displayError(XMLHttpRequest, textStatus, errorThrown) 
{
	try 
	{
		alert(XMLHttpRequest + "-----" + errorThrown);
		if (textStatus == "timeout") 
		{
		}
		else
		{
			
		}
	}
	catch (e) 
	{
	}
	//return confirm("Có lỗi khi thực thi AJAX. Bạn click nút OK để tiếp tục. Error:" + textStatus);
} 
/*
	End of AJAX functions
*/
/********************************************************************************************************************************
* Function Name: redirect
* Description: redirect to an strUrl
********************************************************************************************************************************/

function redirect(strUrl, urlparams)
{
	strUrl = addToUrl(strUrl, urlparams);
	window.location.href = 	strUrl;
	return false;
}
/********************************************************************************************************************************
* Function Name: addToUrl
* Description: add to strUrl with the values from urlparams
********************************************************************************************************************************/


function addToUrl(strUrl, urlparams)
{
	//prepare for url
	if(urlparams != null)
	{
		$.each(urlparams, function(queryKey, queryObjectName) 
		{
			if(queryObjectName.indexOf("|") >= 0)
			{
				var arrQueryObjectName = queryObjectName.split("|");
				for(var i = 0; i < arrQueryObjectName.length;i++)
				{
					if(document.getElementById(arrQueryObjectName[i]) != null)
					{
						var queryValue = $("#" + arrQueryObjectName[i]).val();
						strUrl = strUrl + "&" + queryKey + "=" + queryValue;
						break;
					}
				}
			}
			else
			{
				var queryValue = $("#" + queryObjectName).val();
				strUrl = strUrl + "&" + queryKey + "=" + queryValue;
			}
		});
	}
	return strUrl;
}
/********************************************************************************************************************************
* Function Name: gotoNexField
* Description: go to next field when the current field is enough length
********************************************************************************************************************************/
function gotoNexField(target, nextFieldName, maxlength)
{
	var str = target.value;
	str = jQuery.trim(str);
	if(str.length >= maxlength)
	{
		document.getElementById(nextFieldName).focus();
	}
}
/********************************************************************************************************************************
* Function Name: emptyObject
* Description: empty object content
********************************************************************************************************************************/

function emptyObject(objectName)
{
	$("#" + objectName).html("");;
}
/********************************************************************************************************************************
* Function Name: open Window
* Description: open new window
********************************************************************************************************************************/

function openNewWindow(strUrl, iWidth, iHeight, windowTitle)
{
	var width=iWidth-10;
	var height=iHeight-10;
	if((windowTitle == null) || (windowTitle == ""))
	{
		windowTitle = "LF";
	}
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	
	if(iHeight<screen.height)
	{
		window.open(strUrl,windowTitle,'top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
	else
	{
		window.open(strUrl,windowTitle,'top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
}




/********************************************************************************************************************************
* Function Name: openDivWindow
* Description: display div window 
********************************************************************************************************************************/
function openDivWindow(strUrl, title, width, height)
{
	//Remove the currentWindow
	var continueAfterError = false;
	$("#divWindow").show().remove();
	var actionUrl = strUrl;
	if(actionUrl.indexOf("?") >= 0)
	{
		actionUrl = actionUrl + "&from=ajax";
	}
	else
	{
		actionUrl = actionUrl + "?from=ajax";
	}
	if(width == null)
	{
		width = 400;
	}
	if(height == null)
	{
		width = 550;
	}
	$.ajax(
	{
		type: "GET",
		url: actionUrl,
		timeout: 50000,
		beforeSend: function(x) 
		{


		},
		dataType: "html",
		success: function(data)
		{
			//Remove the waiting Idicator
			 
			var divWindow = buildWindowBox(title, data, width, height);
			$("body").prepend(divWindow);
			//Position window
			
			var topPos = ($(window).height() - $("#divWindow").height() )/2 + $(window).scrollTop();
    		var leftPos = ($(window).width() - $("#divWindow").width() )/2 + $(window).scrollLeft();
			
			$("#divWindow").css("position","absolute");
			$("#divWindow").css("left",leftPos + "px");
			if(topPos <= 0)
			{
				topPos = 10;
			}
			//End of Position window
			$("#divWindow").show();
			
			$("#divWindow").animate({top:"+=" + topPos + "px"}, 1000);
			$("#divWindow").draggable();
			//alert(data.PageMessage);
		} 
	});
	return continueAfterError;
}
/********************************************************************************************************************************
* 
********************************************************************************************************************************/
function buildWindowBox(title, content, width, height)
{
	var str = "";
	//str = str + "<div id=\"divWindow\" style=\"display:none;position:absolute; z-index:100; border: 1px solid blue;top:0px; width:" + width + "px;  height:" + height + "px; \">" + "\r\n";
	
	str = str + "<div id=\"divWindow\" style=\"display:none;position:absolute; z-index:100; width:" + width + "px;\" class=\"window_box\">" + "\r\n";
	str = str + "  <div class=\"top_left\">" + "\r\n";
	str = str + "    <div class=\"box_title\">" + title + "</div>" + "\r\n";
	str = str + "    <div class=\"box_close\"><a href=\"javascript:;\" onclick=\"closeDivWindow();\">[X]</a></div>" + "\r\n";
	str = str + "  	<div class=\"clr\"></div>" + "\r\n";
	str = str + "  </div>" + "\r\n";
	str = str + "  <div class=\"top_right\"></div>" + "\r\n";
	str = str + "  <div class=\"box_content\">" + "\r\n";
	str = str + "  		" + content + "" + "\r\n";
	str = str + "  		<div class=\"clr\"></div>" + "\r\n";
	str = str + "  </div>" + "\r\n";
	str = str + "  <div class=\"bottom_left\"></div>" + "\r\n";
	str = str + "  <div class=\"bottom_right\"></div>" + "\r\n";
	str = str + "</div>" + "\r\n";

 
	return str;
}


/********************************************************************************************************************************
* Function Name: closedivWindow
* Description: close the current chat window 
********************************************************************************************************************************/
function closeDivWindow()
{
		$("#divWindow").animate({top:"0px"}, 1000);
		$("#divWindow").hide(500, function()
			{
				$("#divWindow").show().remove();
			}
		);
		

}
/********************************************************************************************************************************
* Function Name: closedivWindow
* Description: close the current chat window 
********************************************************************************************************************************/
function doSearch(strUrl, fieldName)
{
	var fieldValue = document.getElementById(fieldName).value;
	strUrl = strUrl + "&" + fieldName + "=" + escape(fieldValue);
	window.location.href=strUrl;
	return false;
}

/********************************************************************************************************************************
* Function Name: formatNumber
* Description: format the number using US formated
********************************************************************************************************************************/
function formatNumber(num)
{
	if(!isNaN(num))
	{
		//Round the number
		num = Math.round(num*100)/100;
		var strReturnValue = formatNumberFull(num,2,true,false,true);
		var iStart = strReturnValue.indexOf(".");
		var strTempDecimal = strReturnValue.substring(iStart,strReturnValue.length);
		if(strTempDecimal.length == 2)
		{
		    strReturnValue = strReturnValue + "0";
		}
		return strReturnValue;
	}
	else
	{
		return "";
	}
}
/********************************************************************************************************************************
* Function Name: view More
* Description: view more click on menu
********************************************************************************************************************************/
function viewMore(menuID, viewMoreID, viewMoreText, viewLessText)
{
	$("#" + menuID + " " + ".menu_hide").toggle(300);
	if($( "#" + viewMoreID).text() == viewLessText)
	{
		$( "#" + viewMoreID).text(viewMoreText);
	}
	else
	{
		$( "#" + viewMoreID).text(viewLessText);
	}
}
/********************************************************************************************************************************
* Function Name: changeProductAttributeDetail
* Description: change product attribute detail on combobox text
********************************************************************************************************************************/
function changeProductAttributeDetail(comboboxName, textBoxControlName)
{
 
	var ProductAttributeDetailID = document.getElementById(comboboxName).value;
	if(ProductAttributeDetailID == "-2")
	{
		document.getElementById(textBoxControlName).style.display = "";
	}
	else
	{
		document.getElementById(textBoxControlName).style.display = "none";
	}
}

/********************************************************************************************************************************
* Function Name: formatNumberFull
* Description: core format number function
********************************************************************************************************************************/

function formatNumberFull(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
    if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	 
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
   
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}
/********************************************************************************************************************************
* Function Name: toggleValue
********************************************************************************************************************************/
function toggleValue(value, replaceValue)
{
	var strReturnValue = replaceValue;
	if((value != null) && (value != ""))
	{
		strReturnValue = value;
	}
	return strReturnValue;
}
/********************************************************************************************************************************
* Function Name: displayControl
********************************************************************************************************************************/
function displayControl(target, displayControlName, displayValue)
{
	if(target.value == displayValue)
	{
		$("#" + displayControlName).show();
	}
	else
	{
		$("#" + displayControlName).hide();
	}
}
/********************************************************************************************************************************
* Function Name: toggleValue
********************************************************************************************************************************/

function getFileExtension(filename)
{
    var found = filename.lastIndexOf('.') + 1;
    return (found > 0 ? filename.substr(found) : "");
}

/********************************************************************************************************************************
* Function Name: toggleValue
********************************************************************************************************************************/
function buildComboBox(comboName, comboValue, data, attribute)
{
	var strReturnValue = "";
	strReturnValue = strReturnValue + "            <select name=\"" + comboName + "\" id=\"" + comboName + "\" " + attribute + ">" + "\r\n";
	
	
		
	$.each(data, function(entryIndex, entry) 
	{
		var selected = "";
		//alert(comboValue + "----" + entryIndex);
		if($.trim(comboValue.toLowerCase()) == $.trim(entryIndex.toLowerCase()))
		{
			selected = "selected=\"selected\"";
		}
		strReturnValue = strReturnValue + "                <option " + selected + " value=\"" + entryIndex + "\">" + entry + "</option>" + "\r\n";
	});
	strReturnValue = strReturnValue + "              </select>" + "\r\n";

	return strReturnValue;
}
/********************************************************************************************************************************
* Function Name: toggleValue
********************************************************************************************************************************/
function doSearch(controlName, strUrl)
{
	var Keywords = document.getElementById(controlName).value;
	if(strUrl.indexOf("?") >= 0)
	{
		strUrl = strUrl + "&keywords=" + Keywords;
	}
	else
	{
		strUrl = strUrl + "?keywords=" + Keywords;
	}
	window.location.href = strUrl;
}

