/* ----------------------------------------------- GENERAL FUNCTIONS ------------------------------------------------------------ */

	//----------------------------
	// check require field
	//----------------------------
	
		function checkRequire(obj){
			if(obj.value==""){
				obj.focus();
				return false;
			}
			return true;
		}
		
	//----------------------------
	// compare value of two fields
	//----------------------------
	function checkCompare(obj1,obj2){
		if(obj1.value != obj2.value){
			obj1.focus();
			return false;
		}
		return true;
	}
	
/* ----------------------------------------------- NUMBER ------------------------------------------------------------ */
	
	
	//----------------------------
	// check is number
	//----------------------------
	function checkIsNumber(obj){
		if(obj.value==""){
			obj.focus();
			return false;
		}
		else{
			if(isNaN(obj.value)==true){
				obj.focus;
				return false;
			}	
		}
		return true;
	}
		
	//----------------------------
	// check if positive number
	//----------------------------
	function checkIsPositiveNumber(obj){
		if(obj.value==""){
			obj.focus();
			return false;
		}
		else{
			if((isNaN(obj.value)==false) &&(obj.value > 0)) {
				obj.focus;
				return true;
			}
			else{return false;}
		}
		return true;
	}
	
	//----------------------------
	// check if is interger
	//----------------------------
	function isInteger(s){
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}
	
	//----------------------------
	// check if is interger
	//----------------------------
	function IsInteger2(source){
		if (!ValidateRegular(source, "\\d*")){
			source.select();
			source.focus();
			return false;
		}
		return true;
	}

	//----------------------------
	// Check if a character is a digit or not
	//----------------------------
	function isDigit(c){
		if((c=='0')||(c=='1')||(c=='2')||(c=='3')||(c=='4')||(c=='5')||(c=='6')||(c=='7')||(c=='8')||(c=='9')){
			return true;
		}else{
			return false;
		}
	}

	//----------------------------
	// return true if argvalue contains only numeric characters,
	//----------------------------
		function isNum(argvalue) {
			argvalue = argvalue.toString();
		
			if (argvalue.length == 0)
			return false;
		
			for (var n = 0; n < argvalue.length; n++)
				if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
					return false;
			return true;
		}

	//----------------------------
	// check if a string is a valid positive real
	//----------------------------
		function isPosReal(s){
			var dot;
			s = trim(s);
			dot =0;
			for(i=0;i<s.length;i++)
			if(!isDigit(s.charAt(i))){
				if(s.charAt(i)=='.'){
						dot++;
						if(i==s.length-1) return false;
						if(dot>1) return false;
					}
				else return false;	
			}
			return true;
		}
	
	//----------------------------
	// check if a string is a valid positive integer
	//----------------------------
		function isPosInt(s){
			 var n;
			 n = s.length
			 if(n==0) return false;
			 for(i=0;i<n;i++)
				if(!isDigit(s.charAt(i))) return false;
			 return true;
		}

	//----------------------------
	// if not a number, replace it with a defaultValue text
	//----------------------------
		function resetNumberTextBox(target, defaultValue){
			if(isNaN(target.value))
			{
				target.value = defaultValue;
			}
		}

		
/* ----------------------------------------------- STRING ------------------------------------------------------------ */

	//----------------------------
	// Remove all spaces at the beginning of a string
	//----------------------------
		function trimLeft(s)
		{
			var i;
			i=0;
			var n;
			n = s.length;
			while((i<n)&&(s.charAt(i)==' ')) i++;
			s = s.substring(i);
			return(s);
		} 
		
	//----------------------------
	// Remove all spaces at the end of a string
	//----------------------------
		function trimRight(s){
			var n;
			n = s.length;
			var i;
			i = s.length-1;
			while((i>=0)&&(s.charAt(i)==' ')) i--;
			s = s.substring(0,i+1);
			return(s);
		}
		
	//----------------------------
	// Remove all leading and trailing spaces in a string
	//----------------------------
		function trim(s){
			s = trimLeft(s);
			s = trimRight(s);
			return(s);
		}  

