//--------------------------------------------------------------------------------
function object_preview(obj,ctrl){
	var typeid = ctrl.options[ctrl.selectedIndex].value;
	var value  = obj.value;
	if(value){
		switch(typeid){
			case "0":{
				document.all["t"].src=value;
			}break;
			case "1":{
				document.f.movie=value;
			}break;	
		} //end of switch	
	} //end of of(value)	
}

//--------------------------------------------------------------------------------
/*
//-- auto maximize window --
<!-- Begin
	top.window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	} else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
// End -->
*/
//--------------------------------------------------------------------------------
//shopping cart functions
function ShippingFee(form){
	if(form.shippingfee_domestic.disabled==false && form.shippingfee_domestic.value){
		alert(form.shippingfee_domestic.options[form.shippingfee_domestic.selectedIndex].text + ' - Php ' + form.shippingfee_domestic.value + '.00');
	}
	else if(form.shippingfee_foreign.disabled==false && form.shippingfee_foreign.value){
		alert(form.shippingfee_foreign.options[form.shippingfee_foreign.selectedIndex].text + ' - Php ' + form.shippingfee_foreign.value + '.00');
	}	
}
function ValidateShippingForm(form, msg) {
	if (confirm(msg)){
		/*
		fullname
		email
		phone
		cellphone
		address
		shippingloc - radio button
		shippingfee_domestic
		shipping_foreign
		*/
		if(!form.fullname.value) return feedback(form.fullname,"Please fill in your name.");
		if(!form.email.value) return feedback(form.email,"Please fill in your e-mail.");
		if(!form.phone.value) return feedback(form.phone,"Please fill in your phone number.");
		if(!form.cellphone.value) return feedback(form.cellphone,"Please fill in your mobile number.");
		if(!form.address.value) return feedback(form.address,"Please fill in your shipping address.");
		
		if(!form.shippingfee_domestic.disabled && !form.shippingfee_domestic.value){
			alert("Please select your domestic shipping zone based on your shipping address.");
			return false;
		}
		
		if(!form.shippingfee_foreign.disabled && !form.shippingfee_foreign.value){
			alert("Please select your foreign shipping zone based on your shipping address.");
			return false;
		}
		return true;
		//return (checkHTML(form));
	}
	return false;
}
//--------------------------------------------------------------------------------
function ShowHide(name){
	if (document.getElementById(name).style.visibility=="visible") {
		document.getElementById(name).style.visibility="hidden";
		document.getElementById(name).style.position="absolute";
	} else{
		document.getElementById(name).style.visibility="visible";
		document.getElementById(name).style.position="static";
	}
}
//--------------------------------------------------------------------------------
function bookmark() {
	window.external.AddFavorite("http://www.imagesphilippines.com.","ImagesPhilippines - EACOMM Corporation")
}
//--------------------------------------------------------------------------------
//change button color
<!-- Begin
function change(bg){
var el=event.srcElement
	if (el.tagName=="INPUT"&&el.type=="button"||el.type=="submit"||el.type=="reset"){
		event.srcElement.style.backgroundColor=bg;
	}
}
// -->
//--------------------------------------------------------------------------------
// Typewrier Text on Status Bars
<!--
var speed = 50 // decrease value to increase speed (must be positive)
var pause = 3000 // increase value to increase pause
var timerID = null
var bannerRunning = false
var ar = new Array()

ar[0] = "ImagesPhilippines.com"
ar[1] = "Photos, Pictures, Images..."
ar[2] = "People, Places, Events..."
ar[3] = "About the Philippines"
ar[4] = "EACOMM Corporation"
ar[5] = "www.eacomm.com"

