var hr = escape(window.location.href);
var popups = new Array();

function ViewAllPhotos(ListingID) {
    var w = 620, h = 500;

	if (document.all || document.layers) {
		w = window.screen.availWidth;
		h = window.screen.availHeight;
	}

	var popW = 620, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
    window.open('../viewallphotos.php?blg_id=' + ListingID, 'ViewAllPhotos', 'toolbar=no,resizable=1,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
}

function ViewAllAptPhotos(blg_id, apt_id) {
    var w = 620, h = 500;

	if (document.all || document.layers) {
		w = window.screen.availWidth;
		h = window.screen.availHeight;
	}

	var popW = 620, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
    window.open('../viewallphotos.php?blg_id='+blg_id+'&apt_id='+apt_id, 'ViewAllPhotos', 'toolbar=no,resizable=1,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
}

function ViewAllCelPhotos(blg_id, cel_id) {
    var w = 620, h = 500;

	if (document.all || document.layers) {
		w = window.screen.availWidth;
		h = window.screen.availHeight;
	}

	var popW = 620, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
    window.open('../viewallphotos.php?blg_id='+blg_id+'&cel_id='+cel_id, 'ViewAllPhotos', 'toolbar=no,resizable=1,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Popup(url,width,height,target,status){
	if(!target) target = '_blank';
	if(!width)  width  = '430';
	if(!height) height = '250';
	if(!status) status = 'no';

	popups[popups.lenght] = window.open(
		url,
		target,
		"width="+width+", height="+height+", scrollbars=yes, status="+status+", resizable=yes"
	);
}
function Replay(id,url){
document.getElementById(id).src=url;
}

function DisableEnableForm(xForm,xHow){
  objElems = xForm.elements;
  for(i=0;i<objElems.length;i++){
    objElems[i].disabled = xHow;
  }
}


function submit_tell_friend(form, type, templ){
	real_action = '/tell_friend.php'
	target="_tell_friend"
	if (type != 3){
		email = form.friendsemail.value
		arr = email.match("^[0-9a-zA-Z]([0-9a-zA-Z\._\-]*)@(([0-9a-zA-Z\-]+\.)+)([0-9a-zA-Z\-]+)$")
	
		if (!arr){
			alert("Please enter valid email")
			return
		}
	}
	
	if (type == 2){
		window.open(real_action + "?type=2&friend_email=" + escape(email), target, "width=580, height=400, location=0, menubar=0, status=0, resizable=1");
	}else if (type == 3){
		window.open(real_action + "?type=3&templ=" + escape(templ), target, "width=580, height=400, location=0, menubar=0, status=0, resizable=1");
	}else{
		window.open(real_action + "?friend_email=" + escape(email), target, "width=580, height=400, location=0, menubar=0, status=0, resizable=1");
	}
	
}

function wopenWebUrl(url){
	var loc = url;
	if(loc == "") {
		alert("There is no URL to open.");
		return;
	}
	if(loc.indexOf('http://') < 0) { loc = "http://" + loc; }
	window.open(loc, 'www', 'width=600, height=450, location=yes,resizable=yes,scrollbars=yes');
}

function wopenREO(url){
	window.open(url, 'reoww', 'width=1000, height=700, menubar=yes,location=no,resizable=yes,scrollbars=yes,status=yes');
}

function wopen2(url){
	window.open(url, 'ww', 'width=600, height=450, location=no,resizable=yes,scrollbars=yes');
}

function wopen(url){
	window.open(url, 'ww', 'width=550, height=450, location=no,resizable=yes,scrollbars=yes');
}
function wopen3(url) {
    window.open(url, 'ww', 'width=575, height=385, location=no,resizable=yes,scrollbars=no');
}

/*function submit_wish(){
	var real_action = 'wish.php';
	var target="Thank_You";
	var wish = document.forms['wish_form'].wish.value;
	var url = document.forms['wish_form'].url.value;
	if( wish.length < 1  ){
		alert("Enter subject you can not find, please !");
	}else if( url.length < 1){
		alert("Enter url of a sample site, please !");
	}else{
		window.open( real_action+"?wish="+escape(wish)+"&url="+escape(url)+"&wish_type=<?=(isset($wish_type) ? $wish_type : "1")?>", target, "location=0, menubar=0, status=0, resizable=1" );
	}
}*/


function selectTheOption(optionValue, obj) {

	//alert("trying to find: " + optionValue);
	if(optionValue == "") {
		return;
	} // end if

	for(x=0; x<obj.length; x++) {
		
		if(obj.options[x].value == optionValue) {
			obj.options[x].selected = true;
			break;
		}	
	} // end loop
}

function selectMultipleOptions(values, obj) {

	var vals = values;
	var selArr = vals.split(',');
	var part_num=0;
	
	// For each item in list - scroll through part
	for(x=0; x<obj.length; x++) {
		part_num = 0;
		while (part_num < selArr.length) {
			if(obj.options[x].value == selArr[part_num]) {
				//obj.options[x].selected = true;
				obj.item(x).selected = true;
			}
			part_num+=1;
		} // end while loop
	} // end for loop
	



}



function reportMultiple(sel_obj) {

	var options_string = "";
	var the_select = sel_obj;
	var first = true;

	for (loop=0; loop < the_select.options.length; loop++) {
		if (the_select.options[loop].selected == true) {
			 //alert("the_select.options[loop].value: " + the_select.options[loop].value);
			 if(first) {
				 options_string = options_string + the_select.options[loop].value;
				 first = false;
			 } else {
				 options_string = options_string + "," + the_select.options[loop].value;
			 }
		}
	}
	return options_string;

}




function formTextBoxonblur(obj) {
	obj.className = 'blurInput';
}
	
function formTextBoxonfocus(obj) {
	obj.className = 'focusInput';
}


//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

function LTrim(str){
	var ret=str+"";
	while(ret.length>0 && ret.substring(0,1)==" "){
		ret=ret.substring(1,ret.length);
	}
	return ret;
}

//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

function RTrim(str){
	var ret=str+"";
	while(ret.length>0 && ret.substring(ret.length-1,ret.length)==" "){
		ret=ret.substring(0,ret.length-1);
	}
	return ret;
}

//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

function Trim(str){
	return RTrim(LTrim(str));
}

//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

function roundMoney(amount) {
// returns the amount in the .99 format
    amount -= 0;
    amount = (Math.round(amount*100))/100;
    return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function MultiDimensionalArray(COLS, ROWS) {
  var i;
  var j;
  var a = new Array(ROWS);
  for (i=0; i < ROWS; i++) {
     a[i] = new Array(COLS);
     for (j=0; j < COLS; j++) {
             a[i][j] = "";
     }
  }
  return(a);
}

function KNTrim(String) {
   if (String == null) {
    return (false);
   }
   return String.replace(/(^\s+)|(\s+$)/g,"");
}

// VARIABLE DECLARATIONS

var digits = "0123456789";

var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";

var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

// whitespace characters
var whitespace = " \t\n\r";

// decimal point character differs by language and culture
var decimalPointDelimiter = ".";

var defaultEmptyOK = false;

var NUMBERCHARS = '$,';

// FUNCTION DEFININTIONS


// Check whether string s is empty.

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}


// Returns true if string s is empty or
// whitespace characters only.

function isWhitespace (s) {

	var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}


// Removes all characters which appear in string bag from string s.

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++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}



// Removes all characters which do NOT appear in string bag
// from string s.

function stripCharsNotInBag (s, bag) {

	var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}



// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripWhitespace (s) {
	return stripCharsInBag (s, whitespace)
}


// Removes initial (leading) whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripInitialWhitespace (s) {

	var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;

    return s.substring (i, s.length);
}