/* ----------------------------------------------- EMAIL ------------------------------------------------------------ */


	//----------------------------
	// check if is email
	//----------------------------	
		function checkIsEmail(source){
			if (!ValidateRegular(source, "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")){
				source.select();
				source.focus();
				return false;
			}
			return true;
		}
		
	//----------------------------
	// check if an email address is valid (format only)
	//----------------------------	
		function isEmail(strEmail){
			 var intlen;
			 var ctmp;
			 strEmail = trim(strEmail);
			 if(strEmail=='') return false;
			 intlen=strEmail.length;
			 if(intlen<5) return false;
			 if(strEmail.indexOf('@')==-1) return false;
			 if(strEmail.indexOf('.')==-1) return false;
			 if(intlen - strEmail.lastIndexOf('.') -1 > 5) return false; 
			 if((strEmail.indexOf("_")!=-1) && (strEmail.lastIndexOf("_") > strEmail.lastIndexOf("@"))) return false;
			 if(strEmail.lastIndexOf(".") <= strEmail.lastIndexOf("@")+1)  return false;
			 if(strEmail.indexOf("@")!=strEmail.lastIndexOf("@")) return false;
			 if(intlen -1 == strEmail.lastIndexOf('.')) return false;
			 if(strEmail.charAt(strEmail.indexOf('@')+1)=='.') return false;
			 if(strEmail.indexOf(" ")!=-1) return false;
			 if(strEmail.indexOf("..")!=-1) return false;
			 if(strEmail.indexOf(";")!=-1) return false;
			 
			 strEmail=strEmail.toLowerCase();
			 for(intcnt=0;intcnt<intlen;intcnt++)
				{
				 ctmp = strEmail.charAt(intcnt)
				 if((!isDigit(ctmp))&& ((ctmp>'z')||(ctmp<'a')) && (ctmp!='-') && (ctmp!='.') && (ctmp!='@') && (ctmp!='_')) return false;
				}
			
				return true	;
		}
		
	//----------------------------
	// check if is email by Regular expression
	//----------------------------	
		
		function ValidateEmail(source){
			if  (!ValidateRegular(source, "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
			{
				source.select();
				source.focus();
				return false;
			}
			return true;
		}
		
	//----------------------------
	// check if is email 
	//----------------------------	
		function ValidateEmail2(num,source){
		// num = 1: No Require
		// num = 2: Require
			if (num == 2)
			{
				if (source.value == "")
				{
					alert('Please enter email address');
					source.focus();
					return false;
				}
			}
		
			if  (!ValidateRegular(source, "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
			{
				alert('Format email is invalid.');
				source.select();
				source.focus();
				return false;
			}
			return true;
		}
/* ----------------------------------------------- URL ------------------------------------------------------------ */

	//----------------------------
	// check if is URL
	//----------------------------
		function checkIsURL(source){
			if (!ValidateRegular(source, "(http://)?([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")){
				source.select();
				source.focus();
				return false;
			}
			return true;
		}
	
	//----------------------------
	// check if is URL 
	//----------------------------
		function ValidateURL(source)
		{
			if (!ValidateRegular(source, "((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
			{
				source.select();
				source.focus();
				return false;
			}
			return true;
		}

	//----------------------------
	// URLEncode
	//----------------------------
		function URLEncode(str){
			var ms = "%25#23 20?3F<3C>3E{7B}7D[5B]5D|7C^5E~7E`60+2B"
			var msi = 0
			var i,c,rs,ts
			while (msi < ms.length)
			{
				c = ms.charAt(msi)
				rs = ms.substring(++msi, msi +2)
				msi += 2
				i = 0
				while (true)
				{
					i = str.indexOf(c, i)
					if (i == -1) break
					ts = str.substring(0, i)
					str = ts + "%" + rs + str.substring(++i, str.length)
				}
			}
			return str
		}
	
/* ----------------------------------------------- DATE TIME ------------------------------------------------------------ */
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

	//----------------------------
	// compare two date.
    //    start <= end    :   true
    //    start > end     :   false
	//----------------------------
		function compareDate(start,end){
			
			//check data pass
		   // if((start.length == 0) || (end.length==0) ) return false;
			
			//create two Date objects
			var s = new Date(start);
			var e = new Date(end);
			
			//get month, year, date of date objects
			var s_y = parseInt(s.getYear());
			var s_m = parseInt(s.getMonth());
			var s_d = parseInt(s.getDate());
			
			var e_y = parseInt(e.getYear());
			var e_m = parseInt(e.getMonth());
			var e_d = parseInt(e.getDate());
			
			//compare year , month and day of them
			if( s_y <= e_y){ // compare year
				if(s_y == e_y){
					if(s_m <= e_m){//compare month
						if(s_m == e_m ){
							if(s_d <= e_d){// compare date
								return true;
							}else{
								return false;
							}//end compare date
						}
						return true;
					}else{
						return false;
					}// end compare month
				}    
				return true;
			}else{
				return false
			}// end compare year
					
		}
		
	//----------------------------
	// check date by object (not value)
	//----------------------------
		function ValidateDate(objDate){	
			if (isDate(objDate.value)==false){
				return false
			}
			return true
		 }
		 
	//----------------------------
	// check if is date
	//----------------------------
		 function isDate(dtStr){
			var daysInMonth = DaysArray(12)
			var pos1=dtStr.indexOf(dtCh)
			var pos2=dtStr.indexOf(dtCh,pos1+1)
			var strMonth=dtStr.substring(0,pos1)
			var strDay=dtStr.substring(pos1+1,pos2)
			var strYear=dtStr.substring(pos2+1)
			strYr=strYear
			if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
			if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
			for (var i = 1; i <= 3; i++) {
				if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
			}
		
			month=parseInt(strMonth)
			day=parseInt(strDay)
			year=parseInt(strYr)
			if (pos1==-1 || pos2==-1){
				return false
			}
			if (strMonth.length<1 || month<1 || month>12){
				return false
			}
			if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
				return false
			}
			if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
				return false
			}
			
			if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
				return false
			}
		return true
		}

	//----------------------------
	// get number of days in February by year
	//----------------------------
		function daysInFebruary (year){
			// February has 29 days in any year evenly divisible by four,
			// EXCEPT for centurial years which are not also divisible by 400.
			return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
		}

	//----------------------------
	// get day arrays
	//----------------------------
		function DaysArray(n) {
			for (var i = 1; i <= n; i++) {
				this[i] = 31
				if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
				if (i==2) {this[i] = 29}
		   } 
		   return this
		}

/* ----------------------------------------------- PHONE & FAX ------------------------------------------------------------ */

	//----------------------------
	// validate phone
	//----------------------------
		function ValidatePhone(source){
			if (!ValidateRegular(source, "((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
			{
				source.select();
				source.focus();
				return false;
			}
			return true;
		}

	//----------------------------
	// validate phone
	//----------------------------		
		function ValidatePhone2(num,source)
		// num = 1: No Require
		// num = 2: Require
		{
			if (num == 2)
			{
				if (source.value == "")
				{
					alert('Please enter phone number!');
					source.focus();
					return false;
				}		  	
			}		
			if (!ValidateRegular(source, "((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
			{
				alert('Phone number is invalid!\n Format phone:(xxx)xxx-xxxx');
				source.select();
				source.focus();
				return false;
			}
			return true;
		}

	//----------------------------
	// validate zip numbere
	//----------------------------			
		function ValidateZipS(num,source)
		{
			// num = 1: No Require
			// num = 2: Require
			if (num == 2)
			{
				if (source.value == "")
				{			
					alert("Please enter zip code!");
					source.focus();
					return false;
				}		  	
			}
			if (!ValidateRegular(source, "\\d{5}(-\\d{4})?"))
			{	
				alert('Zip number is invalid!\n Format zip:xxxxx');
				source.select();
				source.focus();
				return false;
			}
			return true;
		}


	//----------------------------
	// validate fax numbere
	//----------------------------	
		function ValidateFaxS(num,source)
		// num = 1: No Require
		// num = 2: Require
		{
			if (num == 2)
			{
				if (source.value == "")
				{
					alert('Please enter fax number!');
					source.focus();
					return false;
				}		  	
			}		
			if (!ValidateRegular(source, "((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
			{
				alert('Fax number is invalid!\n Format Fax:(xxx)xxx-xxxx');
				source.select();
				source.focus();
				return false;
			}
			return true;
		}

/* ----------------------------------------------- REGULAR EXPRESSIONS ------------------------------------------------------------ */

function ValidateRegular(source, reg){	
	var value = source.value;
	if (value=="") return true;
	var rx = new RegExp(reg);
	var matches = rx.exec(value);
    return (matches != null && value == matches[0]);
}

/* ----------------------------------------------- FILES & FOLDERS ------------------------------------------------------------ */

	//----------------------------
	// check is image
	//----------------------------
		function isImage(str){
			str = str.toLowerCase();
			var len = str.length;
			var pos = str.indexOf(".",0);
			var ext = str.substring(pos,len);
			if ((ext==".jpg" )||(ext==".gif")||(ext==".png" )){		
				return true;
			}    	
			return false;	
		}
		
	//----------------------------
	// get file name
	//----------------------------
		function getFileName(str){
			var bpos
			var filename
			if((str=='')||(str.indexOf("\\")==-1)) return(str);
			bpos = str.lastIndexOf("\\");
			filename = str.substring(bpos+1,str.length)
			return(filename);
		}
		
		
	//----------------------------
	// get file type
	//----------------------------
		function checkFile(strValue, strFileType)
		{
			var strExtension = strValue.substr((strValue.lastIndexOf(".") + 1), strValue.length).toLowerCase();
			var arrExtension = strFileType.split(",");
			var bFound = false;
			for(var i = 0; i < arrExtension.length;i++)
			{
				if(strExtension.toLowerCase() == arrExtension[i].toLowerCase())
				{
					bFound = true;
				}
			}
			return bFound;
		}
/* ----------------------------------------------- NEW WINDOWS ------------------------------------------------------------ */

	//----------------------------
	// create new window without menubar
	//----------------------------
		function NewWindow(sURL, width, hight){
			window.open(sURL, 'NewWindow', 'scrollbars=no,status=no,width='+ width+',height='+hight+',resizable=no');
		}
				
		function openSearchWindow(file){
			var iWidth = 500, iHeight = 500;
			window.open(file,"Search" ,"toolbar=no,scrollbars=yes,resizable=yes,width=" +iWidth + ",height=" + iHeight).focus();
		}
		
		function openCustomWindow(file, iWidth, iHeight){
			window.open(file,"Search" ,"toolbar=no,scrollbars=yes,resizable=yes,width=" +iWidth + ",height=" + iHeight).focus();
		}
		
		function openNewWindow(file, Title){
			var iWidth = 500, iHeight = 600;
			window.open(file,Title ,"toolbar=no,scrollbars=yes,resizable=yes,width=" +iWidth + ",height=" + iHeight).focus();
		}
		
		function openCalendarWindow(file, Title){
			var iWidth = 500, iHeight = 600;
			window.open(file,Title ,"toolbar=no,scrollbars=yes,resizable=yes,width=" +iWidth + ",height=" + iHeight).focus();
		}
		
		function showFullImage(URL) {	
			fullSizeWin = window.open(URL, "_blank", 'location=no,titlebar=no,scrollbars=yes,status=no,width=500,height=300,resizable=yes,toolbar=no,menubar=no');		
			fullSizeWin.focus();	
		}
/* ----------------------------------------------- REDIRECT ------------------------------------------------------------ */

	//----------------------------
	// confirm to redirect
	//----------------------------
		function confirmRedirect(strMessage, strUrl){
			if(confirm(strMessage))
			{
				window.location.href=strUrl;
			}
		}

/* ----------------------------------------------- CONFIRM DELETE ITEMS  ------------------------------------------------------------ */

	//----------------------------
	// confirm to delete
	//----------------------------	
		function deleteMe(itemTitle, itemTitles){
			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)
				return confirm("You are deleteing " + count + " selected " + itemTitles + ". Do you wish to continue?")				
			else
			{
				alert("You must select at least one " + itemTitle + " to delete!");
				return false;
			}
		}
	
	//----------------------------
	// confirm to delete
	//----------------------------
		function confirmDel(theForm,subControl){
	
			var count=0;
			for(var i=0;i<theForm.elements.length;i++) {
				var e= theForm.elements[i];
				if((e.name==subControl) &&(e.checked==true))count++;
			}
		
			if (count==0){
				alert("Please choose at least one item to delete");
				return false;
			} else {
				return confirm("Are you sure want to delete these item(s)?");
			}
		}

	//----------------------------
	// deleteMeWithAlert
	//----------------------------
		function deleteMeWithAlert(itemTitle, itemTitles, itemFieldName, itemCountName, itemTitleSub)
		{
			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)
				{
					var itemCount = document.getElementById(itemCountName + "_" + e.value).value;
					if(parseInt(itemCount,10) > 0)
					{
						var itemName = document.getElementById(itemFieldName + "_" + e.value).value;
						strAlert = strAlert + itemTitle + " (" + itemName + ") already has " + itemTitleSub + ". Please deselect it!\n"
					}
					count++;
				}
			}
			if (count > 0)
				if(strAlert != "")
				{
					alert(strAlert);
					return false;
				}
				else
				{
					return confirm("You are sure to delete " + count + " selected " + itemTitles + ". Do you wish to continue?")				
				}
			else
			{
				alert("You must select at least one " + itemTitle + " to delete!");
				return false;
			}
		}
	

	//----------------------------
	// deleteMeWithAlertEx
	//----------------------------
		function deleteMeWithAlertEx(itemTitle, itemTitles, itemFieldName, itemCountName, itemTitleSub)
		{
			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)
				{				
					var itemCount = document.getElementById(itemCountName + "_" + e.value).value;
					if(parseInt(itemCount,10) > 0)
					{
						var itemName = document.getElementById(itemFieldName + "_" + e.value).value;
						strAlert = strAlert + itemTitle + " (" + itemName + ") already has " + itemCount + " " + itemTitleSub + ". Please deselect it!\n"
					}
					count++;
				}
			}
			
			if (count > 0)
				if(strAlert != "")
				{
					alert(strAlert);
					return false;
				}
				else
				{
					return confirm("You are sure to delete " + count + " selected " + itemTitles + ". Do you wish to continue?")				
				}
			else
			{
				alert("You must select at least one " + itemTitle + " to delete!");
				return false;
			}
		}
	
	//----------------------------
	// deleteMeWithAlertAttribute
	//----------------------------
		function deleteMeWithAlertAttribute(itemTitle, itemTitles, itemFieldName, itemCountName, itemTitleSub){
			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)
				{
					var itemCount = document.getElementById(itemCountName + "_" + e.value).value;
					
					if(parseInt(itemCount,10) > 0)
					{
						var itemName = document.getElementById(itemFieldName + "_" + e.value).value;
						strAlert = strAlert + itemTitle + " (" + itemName + ") is used for " + itemTitleSub + ". Please deselect it!\n"
					}
					count++;
				}
			}
			if (count > 0)
				if(strAlert != "")
				{
					alert(strAlert);
					return false;
				}
				else
				{
					return confirm("You are about to delete " + count + " selected " + itemTitles + ". Do you wish to continue?")				
				}
			else
			{
				alert("You must select at least one " + itemTitle + " to delete!");
				return false;
			}
		}	

/* ----------------------------------------------- BROWSER FUNCTIONS ------------------------------------------------------------ */

	//----------------------------
	// bookmarksite
	//----------------------------
		function bookmarksite(title,url){
			if (window.sidebar){ // firefox
				window.sidebar.addPanel(title, url, "");
			}
			else if(window.opera && window.print){ // opera
				var elem = document.createElement('a');
				elem.setAttribute('href',url);
				elem.setAttribute('title',title);
				elem.setAttribute('rel','sidebar');
				elem.click();
			} 
			else if(document.all){ // ie
				window.external.AddFavorite(url, title);
			}
		}

	//----------------------------
	// openBookmarkList
	//----------------------------
		function openBookmarkList(id){
			var el = GetObjectID(id);
			el.style.display='';
		}

	//----------------------------
	// hideBookmarkList
	//----------------------------
		function hideBookmarkList(id){
			var el = GetObjectID(id);
			el.style.display='none';
		}


/* ----------------------------------------------- CHECK/UNCHECK SELECTION/CHECKBOX ------------------------------------------------------------ */

	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 = "#EFEFEF";
				}
				else
				{
					trRow.bgColor = "#FFFFFF";
				}
			}
			if ((e.name == coltrolName))
			{
				iIndex++;
			}
		}
	}
	

	function checkSelect(target, iIndex)
	{
		var trRow = document.getElementById("trRow" + iIndex);
		if(target.checked)
		{
			trRow.bgColor = "#EFEFEF";
		}
		else
		{
			trRow.bgColor = "#FFFFFF";
		}
	}


	function checkAllEx(coltrolName, target, checkColor, normalColor)
	{
		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 = checkColor;
				}
				else
				{
					trRow.bgColor = normalColor;
				}
			}
			if ((e.name == coltrolName))
			{
				iIndex++;
			}
		}
	}
	

	function checkSelectEx(target, iIndex, checkColor, normalColor)
	{
		var trRow = document.getElementById("trRow" + iIndex);
		if(target.checked)
		{
			trRow.bgColor = checkColor;
		}
		else
		{
			trRow.bgColor = normalColor;
		}
	}