var currentMessage = 0
var offset = 0
function stopStatus() {
	if (bannerRunning)
    	clearTimeout(timerID)
    bannerRunning = false
}
function startStatus() {
	stopStatus()
	showStatus()
}
function showStatus() {
	var text = ar[currentMessage]
    if (offset < text.length) {
    	if (text.charAt(offset) == " ")
        	offset++                        
			var partialMessage = text.substring(0, offset + 1) 
			window.status = partialMessage
        	offset++ 
			timerID = setTimeout("showStatus()", speed)
				bannerRunning = true
	} else {
		offset = 0
		currentMessage++
		if (currentMessage == ar.length)
			currentMessage = 0
			timerID = setTimeout("showStatus()", pause)
			bannerRunning = true
	}
}
// -->
//--------------------------------------------------------------------------------
//trim trailing and leading spaces and multispace inbetweens
<!-- Begin
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}
// -->
//--------------------------------------------------------------------------------
//check for invalid filename characters
<!-- Begin
function invalid_char(frmObj) {
	var regInvalid = /[ ,:;~!@#$%^&*()?"'`<>+=|{}\/\\/]/gi;
	var str = frmObj.value;

	if (str.match(regInvalid))	frmObj.value = str.replace(regInvalid,"");
}
// -->
//--------------------------------------------------------------------------------
//Restrict Base Price to numbers
<!-- Begin
function ValidateNum(frmObj) {
	var regNotPhone=/[^.0-9]/gi;
	var tmpStr=frmObj.value;
	var first=tmpStr.indexOf(".");
	var last=tmpStr.lastIndexOf(".");
	if (first == last){
		frmObj.value=tmpStr.replace(regNotPhone,"");}
	else{
		frmObj.value=tmpStr.substring(0, tmpStr.length - 1);}
}
// End -->
//--------------------------------------------------------------------------------
//Integer numbers only
<!-- Begin
function ValidateInt(frmObj) {
	var regNotPhone=/[^0-9]/gi;
	var tmpStr=frmObj.value;
	frmObj.value=tmpStr.replace(regNotPhone,"");
}
// End -->
//--------------------------------------------------------------------------------
//Format to Decimal
<!-- Begin
function formatDecimal(frmObj, addzero, decimaln) {
	var argvalue = frmObj.value;
	if (argvalue){
	  var numOfDecimal = (decimaln == null) ? 2 : decimaln;
	  var number = 1;
	
	  number = Math.pow(10, numOfDecimal);
	
	  argvalue = Math.round(parseFloat(argvalue) * number) / number;
	  // If you're using IE3.x, you will get error with the following line.
	  // argvalue = argvalue.toString();
	  // It works fine in IE4.
	  argvalue = "" + argvalue;
	
	  if (argvalue.indexOf(".") == 0)
	    argvalue = "0" + argvalue;
	
	  if (addzero == true) {
	    if (argvalue.indexOf(".") == -1)
	      argvalue = argvalue + ".";
	    while ((argvalue.indexOf(".") + 1) > (argvalue.length - numOfDecimal))
	      argvalue = argvalue + "0";
	  }
	  frmObj.value = argvalue;
	}
	else{
	  frmObj.value = "0.00";		
  	}
}
// End -->
//--------------------------------------------------------------------------------
//Change link
<!-- Begin
function changeLink(form, idlink, start, id, a_id, c_id){
	var authorid = idlink.substring(0, idlink.indexOf('--'));
	var link = idlink.substring(idlink.indexOf('--') + 2, idlink.lastIndexOf('--'));
	var name = idlink.substr(idlink.lastIndexOf('--') + 2);
	
	/*
	if (id!=0){
		document.links[i].href = "admineditprofile.php?id="+id+"&authorid="+authorid+"&start="+start+"&start1=0";}
	else{
		document.links[i].href = "admineditprofile.php?authorid="+authorid+"&start1=0";;}
	*/

	viewlink.href = "adminprof_edit.php?authorid="+authorid+"&start1=0";	
	form.authorname.value = name
	form.authorid.value = authorid;
	//alert(viewlink.href);
}
// End -->
//--------------------------------------------------------------------------------
//korek to jpg, swf filename
<!-- Begin
function ProperFileName(form,typeid){
	var str = form.picname.value;
	var i = str.lastIndexOf(".");
	var ext;
	
	switch(typeid){
		case 0: ext=".jpg"; break;
		case 1: ext=".swf"; break;
	}//end switch	
	
	if (str.length > 0){
		if (i != -1){
  			if (str.substr(i) != ext){
    			form.picname.value = str.substring(0, i) + ext;
  			}
		}
  		else{
    		form.picname.value = str + ext;
    	}
    }
    else{
    	form.picname.value = form.oldpicname.value;
    }

	if(typeid==0){
		form.picnail.value='_'+form.picname.value;
		form.picnail2.value='_'+form.picname.value;
		form.t.src=form.dir.value+'_'+this.value;
	}	
}

// -->
//--------------------------------------------------------------------------------

//delete keyword from <select> keywords
<!-- Begin
function delete_keyword(form){
	var frmObj	= form.keywords.options;

	if(frmObj.selectedIndex!=-1) {
		frmObj[frmObj.selectedIndex] = null;
		form.keycount.value=frmObj.length;
		frmObj.focus();
	}
}
// -->
//--------------------------------------------------------------------------------
//add keyword to <select> keywords
//NOTE: select options list is zero-based.
<!-- Begin
function add_keyword(form,toadd){
	var lastindex = form.keywords.options.length;
	var maxkeywords = 16;
	var inthelist=false;

	if (toadd!="" && lastindex<maxkeywords) {
		//-- check if existing in option list --
		for(var i=0; i<lastindex; i++) {
			if(toadd==form.keywords.options[i].value){
				inthelist=true;
				break;
			}
		} //-- end of for --

		if(!inthelist) {
			form.keywords.options[lastindex] = new Option(toadd,toadd);
			form.keyword.value="";
			form.keyword.focus();

			form.keycount.value=lastindex+1;
		}

	} //-- end of if toadd --
}
// End -->
//--------------------------------------------------------------------------------
// simulate enter key to do other other events instead of form onSubmit
<!-- Begin
function key_pressed(control) {
     getKey=event.keyCode;
     var form = document.forms(0);
     // enter key
     if (getKey=='13') {
    	switch(control){
 	 		case "keyword": {
 	 			add_keyword(form,form.keyword.value.toLowerCase());
 	 		}break;

    	} //-- end of switch --
    	return false;
     } //-- end of if ENTER pressed
    // numpad del key (numlock on)
    if (getKey=='46') {
    	switch(control){
    		case "keywords": {
    			delete_keyword(document.forms(0));
    		} break;
    	} //-- end of switch --
    } //--end of if DEL pressed
    return true;
}
// -->
//--------------------------------------------------------------------------------
//Validate Form [Required Elements]
<!-- Begin
// search form (imagephil.php)
function ValidateSearch(form, ctrl) {
	//required fields: search
	search_char(form.search);	//remove limiting characters

	if (ctrl==1) {
		if(!form.search.value)
			return feedback(form.search,"Please enter search keyword(s).");
	} else if(ctrl==2) {
		//if(form.dtnid.value==0)
		if(!form.search.value && !form.categories.value && !form.authorid.value && (form.dtnid.value==0)) 
		return feedback(form.search,"Please enter search keyword(s).");
	}
	//alert(form.search.value);
}
// -->
//--------------------------------------------------------------------------------
//limit search characters without
//customized for search
<!-- Begin
function search_char(frmObj) {
	var regInvalid = /[.,:;~!@#$%^&*()?"'`<>+=|{}\/\\/]/gi;
	var str = trim(frmObj.value.toLowerCase());

	if (str.match(regInvalid))	str = str.replace(regInvalid,"");

	frmObj.value = trim(str);
}
// -->
//--------------------------------------------------------------------------------
// adminpages validate form
<!-- Begin

function ValidateForm(form, msg) {
	if (confirm(msg)){
		/*
		required fields:
		picname
		keywords (at least one)
		if(!form. .value) return feedback(form. ,"Please fill in .");
		*/

		if(!form.picname.value) return feedback(form.picname,"Please fill in picname.");
		if(form.keywords.length==0) return feedback(form.keyword,"Please fill in at least one keyword.");
		getkeywords(form);
		
		return (checkHTML(form));
	}
	return false;
}
// -->
//--------------------------------------------------------------------------------
// adminnewprofile validate form
<!-- Begin
function ValidateProfile(form, msg) {
	if (confirm(msg)){
		/*
		required fields:
		author
		*/
		if(!form.author.value) return feedback(form.author,"Please fill in Author Name.");
		if(!form.email.value) return feedback(form.email,"Please fill in Email.");
		if(!form.username.value) return feedback(form.username,"Please fill in Login Name.");		
		if(!form.psword.value) return feedback(form.psword,"Please fill in Password.");		
		if(!form.psword2.value) return feedback(form.psword2,"Please re-type password.");		
		if(form.psword.value != form.psword2.value) return feedback(form.psword2,"Re-typed password does not match.");
		if(!form.que.value) return feedback(form.que,"Please fill in secret question.");		
		if(!form.ans.value) return feedback(form.ans,"Please fill in secret answer.");		
		//return (checkHTML(form));
		return true;
	}
	return false;
}
// -->
//--------------------------------------------------------------------------------
// requestmage.php validate form
<!-- Begin

function ValidateRequest(form, msg) {
	if (confirm(msg)){
		/*
		required fields:
		lastname
		firstname
		mi
		address
		tel
		email
		describe
		durationuse
		width
		height
		*/

		if(!form.lastname.value) return feedback(form.lastname,"Please fill in Last Name.");
		if(!form.firstname.value) return feedback(form.firstname,"Please fill in First Name.");
		if(!form.mi.value) return feedback(form.mi,"Please fill in Middle Initial.");
		if(!form.address.value) return feedback(form.address,"Please fill in Address.");
		if(!form.tel.value) return feedback(form.tel,"Please fill in Telephone.");
		if(!form.email.value) return feedback(form.email,"Please fill in Email.");
		if(!form.describe.value) return feedback(form.describe,"Please describe on detail how the image is to be used.");
		if(!form.durationuse.value) return feedback(form.durationuse,"Please fill in Duration.");
		if(form.deliverymode.value == "Hardcopy" && (!form.width.value || form.width.value==0)) return feedback(form.width,"Please specify the width.");

		return true;
//		return (checkHTML(form));
	}
	return false;
}
// -->
//--------------------------------------------------------------------------------
// ../aboutus/application.php validate form
<!-- Begin

function ValidateApplication(form, msg) {
	if (confirm(msg)){
		/*
		required fields:
		lastname
		firstname
		middlename
		address1
		city
		tel
		email
		occupation
		corpname
		corpaddress1
		corpcity
		corptel
		hobby1
		hobby2
		description
		userfile[0-2]
		reason
		*/
		if(!form.lastname.value) return feedback(form.lastname,"Please fill in Last Name.");
		if(!form.firstname.value) return feedback(form.firstname,"Please fill in First Name.");
		if(!form.middlename.value) return feedback(form.middlename,"Please fill in Middle Name.");
		if(!form.address1.value) return feedback(form.address1,"Please fill in Address 1.");
		if(!form.city.value) return feedback(form.city,"Please fill in City.");
		if(!form.tel.value) return feedback(form.tel,"Please fill in Telephone.");
		if(!form.email.value) return feedback(form.email,"Please fill in Email.");
		if(!form.occupation.value) return feedback(form.occupation,"Please fill in Occupation.");
		if(!form.corpname.value) return feedback(form.corpname,"Please fill in Company/Organization Name.");
		if(!form.corpaddress1.value) return feedback(form.corpaddress1,"Please fill in Company Address 1.");
		if(!form.corpcity.value) return feedback(form.corpcity,"Please fill in City.");
		if(!form.corptel.value) return feedback(form.corptel,"Please fill in Telephone.");
		if(!form.hobby1.value) return feedback(form.hobby1,"Please fill in Hobby.");
		if(!form.hobby2.value) return feedback(form.hobby2,"Please fill in Hobby.");
		if(!form.description.value) return feedback(form.description,"Please write a short description of yourself and your work.");
		if(!form.elements[31].value) return feedback(form.elements[31],"Please upload 3 images as sample of your work.");
		if(!form.elements[32].value) return feedback(form.elements[32],"Please upload 3 images as sample of your work.");
		if(!form.elements[33].value) return feedback(form.elements[33],"Please upload 3 images as sample of your work.");
		if(!form.reason.value) return feedback(form.reason,"Please state your primary reason for joining this service.");

		return true;
//		return (checkHTML(form));
	}
	return false;
}
// -->
//--------------------------------------------------------------------------------
//about us/ application --- limit to jpeg and gif attachment only
<!-- Begin
function checkAttach(frmObject) {
	var ext = frmObject.value;
	ext = ext.substring(ext.length-4,ext.length);
	(ext=='')?
	ext = "NULL":
	ext = ext.toUpperCase();

//	alert(ext);
	if (frmObject.value){
		if(ext == '.JPG' || ext == '.GIF') {
			return true;
		}else{
			alert('You selected a ' + ext + ' file. \nPlease input .JPG/.GIF file.');
			frmObject.focus();
			return false;
		}
	}else{return true;}

} //-- end function checkAttach --
//--------------------------------------------------------------------------------
// multiplier validate form
<!-- Begin

function ValidateMult(form, msg) {
	if (confirm(msg)){
		/*
		required fields:
		desc
		cat
		mult
		*/

		if(!form.desc.value) return feedback(form.desc,"Please fill in DESCRIPTION.");
		if(!form.cat.value) return feedback(form.cat,"Please fill in CATEGORY.");
		if(!form.mult.value) return feedback(form.mult,"Please fill in MULTIPLIER.");

		return (checkHTML(form));
	}
	return false;
}
// -->
//--------------------------------------------------------------------------------
// ./recommend/index.html
<!-- Begin
function ValidateRecommend(form, msg) {
	if (confirm(msg)){
		/*
		required fields:
		SName
		SEmail
		*/
		
		if(!form.SName.value) return feedback(form.SName,"Please fill in Your Name.");
		if(!form.SEmail.value) return feedback(form.SEmail,"Please fill in Your Email.");
		
		if (form.Name1.value && !form.Email1.value) return feedback(form.Email1,"Please fill in Email Address of "+form.Name1.value+".");
		if (form.Name2.value && !form.Email2.value) return feedback(form.Email2,"Please fill in Email Address of "+form.Name2.value+".");
		if (form.Name3.value && !form.Email3.value) return feedback(form.Email3,"Please fill in Email Address of "+form.Name3.value+".");
		if (form.Name4.value && !form.Email4.value) return feedback(form.Email4,"Please fill in Email Address of "+form.Name4.value+".");
		if (form.Name5.value && !form.Email5.value) return feedback(form.Email5,"Please fill in Email Address of "+form.Name5.value+".");

		if (!form.Message.value) return feedback(form.Message,"Please type in your message.");

		if (!form.Email1.value && !form.Email2.value && !form.Email3.value && !form.Email4.value && !form.Email5.value) return feedback(form.Email1,"Please fill in at least one Email Address.");
		return (checkHTML(form));
	}
	return false;
}
// -->
//--------------------------------------------------------------------------------

<!-- Begin
//get values of select option list
function getkeywords(form) {
	var thelist = form.keywords.options;
	var keycount = thelist.length;

	var item = "";
	var items = "";

	for(i=0;i<keycount;i++){
		item = thelist[i].value+" ";
		items += item;
	} //-- end of for ---
	form.keywords2.value = items;
}
// -->
//--------------------------------------------------------------------------------
<!-- Begin
//to focus form object and display message
function feedback(obj,msg) {
	alert(msg);
	obj.focus()
	return false;
}
// -->
//--------------------------------------------------------------------------------
<!-- Begin
//check if there is any HTML tag
function checkHTML(form) {
	var regHTML=/\<.|\>.$/i;
	for(i=0;i<form.elements.length;i++){
		var obj = form.elements[i];
		if(regHTML.test(obj.value)){
			obj.select();
			return feedback(obj,"Possible HTML tag found.")
			break;
		}
	}
	return true;
}
// End -->
//--------------------------------------------------------------------------------
//Validate URL for http:// and www
<!-- Begin
function ValidateURL(frmObj) {
	if (frmObj.value){
	var tmpStr=frmObj.value.toLowerCase();
	(!tmpStr.match('http://')) ? frmObj.value="http://"+tmpStr : frmObj.value=tmpStr.toLowerCase();
	}}
//trim trailing and leading spaces and multispace inbetweens
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}
// End -->
//--------------------------------------------------------------------------------

//Validate maximum characters
<!-- Begin
function MaxChar(frmObj,maxLen) {
	var tmpStr=frmObj.value;
	var strLen=tmpStr.length;
	if(strLen>=maxLen){
		frmObj.value=tmpStr.substring(0,maxLen);
	}
}
// End -->
//--------------------------------------------------------------------------------
//Restrict Date to Digits and some characters
<!-- Begin
function ValidateDate(frmObj) {
	var regNotDate=/[^-+\/(0-9)]/gi;
	var tmpStr=frmObj.value;
	if(tmpStr.match(regNotDate)) {
		frmObj.value=tmpStr.replace(regNotDate,"");
	}
}
// End -->
//--------------------------------------------------------------------------------
//Add Artist/Photographer and Date Taken to Technical Info and Keyword
<!-- Begin
function AddtoDesc(form,control){
	var str = form.picdesc.value;

	switch(control){
		case 'date': {
			var toappend = 'Date Taken: ' + form.datetaken.value;
			if (form.datetaken.value && (str.match(toappend)!=toappend) )  form.picdesc.value += toappend + '\n';
			//add_keyword(form,form.datetaken.value);
		}break;

		case 'photographer':{
			var toappend = 'Photographer/Artist: ' + form.photographer.value;
			if (form.photographer.value && (str.match(toappend)!=toappend) ) form.picdesc.value +=  toappend + '\n';

			/*
			var photographer_array = form.photographer.value.split(" ");
			for (var loop=0; loop<photographer_array.length; loop++) {
				if (photographer_array[loop].length > 3)
			   		add_keyword(form,photographer_array[loop].toLowerCase());
			}
			*/
		}break;

		case 'place':{
			var province = form.provinces.options[form.provinces.options.selectedIndex].value;
			var toappend = 'Place Taken: ' + province;
			if (province && (str.match(toappend)!=toappend) ) form.picdesc.value +=  toappend + '\n';


		}break;
	} //-- end of switch --
}
// End -->
//--------------------------------------------------------------------------------
//Edit Artist/Photographer and Date Taken to Technical Info and Keyword
<!-- Begin
function EditDesc(form, objvalue, control){
	var str;
	var slice1;
	var slice2;
	var slice3;
	var i;

	str = trim(form.picdesc.value) + '\n';

	i = str.indexOf(control)
	if (objvalue){
		if (i > -1){ 
			slice1 = str.substring(0, i)
			slice2 = str.substr(i)
			i = slice2.indexOf("\n")
			slice3 = slice2.substr(i)
			slice2 = slice2.substring(0, i)
			slice2 = control + " " + objvalue
			form.picdesc.value = slice1 + slice2 + slice3
		}
		else{
			form.picdesc.value =  str+control + objvalue +'\n';
		}
	}
}	
// End -->
//--------------------------------------------------------------------------------

//Proper Case
<!-- Begin
function ProperCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	tmpStr = trim(frmObj.value);
	strLen = tmpStr.length;

	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
	         	}
	      	}
	   }
	}
	frmObj.value = tmpStr;
}
// End -->
//--------------------------------------------------------------------------------

