//Event.observe($('anchorAerialVideo'), 'click', fnShowVideo, false);

function fnShowRefineSearch(divId,divButton){

		new Effect.BlindDown(divId,{duration:0.8});
		//if(divButton)
		//$(divButton).hide();
		return false;
				
	}
function fnClose(divId,divButton)
	{
		new Effect.BlindUp(divId,{duration:0.5}); 
		if(divButton)
		$(divButton).show();
		return false;
	}
function fnShowVideo(url)
	{
		window.open(url,'name','height=700,width=800,scrollbars=yes,location=no ');
	}
function fnShowFlashGallery(flashURL)
	{
		window.open(flashURL,'name','height=700,width=800,scrollbars=yes,location=no ');
	}
	


 function getHTTPObject()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlhttp;
}
var  http2 = getHTTPObject();

                       
function handleHttpResponse() 
{
     //Show Adding images
    if (http2.readyState == 4 )
    {
	if(document.getElementById('featured'))
       document.getElementById('featured').innerHTML = http2.responseText;
    }  
}

//if(document.getElementById('featured'))
   

function swapSelect(from,to,all)
{

    var from  = document.getElementById(from);             
    var to  = document.getElementById(to);             
    
    var len = from.options.length;
    for(i=0;i<=(len);i++)    
    {
        if(from.options[i])
        {

        if(from.options[i].selected)
        {    
 
            var opt = document.createElement('option');
            opt.text = from.options[i].text;
            opt.value = from.options[i].value;
            opt.selected =true;
           var OptOld = to.options.lengths  ;  

           try {
              to.add(opt, OptOld); // standards compliant; doesn't work in IE
            }
            catch(ex) {
              to.add(opt, OptOld); // IE only
            }
            
            from.remove(i);
            if(i>0){
           
            }
             i--;    
        }
        }
    }   
  sortlist(to);
}


function fnShowMap(divId,divButton){ if(document.getElementById(divId).style.display == 'none') { new Effect.SlideDown(divId,{duration:0.8}); return false; } else { new Effect.SlideUp(divId,{duration:0.5}); } }

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function validatePwd() {
var invalid = ""; // Invalid character is a space
var minLength = 6; // Minimum length
var pw1 = $("password1").value;
var pw2 = $("password2").value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}
// check for minimum length
if (pw1.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for spaces
/*if (pw1.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else*/ {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}
else {
//alert('Nice job.');
return true;
      }
   }
}

function validateText(txt) {
if(trim(txt) =="")  return false;
}




/*
	Password Validator 0.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/

function validatePassword (pw, options) {
	// default options (allows any password)
	var o = {
		lower:    0,
		upper:    0,
		alpha:    0, /* lower + upper */
		numeric:  0,
		special:  0,
		length:   [6, Infinity],
		custom:   [ /* regexes and/or functions */ ],
		badWords: [],
		badSequenceLength: 0,
		noQwertySequences: false,
		noSequential:      false
	};

	for (var property in options)
		o[property] = options[property];

	var	re = {
			lower:   /[a-z]/g,
			upper:   /[A-Z]/g,
			alpha:   /[A-Z]/gi,
			numeric: /[0-9]/g,
			special: /[\W_]/g
		},
		rule, i;

	// enforce min/max length
	if (pw.length < o.length[0] || pw.length > o.length[1])
		return false;

	// enforce lower/upper/alpha/numeric/special rules
	for (rule in re) {
		if ((pw.match(re[rule]) || []).length < o[rule])
			return false;
	}

	// enforce word ban (case insensitive)
	for (i = 0; i < o.badWords.length; i++) {
		if (pw.toLowerCase().indexOf(o.badWords[i].toLowerCase()) > -1)
			return false;
	}

	// enforce the no sequential, identical characters rule
	if (o.noSequential && /([\S\s])\1/.test(pw))
		return false;

	// enforce alphanumeric/qwerty sequence ban rules
	if (o.badSequenceLength) {
		var	lower   = "abcdefghijklmnopqrstuvwxyz",
			upper   = lower.toUpperCase(),
			numbers = "0123456789",
			qwerty  = "qwertyuiopasdfghjklzxcvbnm",
			start   = o.badSequenceLength - 1,
			seq     = "_" + pw.slice(0, start);
		for (i = start; i < pw.length; i++) {
			seq = seq.slice(1) + pw.charAt(i);
			if (
				lower.indexOf(seq)   > -1 ||
				upper.indexOf(seq)   > -1 ||
				numbers.indexOf(seq) > -1 ||
				(o.noQwertySequences && qwerty.indexOf(seq) > -1)
			) {
				return false;
			}
		}
	}

	// enforce custom regex/function rules
	for (i = 0; i < o.custom.length; i++) {
		rule = o.custom[i];
		if (rule instanceof RegExp) {
			if (!rule.test(pw))
				return false;
		} else if (rule instanceof Function) {
			if (!rule(pw))
				return false;
		}
	}

	// great success!
	return true;
}


function sortlist(lb) {
//var lb = document.getElementById('mylist');
arrTexts = new Array();

for(i=0; i<lb.length; i++)  {
  arrTexts[i] = lb.options[i].text;
}
 

arrTexts.sort();

for(i=0; i<lb.length; i++)  {
  lb.options[i].text = arrTexts[i];
  lb.options[i].value = arrTexts[i];

}
if(lb.options[0]) {
lb.options[0].selected =true;
}
}


function resetSelect(name)
{
    var ele = document.getElementById(name);
    if(ele)
    {
            for(i=0;i<=ele.options.length-1;i++)
            {
                if(ele.options[i])
                {       
                    ele.options[i].selected = false;
                }
            }
    }
}
