function ShowPicture(urlImage, iWidth, iHeight)
{
	var url = "view_image.aspx?img=" + urlImage;
	var width=iWidth-10;
	var height=iHeight-10;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	if(iHeight<screen.height)
	{
		window.open(url,'ShowPicture','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(url,'ShowPicture','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function showTable(strArrTable,tableName)
	{
		
		var arrTable = strArrTable.split("|");
		for(i = 0; i < arrTable.length;i++)
		{
			document.getElementById(arrTable[i]).style.display="none";
		}
		document.getElementById(tableName).style.display="";
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changePayTypeView(hideControl,displayControl)
{
	var arrControl = getElementsByTagNames('span');
	for (i = 0; i < arrControl.length; i++)
	{	
		e = arrControl[i];
		if (e.id == hideControl)
		{
			e.style.display="none";
		}
		if (e.id == displayControl)
		{
			e.style.display="";
		}
	}
	/*
	if(document.getElementById(hideControl) != null)
	{
		document.getElementById(hideControl).style.display="none";
	}
	if(document.getElementById(displayControl) != null)
	{
		document.getElementById(displayControl).style.display="";
	}
	*/
}
function getElementsByTagNames(list,obj)
{
	if (!obj) var obj = document;
	var tagNames = list.split(',');
	var resultArray = new Array();
	for (var i=0;i<tagNames.length;i++)
	{
		var tags = obj.getElementsByTagName(tagNames[i]);
		for (var j=0;j<tags.length;j++)
		{
			resultArray.push(tags[j]);
		}
	}
	var testNode = resultArray[0];
	if (testNode.sourceIndex)
	{
		resultArray.sort(function (a,b) {
				return a.sourceIndex - b.sourceIndex;
		});
	}
	else if (testNode.compareDocumentPosition)
	{
		resultArray.sort(function (a,b) {
				return 3 - (a.compareDocumentPosition(b) & 6);
		});
	}
	return resultArray;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeHiddenID(ID)
{
	document.getElementById("hHiddenID").value = ID;
	return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function priceRangeCompare(strUrl, MenuID)
{
	var PriceFrom = document.getElementById("txtPriceFrom" + "_" + MenuID + "").value;
	var CurrencyFrom = document.getElementById("cbCurrencyFrom" + "_" + MenuID + "").value;
	var PriceTo = document.getElementById("txtPriceTo" + "_" + MenuID + "").value;
	var CurrencyTo = document.getElementById("cbCurrencyTo" + "_" + MenuID + "").value;
	strUrl = strUrl + "&pricefrom=" + PriceFrom;
	strUrl = strUrl + "&currencyfrom=" + CurrencyFrom;
	strUrl = strUrl + "&priceto=" + PriceTo;
	strUrl = strUrl + "&currencyto=" + CurrencyTo;
	window.location.href=strUrl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function productAttributeFilter(strUrl, MenuID,ListProductAttributeDetailID,AppendUrl)
{
	
	var count = 0;
	var strAlert = "";
	var strQueryListProductAttributeID = "";
	var arrListProductAttributeDetailID = ListProductAttributeDetailID.split("|");
	for (i = 0; i < arrListProductAttributeDetailID.length; i++)
	{	
		if(arrListProductAttributeDetailID[i] != "")
		{
			var e = document.getElementById("ckProductAttribute_" + MenuID + "_" + arrListProductAttributeDetailID[i]);
			if (e.checked == true)
			{
				strQueryListProductAttributeID = strQueryListProductAttributeID + "&padid=" + e.value;
				count++;
			}
		}
	}
	if (count > 0)
	{
	}
	else
	{
		alert("You must select at least one  attribute to filter!");
		return false;
	}
	strUrl = strUrl + strQueryListProductAttributeID;
	strUrl = strUrl + AppendUrl;
	window.location.href=strUrl;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function productAttributeFilterEx(strUrl, MenuID,ListProductAttributeDetailID,ListPriceRangeID)
{
	
	var count = 0;
	var strAlert = "";
	var strQueryListProductAttributeID = "";
	var arrListProductAttributeDetailID = ListProductAttributeDetailID.split("|");
	for (i = 0; i < arrListProductAttributeDetailID.length; i++)
	{	
		if(arrListProductAttributeDetailID[i] != "")
		{
			var e = document.getElementById("ckProductAttribute_" + MenuID + "_" + arrListProductAttributeDetailID[i]);
			if (e.checked == true)
			{
				strQueryListProductAttributeID = strQueryListProductAttributeID + "&padid=" + e.value;
				count++;
			}
		}
	}
	
	strUrl = strUrl + strQueryListProductAttributeID;
	//Append for price range
	
	var arrListPriceRangeID = ListPriceRangeID.split("|");
	//alert(strUrl);
	for (i = 0; i < arrListPriceRangeID.length; i++)
	{	
		if(arrListPriceRangeID[i] != "")
		{
			var e = document.getElementById("ckPriceRange_" + MenuID + "_" + arrListPriceRangeID[i]);
			if (e.checked == true)
			{
				strUrl = strUrl + e.value;
				count++;
			}
		}
	}
	
	if (count > 0)
	{
	}
	else
	{
		alert("You must select at least one condition to filter!");
		return false;
	}
	window.location.href=strUrl;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function priceRangeFilter(strUrl, MenuID,ListPriceRangeID,AppendUrl)
{
	
	var count = 0;
	var strAlert = "";
	var strQueryListPriceRangeID = "";
	var arrListPriceRangeID = ListPriceRangeID.split("|");
	//alert(strUrl);
	for (i = 0; i < arrListPriceRangeID.length; i++)
	{	
		if(arrListPriceRangeID[i] != "")
		{
			var e = document.getElementById("ckPriceRange_" + MenuID + "_" + arrListPriceRangeID[i]);
			if (e.checked == true)
			{
				strUrl = strUrl + e.value;
				count++;
			}
		}
	}
	if (count > 0)
	{
	}
	else
	{
		alert("You must select at least one  to filter!");
		return false;
	}
	strUrl = strUrl + AppendUrl;
	//alert(strUrl);
	window.location.href=strUrl;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeComboBoxUrl(target)
{
	var strUrl = target.value
	window.location.href=strUrl;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function changeComboBox(target, queryKey, queryValue, strUrl)
{
	if(strUrl.indexOf("&" + queryKey + "=") > 0)
	{
		strUrl = strUrl.replace("&" + queryKey + "=" + queryValue, "&" + queryKey + "=" + target.value);
	}
	else
	{
		strUrl = strUrl + "&" + queryKey + "=" + target.value
	}
	window.location.href=strUrl;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeComboAppend(target, queryKey, queryValue, strUrl)
{
	//
	strUrl = strUrl + "&" + queryKey + "=" + target.value
	window.location.href=strUrl;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function voteMe(ControlName, Type, SourceID, strReturnUrl)
{
	var VoteValue = document.getElementById(ControlName).value;
	var strUrl = GetWebsiteUrl() + "default.aspx?module=misc&content=vote&value=" + VoteValue + "&type=" + Type + "&sid=" + SourceID + "&returnUrl=" + strReturnUrl + "";
	window.location.href=strUrl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doSimpleSearch(SimpleSearchComboID, SimpleSearchTextID)
{
	//
	//queryKey queryValue, 
	var SearchType = document.getElementById(SimpleSearchComboID).value.toLowerCase();
	var Keyword = document.getElementById(SimpleSearchTextID).value.toLowerCase();
	var strUrl = "";
	switch(SearchType)
	{
		case "album":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=show_album&action=searchresult&keyword=" + Keyword + "";
			break;
		case "music":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=list_media&filetype=mu&action=searchresult&keyword=" + Keyword + "";
			break;
		case "movie":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=list_media&filetype=mo&action=searchresult&keyword=" + Keyword + "";
			break;
		case "file":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=list_media&filetype=fi&action=searchresult&keyword=" + Keyword + "";
			break;
		case "diary":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=show_diary&action=searchresult&keyword=" + Keyword + "";
			break;
		case "product":
			strUrl = GetWebsiteUrl() + "default.aspx?module=product&content=list_product&action=searchresult&keyword=" + Keyword;
			break;
		case "news":
			strUrl = GetWebsiteUrl() + "default.aspx?module=news&content=list_news&action=searchresult&keyword=" + Keyword;
			break;
		case "product_news":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=search_result&action=searchresult&searchtype=product_news&keyword=" + Keyword + "";
			break;
		default:
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=search_result&action=searchresult&keyword=" + Keyword + "";
			break;
	}
	window.location.href=strUrl;
	return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doProductSearch(SimpleSearchTextID,ProvinceComboID,DistrictComboID)
{
	//
	//queryKey queryValue, 
	var Keyword = document.getElementById(SimpleSearchTextID).value.toLowerCase();
	var Province = document.getElementById(ProvinceComboID).value.toLowerCase();
	var District = document.getElementById(DistrictComboID).value.toLowerCase();
	var strUrl = "";
	strUrl = GetWebsiteUrl() + "default.aspx?module=product&content=list_product&action=searchresult&province=" + Province + "&district=" + District + "&keyword=" + Keyword;

	window.location.href=strUrl;
	return false;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
function doSearchProduct()
{
	
		var UserControlPrefix = document.getElementById("hUserControlPrefix").value
		var PriceFrom = document.getElementById(UserControlPrefix + "_" + "PriceFrom").value.toLowerCase();
		var PriceTo = document.getElementById(UserControlPrefix + "_" + "PriceTo").value.toLowerCase();
		var cbCurrencyFrom = document.getElementById(UserControlPrefix + "_" + "cbCurrencyFrom").value.toLowerCase();
		var cbCurrencyTo = document.getElementById(UserControlPrefix + "_" + "cbCurrencyTo").value.toLowerCase();
		var CategoryID = document.getElementById("cbCategory").value.toLowerCase();
		var cbCurrencyTo = document.getElementById("cbCategory").value.toLowerCase();
					
}
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doAdvanceSearch(SimpleSearchComboID, AdvanceSearchKeyword,AdvanceSearchDateFrom,AdvanceSearchDateTo,AdvanceSearchViewCountFrom,AdvanceSearchViewCountTo)
{
	//
	//queryKey queryValue, 
	var UserControlPrefix = document.getElementById("hUserControlPrefix").value
	var SearchType = document.getElementById(UserControlPrefix + "_" + SimpleSearchComboID).value.toLowerCase();
	var AdvanceSearchKeyword = document.getElementById(AdvanceSearchKeyword).value.toLowerCase();
	var AdvanceSearchDateFrom = document.getElementById(AdvanceSearchDateFrom).value.toLowerCase();
	var AdvanceSearchDateTo = document.getElementById(AdvanceSearchDateTo).value.toLowerCase();
	var AdvanceSearchViewCountFrom = document.getElementById(AdvanceSearchViewCountFrom).value.toLowerCase();
	var AdvanceSearchViewCountTo = document.getElementById(AdvanceSearchViewCountTo).value.toLowerCase();
	var Param = "&keyword=" + AdvanceSearchKeyword + "&datefrom=" + AdvanceSearchDateFrom + "&dateto=" + AdvanceSearchDateTo + "&viewcountfrom=" + AdvanceSearchViewCountFrom + "&viewcountto=" + AdvanceSearchViewCountTo;
	var strUrl = "";
	
	switch(SearchType)
	{
		case "album":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=show_album&action=searchresult" + Param;
			break;
		case "music":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=list_media&filetype=mu&action=searchresult" + Param;
			break;
		case "movie":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=list_media&filetype=mo&action=searchresult" + Param;
			break;
		case "file":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=list_media&filetype=fi&action=searchresult" + Param;
			break;
		case "diary":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=show_diary&action=searchresult&keyword=" + Param;
			break;
		case "product":
			strUrl = GetWebsiteUrl() + "default.aspx?module=product&content=list_product&action=searchresult&keyword=" + Param;
			break;
		case "news":
			strUrl = GetWebsiteUrl() + "default.aspx?module=news&content=list_news&action=searchresult&keyword=" + Param;
			break;
		case "product_news":
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=search_result&action=searchresult&searchtype=product_news&keyword=" + Keyword + "";
			break;
		default:
			strUrl = GetWebsiteUrl() + "default.aspx?module=blogger&content=search_result&action=searchresult&keyword=" + Keyword + "";
			break;
	}
	
	window.location.href=strUrl;
	return false;
}

/////////////////////////////////////////////////////////////////////////////////////
			//
			/////////////////////////////////////////////////////////////////////////////////////
			function addMore()
			{
				if(document.frmForm.hTable.value == "")
				{
					document.frmForm.hTable.value = document.getElementById("tdTable").innerHTML;
				}
				var strTable = document.getElementById("tdTable").innerHTML;
				strTable = strTable + document.frmForm.hTable.value;
				document.getElementById("tdTable").innerHTML = strTable;
				
			}
			/////////////////////////////////////////////////////////////////////////////////////
			//
			/////////////////////////////////////////////////////////////////////////////////////
			function remove()
			{
				var strTable = document.getElementById("tdTable").innerHTML;
				var arrTable = strTable.split("<!--BEGIN-->");
				var strNewTable = "";
				if(arrTable.length > 1)
				{
					for(i = 0; i < (arrTable.length -1); i++)
					{
						strNewTable = strNewTable + "<!--BEGIN-->" + arrTable[i];
					}
					document.getElementById("tdTable").innerHTML = strNewTable;
				}
				else
				{
					alert("Can not remove");
				}
			}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function enableControl(target)
{
	target.readOnly = false;
	target.className = "exceltextboxdl";
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function disableControl(target)
{
	target.readOnly = true;
	target.className = "exceltextbox";
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function OpenWindow(urlImage, iWidth, iHeight)
{
	var url = urlImage;
	var width=iWidth-10;
	var height=iHeight-10;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	if(iHeight<screen.height)
	{
		window.open(url,'izday','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(url,'izday','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function IZOpenWindow(urlImage, iWidth, iHeight, Title)
{
	var url = urlImage;
	var width=iWidth-10;
	var height=iHeight-10;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	if(iHeight<screen.height)
	{
		window.open(url,Title,'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(url,Title,'top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doSearchAll()
{
	var keyword= document.getElementById("keyword").value;
	var cbCategory= document.getElementById("cbCategory").value;
	window.location.href="search.aspx?action=searchresult&keyword=" + keyword + "&cbCategory=" + cbCategory;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openPollWindow(PollID)
{
	var answer = "";
	var frmForm = document.PollForm;
	for (i = 0; i < frmForm.elements.length; i++)
	{	
		e = frmForm.elements[i];
		if (e.name == "Poll_" + PollID && e.checked == true)
		{
			answer = answer + "&answer=" +  e.value;
		}
	}
	//alert(answer);
	pollWindow = window.open('default.aspx?module=module&content=poll_result&displaytype=disableallgui&pid=' + PollID + answer,'AQContextHelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=300').focus();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addMailingList()
{
	var Email= document.getElementById("MailingList").value;
	var strAlert = "";
	strAlert = strAlert + VKCheckRequireField(document.getElementById("MailingList"),"Please enter your email!\n");
	strAlert = strAlert + VKCheckEmail(document.getElementById("MailingList"),"Your email is not valid. Please re-enter!\n");
	if(strAlert != "")
	{
		alert(strAlert);
	}
	else
	{
		window.location.href="add_mailinglist.aspx?action=add&email=" + Email;
	}
	return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function viewPollWindow(PollID)
{
	var answer = "";
	pollWindow = window.open('default.aspx?module=module&content=poll_result&displaytype=disableallgui&pid=' + PollID + answer,'AQContextHelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=300').focus();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openEditor(formName, ImageFolder, strUrl)
{
	
	strUrl = strUrl + "?form=" + formName + "&folder=" + ImageFolder;
	var width=680;
	var height=400;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	window.open(strUrl,'OnlineEditor','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();

}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Get Website Url
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function GetWebsiteUrl()
{
	var strReturnValue = "";
	var strUrl = window.location.href.toLowerCase();
	strUrl = strUrl.replace("http://","");
	var iLastIndex = strUrl.lastIndexOf("/");
	//Prevent for infinite loop
	var iLoopIndex = 0; 
	while((iLastIndex > 0) && (iLoopIndex < 20))
	{
		strUrl = strUrl.substring(0,iLastIndex);
		iLastIndex = strUrl.lastIndexOf("/");
		iLoopIndex++;
	}
	strUrl = "http://" + strUrl + "/";
	return strUrl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function checkMemberLogin(target, strUrl)
{
	var objUsername = document.getElementById('txtLoginUserName');
	var objPassword = document.getElementById('txtLoginPassword');
	var strAlert = "";
	strAlert = strAlert + VKCheckRequireField(objUsername, "Please enter your username!\n");
	strAlert = strAlert + VKCheckRequireField(objPassword, "Please enter your password!\n");
	if(strAlert != "")
	{
		alert(strAlert);
		return false;
	}
	else
	{
		target.action = strUrl;
		target.method = "post";
		return true;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function compareProduct(returnUrl, CategoryID)
	{
		var count = 0;
		var strAlert = "";
		var strUrl = GetWebsiteUrl() + "default.aspx?module=product&content=compare_product&";
		
		
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if (e.name == "ckSelect" && e.checked == true)
			{
				strUrl = strUrl + "pid=" + e.value + "&";
				count++;
			}
		}
		
		if(parseInt(CategoryID,10) != 0)
		{
			strUrl = strUrl + "cid=" + CategoryID + "&";
		}
		strUrl = strUrl + "returnUrl=" + returnUrl + "";
		if (count > 1)
			if(strAlert != "")
			{
				alert(strAlert);
				return false;
			}
			else
			{
				document.frmForm.action = strUrl;
				//document.frmForm.submit();
				//window.location.href=strUrl;
				return true;
			}
		else
		{
			alert("You must select at least 2 product to compare!");
			return false;
		}
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function actionMe(action, actionWho)
	{
		var count = 0;
		var strAlert = "";
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if (e.name == "ckSelect" && e.checked == true)
			{
				count++;
			}
		}
		if (count > 0)
			if(strAlert != "")
			{
				alert(strAlert);
				return false;
			}
			else
			{
				return confirm("You are about to " + action + " " + count + " selected  " + actionWho + "(s). Do you wish to continue?")
			}
		else
		{
			alert("You must select at least one  " + actionWho + " to " + action + "!");
			return false;
		}
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function actionMeEx(action, actionWho, appendMessage)
	{
		var count = 0;
		var strAlert = "";
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if (e.name == "ckSelect" && e.checked == true)
			{
				count++;
			}
		}
		if (count > 0)
			if(strAlert != "")
			{
				alert(strAlert);
				return false;
			}
			else
			{
				return confirm("You are about to " + action + " " + count + " selected  " + actionWho + "(s).\n" + appendMessage +".\n Do you wish to continue?")
			}
		else
		{
			alert("You must select at least one  " + actionWho + " to " + action + "!");
			return false;
		}
	}	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	function sortMe(strUrl, Sort, strQueryString, target)
	{
		if(strUrl.indexOf("sort=") > 0)
		{
			strUrl = strUrl.replace("sort=" + Sort,"sort=" + target.value);
		}
		else
		{
			if(strQueryString == "")
			{
				strUrl = strUrl + "?" + "sort=" + target.value;
			}
			else
			{
				strUrl = strUrl + "&" + "sort=" + target.value;
			}
		}
		window.location.href=strUrl;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	function sortbyMe(strUrl, SortBy, strQueryString, target)
	{
		if(strUrl.indexOf("sortby=") > 0)
		{
			strUrl = strUrl.replace("sortby=" + SortBy,"sortby=" + target.value);
		}
		else
		{
			if(strQueryString == "")
			{
				strUrl = strUrl + "?" + "sortby=" + target.value;
			}
			else
			{
				strUrl = strUrl + "&" + "sortby=" + target.value;
			}
		}
		window.location.href=strUrl;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doSearch()
{
	var objKeyword = document.getElementById('txtKeywordSearch');
	window.location.href="search.aspx?keyword=" + objKeyword.value;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check All function
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	function checkAll(coltrolName, target)
	{
		var iIndex = 1;
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if ((e.name == coltrolName) && (e.disabled == false))
			{
				e.checked = target.checked;
				/*var trRow = document.getElementById("trRow" + iIndex);
				if(target.checked)
				{
					trRow.bgColor = "#CEDAEF";
				}
				else
				{
					trRow.bgColor = "#EFEFEF";
				}
				*/
			}
			if ((e.name == coltrolName))
			{
				iIndex++;
			}
		}
	}
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function checkSelect(target, iIndex)
	{
		var trRow = document.getElementById("trRow" + iIndex);
		if(target.checked)
		{
			trRow.bgColor = "#CEDAEF";
		}
		else
		{
			trRow.bgColor = "#EFEFEF";
		}
	}
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeCountry(target,ProvinceComboboxName,ProvinceDivID,DistrictComboboxName,DistrictDivID)
		{
			var CountryCode = target.value;
			var iIndex = GetArrayIndex(arrCountryArray,CountryCode);
			var strProvinceControl = "";
			if(iIndex >= 0)
			{
				var strListProvinceCode = arrProvinceListArrayCode[iIndex]
				var strListProvinceName = arrProvinceListArrayName[iIndex]
				var arrProvinceCode = strListProvinceCode.split("|");
				var arrProvinceName = strListProvinceName.split("|");
				if(arrProvinceCode.length > 0)
				{
					strProvinceControl = strProvinceControl + "<select  class=\"TEXTBOX\" id=\"" + ProvinceComboboxName + "\" name=\"" + ProvinceComboboxName + "\" onchange=\"changeProvince(this,'" + DistrictComboboxName + "','" + DistrictDivID + "')\">";
					for(i = 0; i < arrProvinceCode.length;i++)
					{
						strProvinceControl = strProvinceControl + "<option value=\"" + arrProvinceCode[i] + "\">" + arrProvinceName[i] + "</option>";
					}
					strProvinceControl = strProvinceControl + "</select>";
				}
			}
			else
			{
				strProvinceControl = strProvinceControl + "<select  class=\"TEXTBOX\" id=\"" + ProvinceComboboxName + "\" name=\"" + ProvinceComboboxName + "\">";
				strProvinceControl = strProvinceControl + "<option value=\"\">---</option>";
				strProvinceControl = strProvinceControl + "</select>";
				document.getElementById(DistrictDivID).innerHTML = strProvinceControl;
			}
			document.getElementById(ProvinceDivID).innerHTML = strProvinceControl;
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		function changeProvince(target,DistrictComboboxName,DistrictDivID)
		{
			var ProvinceCode = target.value;
			var iIndex = GetArrayIndex(arrProvinceArray,ProvinceCode);
			
			var strDistrictControl = "";
			if(iIndex >= 0)
			{
				var strListDistrictCode = arrDistrictListArrayCode[iIndex]
				var strListDistrictName = arrDistrictListArrayName[iIndex]
				var arrDistrictCode = strListDistrictCode.split("|");
				var arrDistrictName = strListDistrictName.split("|");
				if(arrDistrictCode.length > 0)
				{
					strDistrictControl = strDistrictControl + "<select class=\"TEXTBOX\" id=\"" + DistrictComboboxName + "\" name=\"" + DistrictComboboxName + "\" onchange=\"changeProvince(this,'" + DistrictComboboxName + "','" + DistrictDivID + "')\">";
					for(i = 0; i < arrDistrictCode.length;i++)
					{
						strDistrictControl = strDistrictControl + "<option value=\"" + arrDistrictCode[i] + "\">" + arrDistrictName[i] + "</option>";
					}
					strDistrictControl = strDistrictControl + "</select>";
				}
			}
			else
			{
				strDistrictControl = strDistrictControl + "<select class=\"TEXTBOX\" id=\"" + DistrictComboboxName + "\" name=\"" + DistrictComboboxName + "\">";
				strProvinceControl = strProvinceControl + "<option value=\"\">---</option>";
				strDistrictControl = strDistrictControl + "</select>";
			}
			document.getElementById(DistrictDivID).innerHTML = strDistrictControl;
			
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		function GetArrayIndex(arrArray,value)
		{
			var iReturnValue = -1;
			for(i = 0; i < arrArray.length;i++)
			{
				if(arrArray[i] == value)
				{
					iReturnValue = i;
				}
			}
			return iReturnValue;
		}