/* ----------------------------------------------- OTHERS ------------------------------------------------------------ */

	//----------------------------
	// stripCharsInBag
	//----------------------------
		
		function stripCharsInBag(s, bag){
			var i;
			var returnString = "";
			// Search through string's characters one by one.
			// If character is not in bag, append to returnString.
			for (i = 0; i < s.length; i++){   
				var c = s.charAt(i);
				if (bag.indexOf(c) == -1) returnString += c;
			}
			return returnString;
		}

	//----------------------------
	// check delete image checkboxs
	//----------------------------
		
		function checkDeleteImage(obj1,obj2){
			if (obj1.checked == true)
			{
				obj2.disabled = true;
			}
			else
			{
				obj2.disabled = false;
			}
		}

	//----------------------------
	// 
	//----------------------------

		function IsCheckedRadio(source){ 
			if(source.length != null){			
				for (i=0; i< source.length; i++)
				if (source[i].checked)
				return true;
			}
			else{
				if (source.checked)
					return true;
			}
			return false;
		}
		
	//----------------------------
	// 
	//----------------------------

		function showmenu(flag){
			var menu = document.getElementById("pmenu");
			if(flag==1){ menu.style.display = "";}
			else{ menu.style.display="none";}
		}
	
	//----------------------------
	// change status
	//----------------------------
		function changeStatus(statusTitle, itemTitle){
			var count = 0;
			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){
				return true;
			}
			else
			{
				alert("You must select at least one " + itemTitle + " to set " + statusTitle + "!");
				return false;
			}
		}
	
	
	//----------------------------
	// change featured
	//----------------------------
		function changeFeatured(statusTitle, itemTitle){
			var count = 0;
			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){
				return true;
			}
			else
			{
				alert("You must select at least one " + itemTitle + " to " + statusTitle + "!");
				return false;
			}
		}
	
	//----------------------------
	// changeComboBox
	//----------------------------
		function changeComboBox(target, queryKey, queryValue, strUrl){	
			var strAppend = "?";
			if(strUrl.indexOf("?") > 0)
			{
				strAppend = "&";
			}
			if(strUrl.indexOf(queryKey + "=") > 0)
			{
		
				strUrl = strUrl.replace(queryKey + "=" + queryValue, queryKey + "=" + target.value);
						
			}
			else
			{
				strUrl = strUrl + strAppend + queryKey + "=" + target.value;
				
			}
			window.location.href=strUrl;
		}