//Proper Case2
<!-- Begin
function ProperCase2(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	tmpStr = trim(frmObj.value.toLowerCase());
	strLen = tmpStr.length;

	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
	         	}
	      	}
	   }
	}
	frmObj.value = tmpStr;
}
// End -->
//--------------------------------------------------------------------------------
//Upper Case
<!-- Begin
function UpperCase(frmObj) {
	frmObj.value = frmObj.value.toUpperCase();
}
// End -->
//--------------------------------------------------------------------------------
//Add Dot [for M.I.]
<!-- Begin
function AddDot(frmObj) {
	var tmpStr = frmObj.value.toUpperCase();
	if (tmpStr.indexOf('.')<0) {
		frmObj.value = tmpStr + ".";
	}
}
// End -->
//--------------------------------------------------------------------------------//================= ADMINPAGE SCRIPTS ============================================

//Validate Email Address
<!-- Begin
function ValidateEmail(frmObj) {
	var regEmail=/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi;

	if (trim(frmObj.value)){
		if(!regEmail.test(frmObj.value)) {
			alert("Sorry, invalid email address format.");
			frmObj.select();
			frmObj.focus();
		}
	}
}
// End-->
//--------------------------------------------------------------------------------

//Initialize Case (For Textarea - include newLine)
<!-- Begin
function InitTextArea(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	
	tmpStr = trim(frmObj.value);
	strLen = tmpStr.length;
	
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " || tmpChar == "\n" && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
	         	}	
	      	}
	   }
	}
	frmObj.value = tmpStr;
}
// End -->
//--------------------------------------------------------------------------------
//Restrict Phone and Fax to Digits and some characters
<!-- Begin
function ValidatePhoneFax(frmObj) {
	var regNotPhone=/[^- +\/(0-9)]/gi;
	var tmpStr=frmObj.value;
	if(tmpStr.match(regNotPhone)) {
		frmObj.value=tmpStr.replace(regNotPhone,"");
	}
}
// End -->
//--------------------------------------------------------------------------------
//Restrict to Digits and some characters
<!-- Begin
function ValidateDigits(frmObj) {
	var regNotDigits=/[^(0-9)]/gi;
	var tmpStr=frmObj.value;
	if(tmpStr.match(regNotDigits)) {
		frmObj.value=tmpStr.replace(regNotDigits,"");
	}
}
// End -->
//--------------------------------------------------------------------------------
//requestmage.php 
<!-- Begin
function chkEnable(ctrl, form) {
	if (ctrl=='Digital'){
		form.resolution.disabled=false
		form.digital.disabled=false	
		form.width.disabled=true
		form.height.disabled=true
		form.required.disabled=true
	}else{
		form.resolution.disabled=true
		form.digital.disabled=true
		form.width.disabled=false
		form.height.disabled=false
		form.required.disabled=false
	}
}
// End -->
//--------------------------------------------------------------------------------//================= ADMINPAGE SCRIPTS ============================================
//Get width/height requestmage.php
<!-- Begin
function GetDimension(passvalue, ctrl, pw, ph, frm) {
//	alert("VALUE="+passvalue+"\n\r"+pw+" x "+ph+"\n\r"+ctrl);
	if (passvalue=="." || passvalue=="") passvalue=0;
		
	if (ctrl==0){ //-- pass value is width
		h=(passvalue*ph)/pw
		h=Math.round(h*1000)/1000
		frm.height.value = h;
	}else{ //-- pass value is height
		w=(passvalue*pw)/ph
		w=Math.round(w*1000)/1000
		frm.width.value = w;
	}	
}
// End -->
//--------------------------------------------------------------------------------
<!-- Begin
function showus() {
     getKey=event.keyCode;
     // esc - 27
     if (getKey=='27') {
		alert("Web Developers:\n CrisJr [crisjr_27@yahoo.com]\n Grace [garabone@yahoo.com]");	    	
    	return false;
     }
    return true;
}
// -->
/*
//----------------- CALENDAR FUNCTIONS -------------------------------------------
<!-- Begin
function y2k(number)    { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());

function padout(number) { return (number < 10) ? '0' + number : number; }

function restart() {
    //-- change output textbox ---
    var outbox = document.forms[0].datetaken;
    outbox.value = '' + padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
    outbox.focus();
    mywindow.close();
}

function openCal() {
    var myWidth=350
    var myHeight=270
    mywindow=open('cal.htm','mycal','resizable=no, width='+myWidth+',height='+myHeight+',top='+(100+screen.height-myHeight)/2+',left='+(320+screen.width-myWidth)/2 +',scrollbar=no');
    mywindow.location.href = 'cal.htm';
    if (mywindow.opener == null) mywindow.opener = self;
}
//--------------------------------------------------------------------------------
*/