// Returns true if character c is an English letter
// (A .. Z, a..z).
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isLetter (c) {
	return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}



// Returns true if character c is a digit
// (0 .. 9).

function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}



// Returns true if character c is a letter or digit.

function isLetterOrDigit (c) {
	return (isLetter(c) || isDigit(c))
}



// isInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true),
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true
// isInteger ("")             defaultEmptyOK
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true

function isInteger (s) {

	var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       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;
}







// isSignedInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if all characters are numbers;
// first character is allowed to be + or - as well.
//
// Does not accept floating point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// EXAMPLE FUNCTION CALL:          RESULT:
// isSignedInteger ("5")           true
// isSignedInteger ("")            defaultEmptyOK
// isSignedInteger ("-5")          true
// isSignedInteger ("+5")          true
// isSignedInteger ("", false)     false
// isSignedInteger ("", true)      true

function isSignedInteger (s) {

	if (isEmpty(s))
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}




// isPositiveInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is an integer > 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isPositiveInteger (s) {

	var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a positive, not negative, number

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}






// isNonnegativeInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is an integer >= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNonnegativeInteger (s) {

	var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}






// isNegativeInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is an integer < 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNegativeInteger (s) {

	var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a negative, not positive, number

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}






// isNonpositiveInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is an integer <= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNonpositiveInteger (s) {

	var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number <= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}





