function selectDropDown(dropDownId,value) {
    var dropdown = document.getElementById(dropDownId);
    for (var f = 0; f < dropdown.length; f++) {
        //debugger;
        if (dropdown.options[f].value == value) {
            
            dropdown.options[f].selected = true;
        }
    }
    
}
function getQueryString(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
    //alert('Query Variable ' + variable + ' not found');
} 


showVideo = function(params) {
var controlBarHeight = 25;
    
    var filename = params.filename;
    if (filename == null) {
        var guid = params.guid;
        var ext = params.ext;
        filename = guid + '.' + ext;
    }
    var title = params.title;
    if (title === undefined)
        title = " ";

    var width = params.width;
    var height = params.height;
    if (width == null)
        width = 480;
    if (height == null)
        height = 384 - controlBarHeight;


    var lightWindowOptions = {hideGalleryTab : false,
showGalleryCount : true,
        skin: {
            main: '<div id="lightwindow_container" >' +
                '<div id="lightwindow_title_bar" >' +
                    '<div id="lightwindow_title_bar_inner" >' +
                        '<span id="lightwindow_title_bar_title"></span>' +
                        '<a id="lightwindow_title_bar_close_link" >close</a>' +
                    '</div>' +
                '</div>' +
                '<div id="lightwindow_stage" >' +
                    '<div id="lightwindow_contents" >' +
                    '</div>' +
                    '<div id="lightwindow_navigation" >' +
                        '<a href="#" id="lightwindow_previous" >' +
                            '<span id="lightwindow_previous_title"></span>' +
                        '</a>' +
                        '<a href="#" id="lightwindow_next" >' +
                            '<span id="lightwindow_next_title"></span>' +
                        '</a>' +
                        '<iframe name="lightwindow_navigation_shim" id="lightwindow_navigation_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>' +
                    '</div>' +
                    '<div id="lightwindow_galleries">' +
                        '<div id="lightwindow_galleries_tab_container" >' +
                            '<a href="#" id="lightwindow_galleries_tab" >' +
                                '<span id="lightwindow_galleries_tab_span" class="up" >Galleries</span>' +
                            '</a>' +
                        '</div>' +
                        '<div id="lightwindow_galleries_list" >' +
                        '</div>' +
                    '</div>' +
                '</div>' +
                '<div id="lightwindow_data_slide" >' +
                    '<div id="lightwindow_data_slide_inner" >' +
                        '<div id="lightwindow_data_details" >' +
                            '<div id="lightwindow_data_gallery_container" >' +
                                '<span id="lightwindow_data_gallery_current"></span>' +
                                ' of ' +
                                '<span id="lightwindow_data_gallery_total"></span>' +
                            '</div>' +
                            '<div id="lightwindow_data_author_container" >' +
                                'by <span id="lightwindow_data_author"></span>' +
                            '</div>' +
                        '</div>' +
                        '<div id="lightwindow_data_caption" >' +
                        '</div>' +
                    '</div>' +
                '</div>' +
            '</div>',
            loading: '<div id="lightwindow_loading" >' +
            //'<img src="images/ajax-loading.gif" alt="loading" />'+
            //'<span>Loading or <a href="javascript: myLightWindow.deactivate();">Cancel</a></span>'+
            //'<iframe name="lightwindow_loading_shim" id="lightwindow_loading_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
                '</div>',
            iframe: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' +
                '<html xmlns="http://www.w3.org/1999/xhtml">' +
                    '<body>' +
                        '{body_replace}' +
                    '</body>' +
                '</html>',
            gallery: {
                top: '<div class="lightwindow_galleries_list">' +
                        '<h1>{gallery_title_replace}</h1>' +
                        '<ul>',
                middle: '<li>' +
                                '{gallery_link_replace}' +
                            '</li>',
                bottom: '</ul>' +
                   '</div>'
            }
        }
    };
    var lightwindow1 = new lightwindow(lightWindowOptions);
    lightwindow1.activateWindow(
		{
		    href: '/_framework/modules/gallery/playvideo.asp?filename=' + filename + '&width=' + width + '&height=' + height,
		    title: title,
		    width: width + 2,
		    height: height + 2 + controlBarHeight,
		    method: 'get'
		}
	);
}





	function numChecked(theform){
		
		var numchecked=0;
		for( var i = 0; i < theform.elements.length; i++ ){ 	   
		  
		   if (theform.elements[i].type=='checkbox'){
				if(theform.elements[i].checked==true){
					numchecked++;
				}
		   }
		}	
		
		return numchecked;
	}

	
	
	function toggleCheckBoxes(theform){
		var numcheckboxes=0;
		var numchecked=0;
		var el;
		for( var i = 0; i < theform.elements.length; i++ ){ 	   
		   if (theform.elements[i].type=='checkbox'){
		   		numcheckboxes++;
				if(theform.elements[i].checked==true){
					numchecked++;
				}
		   }
		}
		 
		for( var i = 0; i < theform.elements.length; i++ ){
			 if (theform.elements[i].type=='checkbox'){
			 	el=theform.elements[i];
				if(numchecked>=numcheckboxes/2){
					el.checked=false;
				}
				else
				{
					el.checked=true;
				}
			 }
			
		}	   
		   	
	}





	
	function togglePassword(pwtobj, pwobj, alink){

		if (pwtobj.style.display=='none'){
			pwtobj.style.display='block';
			pwobj.style.display='none';
			if(document.all){
				 alink.innerText = "Show";
			} else{
				alink.textContent = "Show";
			}			
			
		}
		
		
		else{
			pwobj.style.display='block';
			pwtobj.style.display='none';
			if(document.all){
				 alink.innerText = "Hide";
			} else{
				alink.textContent = "Hide";
			}	
		}
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}



function validateemail (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   return false
}

// If we've gotten this far, everything's valid!
return true;
}