//---- PART OF VALIDATION FORM ---- IMAGE UPLOAD ----------------------------------
function checkUpload() {
	if (confirm('Upload image?')) {
  		var ext = document.forms[0].picname.value;
  		ext = ext.substring(ext.length-4,ext.length);
  		(ext=='')?
  			ext = "NULL":
  			ext = ext.toUpperCase();

		//alert(ext);
  		
  		if(ext != '.JPG' && ext != '.SWF') {
  			alert('You selected a ' + ext + ' file. \nPlease input [.JPG, .SWF] file.');
    		document.forms[0].picname.focus();
    		return false;
    	} else {
  			//-- set the keywords (option list) to keywords2 (hidden)--
  			//-- getkeywords function is defined in imagephil.java ---
  			getkeywords(document.forms[0]);
    		return true;
    	}
    	
	}
	return false;

} //-- end function checkUpload --

//======================= swap option list for keywords ============================
function swap(obj,ctrl){
	var index = obj.selectedIndex;
	switch(ctrl.toUpperCase()){
		case 'UP':{
			//-- check if top list
			if (index>0){
				var swap = obj[index-1].value;

				obj[index-1].value = obj[index].value;
				obj[index-1].text = obj[index].value;

				obj[index].value = swap;
				obj[index].text = swap;
			}
		}break;
		case 'DOWN':{
			if(index<obj.length-1) {
				var swap = obj[index+1].value;
				obj[index+1].value = obj[index].value;
				obj[index+1].text = obj[index].value;

				obj[index].value = swap;
				obj[index].text = swap;
			}
		}break;
	} //-- end of switch --

} //-- end of function swapUP --
// End -->
//------------- END SCRIPT FOR ADMINPAGE -------------------------------------------