// isFloat (STRING s [, BOOLEAN emptyOK])
//
// True if string s is an unsigned floating point (real) number.
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isInteger, then call isFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isFloat (s) {

	var i;
    var seenDecimalPoint = false;

    if (isEmpty(s))
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;

    // 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 ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}







// isSignedFloat (STRING s [, BOOLEAN emptyOK])
//
// True if string s is a signed or unsigned floating point
// (real) number. First character is allowed to be + or -.
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isSignedInteger, then call isSignedFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isSignedFloat (s) {

	if (isEmpty(s))
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}




// isAlphabetic (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is English letters
// (A .. Z, a..z) only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphabetic (s) {

	var i;

    if (isEmpty(s))
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}




// isAlphanumeric (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is English letters
// (A .. Z, a..z) and numbers only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphanumeric (s) {

	var i;

    if (isEmpty(s))
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphanumeric 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 or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}


// reformat (TARGETSTRING, STRING, INTEGER, STRING, INTEGER ... )
//
// Handy function for arbitrarily inserting formatting characters
// or delimiters of various kinds within TARGETSTRING.
//
// reformat takes one named argument, a string s, and any number
// of other arguments.  The other arguments must be integers or
// strings.  These other arguments specify how string s is to be
// reformatted and how and where other strings are to be inserted
// into it.
//
// reformat processes the other arguments in order one by one.
// * If the argument is an integer, reformat appends that number
//   of sequential characters from s to the resultString.
// * If the argument is a string, reformat appends the string
//   to the resultString.
//
// NOTE: The first argument after TARGETSTRING must be a string.
// (It can be empty.)  The second argument must be an integer.
// Thereafter, integers and strings must alternate.  This is to
// provide backward compatibility to Navigator 2.0.2 JavaScript
// by avoiding use of the typeof operator.
//
// It is the caller's responsibility to make sure that we do not
// try to copy more characters from s than s.length.
//
// EXAMPLES:
//
// * To reformat a 10-digit U.S. phone number from "1234567890"
//   to "(123) 456-7890" make this function call:
//   reformat("1234567890", "(", 3, ") ", 3, "-", 4)
//
// * To reformat a 9-digit U.S. Social Security number from
//   "123456789" to "123-45-6789" make this function call:
//   reformat("123456789", "", 3, "-", 2, "-", 4)
//
// HINT:
//
// If you have a string which is already delimited in one way
// (example: a phone number delimited with spaces as "123 456 7890")
// and you want to delimit it in another way using function reformat,
// call function stripCharsNotInBag to remove the unwanted
// characters, THEN call function reformat to delimit as desired.
//
// EXAMPLE:
//
// reformat (stripCharsNotInBag ("123 456 7890", digits),
//           "(", 3, ") ", 3, "-", 4)

