// JavaScript Document

//Francis Files

function PopupPic(sPicURL, title,w,h) { 

     var winl = (screen.width - w) / 2;

    var wint = (screen.height - h) / 2;

    winprops = 'height=100,width=100,top='+wint+',left='+winl+'resizable=0';

  window.open("picturedetails.html?"+sPicURL+"&"+title+"", "", winprops);

  } 

function pop_center(mypage, myname, w, h, scroll) {

var winl = (screen.width - w) / 2;

var wint = (screen.height - h) / 2;

winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';

win = window.open(mypage, myname, winprops);

if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); };

}

function isschar(text){

 var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

        for (var i = 0; i < text.length; i++) {

                if (iChars.indexOf(text.charAt(i)) != -1) {

                alert ("The box has special characters. \nThese are not allowed.\n");

                return false;

        }

                }

   

return true;



}

String.prototype.trim = function() {



 // skip leading and trailing whitespace

 // and return everything in between

  var x=this;

  x=x.replace(/^\s*(.*)/, "$1");

  x=x.replace(/(.*?)\s*$/, "$1");

  return x;

}

function isArray(com) {

	if (typeof(com.length) == "undefined") {

		return false;

	}

	else {

		return true;

	}

}



function isArraySelectBox(com) {

	if (typeof(com[0].length) == "undefined") {

		return false;

	}

	else {

		return true;

	}

}



function trim(str) {

	var strTrim = "";

	var i, j;

	

	if (isEmpty(str)) return strTrim;

	

	for (i=0; i<str.length; i++) {

		if (str.charAt(i) != " ") break;

	}

	for (j=str.length-1; j>=0; j--) {

		if (str.charAt(j) != " ") break;

	}

	

	strTrim = str.substr(i, j-i+1);

	return strTrim;

}

function remove_spaces(str) {

	var strTrim = "";

	var i, j;

	

	if (isEmpty(str)) return strTrim;

	

	for (i=0; i<str.length; i++) {

		if (str.charAt(i) != " ") break;

	}

	for (j=str.length-1; j>=0; j--) {

		if (str.charAt(j) != " ") break;

	}

	

	strTrim = str.substr(i, j-i+1);

	alert("return :"+strTrim);

	return strTrim;

}



function isEmpty(str) {

	return ((str==null) || (str.length==0));

}



function isWhiteSpace(str) {

	return isEmpty(trim(str));

}



function isDigit(d) {

	return ((d >= "0") && (d <= "9"));

}



function isLetter(c) {

	return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")));

}



function isNumeric(strNum) {

	var i;

	

	if (isWhiteSpace(strNum) == true) {

		return false;

	}

	

	strNum = trim(strNum);

	

	for (i=0; i<strNum.length; i++) {

		var chr = strNum.charAt(i);

		if (!isDigit(chr)) {

			return false;

		}

	}

	return true;

}

function isInteger(s)

{   var i;



    if (isEmpty(s)) 

       if (isInteger.arguments.length == 1) return false;

       else return (isInteger.arguments[1] == true);



    // Search through string's characters one by one

    // until we find a non-numeric character.

    // When we do, return false; if we don't, return true.



    for (i = 0; i < s.length; i++)

    {   

        // Check that current character is number.

        var c = s.charAt(i);



        if (!isDigit(c)) return false;

    }



    // All characters are numbers.

    return true;

}



function isAlphaNumeric(strNum) {

	var i;

	

	if (isWhiteSpace(strNum) == true) {

		return false;

	}

	

	strNum = trim(strNum);

	

	for (i=0; i<strNum.length; i++) {

		var chr = strNum.charAt(i);

		if (!isDigit(chr) && !isLetter(chr)) {

			return false;

		}

	}

	return true;

}



function isAlphaOnly(strNum) {

	var i;

	

	if (isWhiteSpace(strNum) == true) {

		return false;

	}

	

	strNum = trim(strNum);

	

	for (i=0; i<strNum.length; i++) {

		var chr = strNum.charAt(i);

		if (!isLetter(chr)) {

			return false;

		}

	}

	return true;

}



function isEmail(s)

{   

	

	//alert(s); 

   	// is s whitespace?

    //if (isWhitespace(s)) return false;

    

    // there must be >= 1 character before @, so we

    // start looking at character position 1 

    // (i.e. second character)

    var i = 1;

    var sLength = s.length;



    // look for @

    while ((i < sLength) && (s.charAt(i) != "@"))

    { i++;

    }



    if ((i >= sLength) || (s.charAt(i) != "@")) return false;

    else i += 2;



    // look for .

    while ((i < sLength) && (s.charAt(i) != "."))

    { i++;

    }



    // there must be at least one character after the .

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;

    else

	return true;

}



//Function to check whether the string is a valid integer

//Function to check whether the zipcode is a valid US zip code

function isZIPCode(field) 

