
//v1.1.0.2 by PVII-www.projectseven.com

function P7_ExpMenu()
{ 
 if(navigator.appVersion.indexOf("MSIE")==-1)
 {
    return;
 }
 var i; // UL counter
 var k; // LI counter
 var g; // UL object
 var lg; // LI object collection
 var r=/\s*p7hvr/; // regex for finding the p7hvr class
 var nn=''; // Used for nexted UL's (headernav->headernav1->headernav2)
 var c; // used in the function creation? 
 var cs='p7hvr'; // p7hvr class that gets appended to the UL
 var bv='headernav'; // UL name
 
 for( i=0; i<10; i++)// aparent limit of 10 nested levels
 {
    g=document.getElementById(bv+nn); //getting the UL
    if(g)// making sure we have a UL
    {
        lg = g.getElementsByTagName("LI");//get the child LIs
        if(lg) // make sure we have LIs
        {
            for( k = 0; k < lg.length; k++)// loop through the LIs
            {
                lg[k].onmouseover = function()
                    {
                        c = this.className;
                        cl = (c)?c+' '+cs:cs; //cs = p7hvr, basicly adding onto the assigned class (classname p7hvr)
                        this.className=cl;
                    };
                 lg[k].onmouseout = function()
                    {
                        c=this.className;
                        this.className=(c)?c.replace(r,''):''; // removing the p7hvr class (r is regex to match p7hvr)
                    };
              }
        }
    }
    nn=i+1; // update nn to loop through the next layer of nested ULs
 }
}

function populateFields(chkThis, frmThis, arFieldsFrom, arFieldsTo){
	var i, j;
	var fefrom;
	var feto;
	var fetorep;
	
	if (chkThis.checked){
		for (i=0; i < arFieldsFrom.length; i++){
			if(frmThis[arFieldsTo[i]]) {
				fefrom = frmThis[arFieldsFrom[i]];
				feto = frmThis[arFieldsTo[i]];
				if (fefrom.tagName.toLowerCase() == "select" && feto.tagName.toLowerCase() == "select") {
					feto.options.length = 1;
					
					for (j=1; j < fefrom.options.length; j++) {
						fetorep = feto.options.add ? feto.options : feto;
						fetorep.add(document.createElement("option"));
						feto.options[feto.options.length-1].value = fefrom.options[j].value;
						feto.options[feto.options.length-1].text = fefrom.options[j].text;
					}
					feto.selectedIndex = fefrom.selectedIndex;
				} else {
					frmThis[arFieldsTo[i]].value = frmThis[arFieldsFrom[i]].value;
				}
			}
		}
	}else{
		for (i=0; i < arFieldsFrom.length; i++){
			if(frmThis[arFieldsTo[i]])
				frmThis[arFieldsTo[i]].value = '';
		}
	}
}



//JONK's getAcuElementById------
// some browser sniffing:
document.version = parseFloat(navigator.appVersion);
document.hostApplication = navigator.appName.substring(0,3);
document.browserClass = parseInt(document.version);
			
if(document.browserClass < 4) 
{
 // redirect -- no CSS support
 // if you used &lt;script language=javascript1.2&gt; 
 // this won't be necessary
 // ALL this code will be ignored!
}
else      // isolate this setup from "modern" browsers!!
if(document.browserClass == 4) // might need to check NN5 browsers as well
{

	if(document.hostApplication == "Net") // got netscape?
	{
		  // need to "fake" the style attribute
		  // so we add a little misdirection
		  // by creating an object that will
		  // intercept the property setting.
		  // we make NN think it's setting properties 
		  // in A style object, when it is actually
		  // redirected to set the property to the actual layer
		   // and you might have thought it couldn't be done...
		 function _style()
		 {
		  this.layerRef = null;    // this will be set when <B style="COLOR: black; BACKGROUND-COLOR: #ffff66">getElementByID</B> is called

		  /* we don't actually need these -- it's just pseudocode
		  this.visibility = "";
		  this.top = 0;
		  this.left = 0;
		  */
						   
		   // very cool method in NN (only) -- 
		   // since these aren't "real" object properties
		   // it's more like a watchdog
		   // for more info -- check Netscape's docs
		  this.watch("visibility", 
		     function(id, old, nval) 
		      {  // set the "real" property of the layer here
		       eval("this.layerRef." + id + " = '" + nval + "'");
		       return nval; });
		        // you must return either old or nval
		  this.watch("top",
		     function(id, old, nval) {
		       eval("this.layerRef." + id + " = '" + nval + "'");
		      return nval;});
		  this.watch("left",
		     function(id, old, nval) {
		       eval("this.layerRef." + id + " = '" + nval + "'");
		      return nval;});
						  
		   // note: all the inline functions are exactly the same
		   //  you can cut'n'paste for each property you need to watch!
		}

	 // here we set up the "appearance" of a style property

	 Layer.prototype.style = new _style();
	  // each time a new layer is created, a new _style() object
	  // is attached to it
				    
	} // end if NN

	 // here, getElementById is getting declared by BOTH IE4 and NN4 browsers
	document.getAcuElementById = function(name)
	{
		if(document.hostApplication == "Net") // netscape 4
		{
			if (document.browserClass == 4){
				var lyr = eval("document." + name);
						   
			 // only need to do this once, but
			 // what the hey...
			 if(lyr.style != null) lyr.style.layerRef = lyr;
								    
			return lyr;
			}else{
				return document.layers('" + name + "');
			}
		}
		  else // IE
		  {
			return eval("document.all." + name);
		  }
  }
}else // end browserClass == 4
	{
	if(document.hostApplication == "Net"){
		document.getAcuElementById = function(name){
				if(!eval("document." + name)){
					return document.getElementById(name);
				}else{
					return eval("document." + name);
				}
			}
	}else
	{
		document.getAcuElementById = function(name){
				return document.getElementById(name);
			}
	}
}
//END JONK's getAcuElementById---------