function reformat (s) {

	var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


/* FUNCTIONS TO NOTIFY USER OF INPUT REQUIREMENTS OR MISTAKES. */

// Display prompt string s in status bar.

function prompt (s) {
	window.status = s
}



// Display data entry prompt string s in status bar.

function promptEntry (s) {
	window.status = pEntryPrompt + s
}



// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s) {
	theField.focus();
    alert(s);
    return false
}



// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.

function warnInvalid (theField, s) {
	theField.focus()
    theField.select()
    alert(s)
    return false
}



function getFormElements(vFormName) {

	x = 'Elements in ' + vFormName + '\n';
	y = '';
	s = '';

	for (i=0; i < vFormName.elements.length; i++) {

		y = vFormName.elements[i].name + '';

		if (y != '') {
			s = y.substr(0,3);
		}

		//if (s == 'txt') {
			x += 'Element ' + i + ' is ' + y + '\n';
		//}

	}

	return x;

}

/**--------------------------
//* Validate Date Field script- By JavaScriptKit.com
//* For this script and 100s more, visit http://www.javascriptkit.com
//* This notice must stay intact for usage
---------------------------**/

function checkIfValidDate(input) {
	// var validformat=/^\d{4}\/\d{2}\/\d{2}$/ //Basic check for format validity
	var validformat=/^\d{4}\-\d{2}\-\d{2}$/ //Basic check for format validity
	
	if (!validformat.test(input)) {
		
		//alert("Invalid Date Format. Please correct and submit again.")
		return false;

	} else { //Detailed check for valid date ranges
		
		var yearfield=input.split("-")[0]
		var monthfield=input.split("-")[1]
		var dayfield=input.split("-")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
			//alert("Invalid Day, Month, or Year range detected. Please correct and submit again.")
			return false;
		} else {
			//alert ('Correct date');
			return true;
		}
	}

}

/*
	Gmap obeck highlight on mouse over functions
*/

function showHint (i, top) {
	
	element = document.getElementById('show_hide');
	element.style.top = parseInt(top) + i*150 + 'px';	
	element.style.display = 'block';
	
	document.getElementById('panel1_c').style.left = '100px';
	document.getElementById('panel1_c').style.top = '0px';
	
	if (_markerObjects[i].lat == '' || _markerObjects[i].lng == '') {
	
		document.getElementById('map_bbl').innerHTML = '<img src="http://www.manhattan-buildings.com/images/nomap.gif" />';
		return;
	}
		
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById('map_bbl'));
		geocoder = new GClientGeocoder();
		var centerPoint = new GLatLng(_markerObjects[i].lat, _markerObjects[i].lng);
		map.setCenter(centerPoint, 15);
		// map.addControl(new GLargeMapControl());
		// map.addControl(new GMapTypeControl());
		
		// Types: G_SATELLITE_TYPE, G_HYBRID_TYPE, G_MAP_TYPE
		map.setMapType(G_NORMAL_MAP);
		
		// Create our marker icon
		var tregnyIcon = new GIcon();
		tregnyIcon.image = iconUrl;
		tregnyIcon.shadow = iconShadowUrl;
		tregnyIcon.iconSize = new GSize(18, 37);
		tregnyIcon.shadowSize = new GSize(27, 37);
		tregnyIcon.iconAnchor = new GPoint(6, 20);
		tregnyIcon.infoWindowAnchor = new GPoint(5, 1);

		
		// Set up our GMarkerOptions object
		markerOptions = { icon:tregnyIcon };

		//Drow building markers at the map

		var point = new GLatLng(_markerObjects[i].lat, _markerObjects[i].lng);
		var marker = new GMarker(point, markerOptions);
		// addEachListener(marker, i);
		map.addOverlay(marker);

	}
}

function hideHint() {

	element = document.getElementById('show_hide');
	element.style.display = 'none';
}