{

	var valid = "0123456789";

	var hyphencount = 0;

	

	if (field.length!=5) {

	alert("Please enter your 5 digit zip code.");

	return false;

	}

	for (var i=0; i < field.length; i++) {

	temp = "" + field.substring(i, i+1);

	if (valid.indexOf(temp) == "-1") {

	alert("Invalid characters in your zip code.  Please try again.");

	return false;

	}



	}

	return true;

}



function isMoney(str) 

// Dennis Seo: this is really simple check. If this ever needs to be

// sofisticated, it needs to be updated.

{

	var valid = "0123456789.-"

	var temp;

	for (var i=0; i<str.length; i++) {

		temp = "" + str.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") 

			//ok = "no";

			return false;

	}

	return true;

}



function isCheckedRadio(objRadio) {

	checked = false;

	if (objRadio) {

		count = objRadio.length;

		if(count == 1) {

			checked = objRadio.checked;

		} 

		else {

			for(var i=0; i<count; i++) {

				if(objRadio[i].checked) {

					checked = true;

				}

			}

		}

	}

	return checked;

}



function isSelected(frmObjSelect)

{

	if (frmObjSelect.value == -1) {

		return false;

	}

	else {

		return true;

	}

}





								function moveDownList(listField) {

   if ( listField.length == -1) {  // If the list is empty

      alert("There are no values which can be moved!");

   } else {

      var selected = listField.selectedIndex;

      if (selected == -1) {

         alert("You must select an entry to be moved!");

      } else {  // Something is selected 

         if ( listField.length == 0 ) {  // If there's only one in the list

            alert("There is only one entry!\nThe one entry will remain in place.");

         } else {  // There's more than one in the list, rearrange the list order

            if ( selected == listField.length-1 ) {

               alert("The last entry in the list cannot be moved down.");

            } else {

               // Get the text/value of the one directly below the hightlighted entry as

               // well as the highlighted entry; then flip them

               var moveText1 = listField[selected+1].text;

               var moveText2 = listField[selected].text;

               var moveValue1 = listField[selected+1].value;

               var moveValue2 = listField[selected].value;

               listField[selected].text = moveText1;

               listField[selected].value = moveValue1;

               listField[selected+1].text = moveText2;

               listField[selected+1].value = moveValue2;

               listField.selectedIndex = selected+1; // Select the one that was selected before

            }  // Ends the check for selecting one which can be moved

         }  // Ends the check for there only being one in the list to begin with

      }  // Ends the check for there being something selected

   }  // Ends the check for there being none in the list

}



								function moveUpList(listField) {

   if ( listField.length == -1) {  // If the list is empty

      alert("There are no values which can be moved!");

   } else {

      var selected = listField.selectedIndex;

      if (selected == -1) {

         alert("You must select an entry to be moved!");

      } else {  // Something is selected 

         if ( listField.length == 0 ) {  // If there's only one in the list

            alert("There is only one entry!\nThe one entry will remain in place.");

         } else {  // There's more than one in the list, rearrange the list order

            if ( selected == 0 ) {

               alert("The first entry in the list cannot be moved up.");

            } else {

               // Get the text/value of the one directly above the hightlighted entry as

               // well as the highlighted entry; then flip them

               var moveText1 = listField[selected-1].text;

               var moveText2 = listField[selected].text;

               var moveValue1 = listField[selected-1].value;

               var moveValue2 = listField[selected].value;

               listField[selected].text = moveText1;

               listField[selected].value = moveValue1;

               listField[selected-1].text = moveText2;

               listField[selected-1].value = moveValue2;

               listField.selectedIndex = selected-1; // Select the one that was selected before

            }  // Ends the check for selecting one which can be moved

         }  // Ends the check for there only being one in the list to begin with

      }  // Ends the check for there being something selected

   }  // Ends the check for there being none in the list

}

				function valid_image(strFilename)

 {

  

  //var ext=strFilename.substring(strFilename.length-3,strFilename.length);

  var separator = '.';

  var stringArray = strFilename.split(separator);

  ext=stringArray[stringArray.length-1];

  if ((ext!="jpg") &&  (ext!="JPG")&& (ext!="jpeg")&& (ext!="JPEG"))

   {

   	alert(ext+" extension is not valid .Pls Upload jpg File only! ex:logo.jpg");

  	return false;

   }else{

   return true;

   }

   

}

				function valid_audio(strFilename)

 {

  

  //var ext=strFilename.substring(strFilename.length-3,strFilename.length);

  var separator = '.';

  var stringArray = strFilename.split(separator);

  ext=stringArray[stringArray.length-1];

  if ((ext!="mp3") &&  (ext!="MP3")&& (ext!="wav")&& (ext!="WAV"))

   {

   	alert(ext+" extension is not valid .Pls Upload  wav or mp3 File only! ex:bg.mp3");

  	return false;

   }else{

   return true;

   }

   

}