function showHideDisplay(obj) {
	if (typeof(obj) == "string") obj = $(obj);
	if (obj) 
	{
	  if (getStyleByObj(obj, "display") == "none") 
	  {
	       obj.style.display = "block";
	  } else if (getStyleByObj(obj, "display") == "block") 
	  {
	       obj.style.display = "none";
	  }
		
	}
}

function bcnClickHandler()
{
    var params = new Hash();
    if(this.href)
    {
        params.exitlink = this.href;
    } 
    else 
    {
        params.exitlink='';
    }
    new Ajax.Request('/handlers/bcnexittracking-1.0.aspx',
        {
            method: 'post',
            parameters: params
        });

}

function addBookmark(userid, pageid)
{
    var params = new Hash();
    params.action = 'create';
    params.user = userid;
    params.pageid = pageid;
    params.title = document.title;
    params.location = window.location.href.substr(window.location.protocol.length + 2 + window.location.hostname.length);
    new Ajax.Request('/handlers/bookmark-1.0.aspx', 
        {
	        asynchronous: false,
	        parameters: params,
	        onSuccess: function(transport) { alert('Bookmark created'); }
        });
}
function deleteBookmark(userid, bookmarkid)
{
    var params = new Hash();
    params.action = 'delete';
    params.user = userid;
    params.bookmarkid = bookmarkid;
    new Ajax.Request('/handlers/bookmark-1.0.aspx', 
        {
	        asynchronous: false,
	        parameters: params,
	        onSuccess: function(transport) { alert('Bookmark removed'); window.location.href='?processor=asp&asp_processor=fourd&action=isloggedin'; }
        });
}

function directoryPreview(previewUrl){
   var win = new Window("Window Name", {className: "dialog", width:510, height:600, draggable:true, minimizable:false, maximizable:false, resizable:true, url: previewUrl, destroyOnClose:true});
   win.showCenter(true, 100);
}
function showPhotoWindow(photoid, pageid){
   var win = new Window(photoid, {className: "dialog", width:1000, height:500, draggable:true, minimizable:false, maximizable:true, resizable:true, url: "/?sectionpath=1&processor=content&p_prototype=prototype&pageid=" + pageid + "&photoid=" + photoid, destroyOnClose:true});
   win.showCenter(true, 100);
  }   
  
function showPhotoUpload(sectionpath, pageid, pp){
   var win = new Window("photoupload", {className: "dialog", width:800, height:600, draggable:true, minimizable:false, maximizable:true, resizable:true, url: "/site/components/filemanager/photogalleryuploader.aspx?sectionpath=" + sectionpath+ "&pageid=" + pageid + "&pp=" + pp, destroyOnClose:true});
   win.showCenter(true, 40);
  }   
  
function showPhotoUploadByPage(sectionpath, pageid, pp, sourcepageid){
   var win = new Window("photoupload", {className: "dialog", width:800, height:600, draggable:true, minimizable:false, maximizable:true, resizable:true, url: "/site/components/filemanager/photogalleryuploader.aspx?sectionpath=" + sectionpath+ "&pageid=" + pageid + "&pp=" + pp + "&sourcepageid=" & sourcepageid, destroyOnClose:true});
   win.showCenter(true, 40);
  } 
  
function addComment()
    {
        $('submitcomment').request({
           asynchronous: false,
            onSuccess: function(transport) { window.location.reload(); }
        });
    }    
    
function markComment(commentid)
    {
        if (confirm('Flagging this as inappropriate will alert staff to a potential problem.  It may take a few hours before can be reviewed.  Would you like to flag this as inappropriate?')){
        $('markcomment' + commentid).request({
           asynchronous: false,
            onSuccess: function(transport) { alert('This comment has been marked as inappropriate and will be reviewed.'); window.location.reload(); }
        });
        }
    }    
   
function showPageWindow(pageid){
   var win = new Window("pagewindow", {className: "dialog", width:1000, height:500, draggable:true, minimizable:false, maximizable:true, resizable:true, url: "/?sectionpath=1&p_prototype=prototype&pageid=" + pageid, destroyOnClose:true});
   win.showCenter(true, 100);
  }   

function checkAll(field)
{
    for (i = 0; i < field.length; i++)
	    field[i].checked = true ;
}

function setCookieValue(name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString() + '; path=/');
}
