// JavaScript Document

function openWindow(url) {
  popupWin = window.open(url,'new_page','width=400,height=400')
}
function openWindow2(url) {
  popupWin = window.open(url,'new_page','width=400,height=480')
}
function openWindow3(url) {
  popupWin = window.open(url,'new_page','width=400,height=450,scrollbars=yes')
}
function openWindow4(url) {
  popupWin = window.open(url,'new_page','width=400,height=525')
}
function openWindow5(url) {
  popupWin = window.open(url,'new_page','width=450,height=525,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes')
}
function openWindow6(url) {
  popupWin = window.open(url,'new_page','width=550,height=525,scrollbars=yes,resizable=yes')
}

function jumpToPage(s) {if (s.selectedIndex != -1) top.location.href = s.options[s.selectedIndex].value;return 1;}

if( top.parent.frames.length > 0)
top.parent.location.href=self.location.href;

/* ********** some hide/show script ********************************** */
  var mmImages = new Array(2);

  mmImages[0] = "Themes/Standard/icon_max.gif";
  mmImages[1] = "Themes/Standard/icon_min.gif";

  for (i=0; i < mmImages.length; i++) {
    var preload = new Image();
    preload.src = mmImages[i];
  }
  
function swap(imgID,img) {
 document[''+imgID+'Img'].src = mmImages[img];
 if(document[''+imgID+'Img'].alt != "Collapse" ){
	document[''+imgID+'Img'].alt = "Collapse";
 }else{
	document[''+imgID+'Img'].alt = "Expand";
 }
}
// forum min/max function
function mwpHS(obj,idd,tagg){
	if(document.getElementById){
	var ar = document.getElementById(obj).getElementsByTagName(tagg);
	var cook = "MWP211xyzAGhide";
	var clsNam = obj + idd;
		for (var i=0; i<ar.length; i++){
		  if(ar[i].id==clsNam){
			if(ar[i].style.display != "none"){
				swap(clsNam,0);
				ar[i].style.display = "none";
				setCookieSubKey(cook,clsNam,"1");
			}else{
				swap(clsNam,1);
				ar[i].style.display = "";
				setCookieSubKey(cook,clsNam,"0");
			}
		  }
		} 
	}
}
//themebox min/max
function mwpHSx(obj){
  if(document.getElementById){
	var ele = document.getElementById(obj);
	var cook = "MWP211xyzAGhide";
	if(ele.style.display != "none"){
		swap(obj,0);
		ele.style.display = "none";
		setCookieSubKey(cook,obj,"1");
	}else{
		swap(obj,1);
		ele.style.display = "block";
		setCookieSubKey(cook,obj,"0");
	}
  }
}

var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

//simple hide/show
function mwpHSs(obj,typ){
	// Netscape 4
	if(ns4){
		if (document.layers[obj]){
			if (document.layers[obj].visibility != "hide"){
				document.layers[obj].visibility = "hide";
			}else{
				document.layers[obj].visibility = "show";
			}
		}
	}
	// Explorer 4
	else if(ie4){
	  if (document.all[obj]){
		if (document.all[obj].style.visibility != "hidden"){
		  document.all[obj].style.visibility = "hidden";
		}else{
		  document.all[obj].style.visibility = "visible";
		}
	  }
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		if (document.getElementById(obj)){
			var ela = document.getElementById(obj)
			//for (var i=0; i<el.length; i++){
				if (ela.style.display != "none"){		
				  if(typ != 1){
					swap(obj,0);
				  }
				  ela.style.display = "none";
				}else{
				  if(typ != 1){
				    swap(obj,1);
				  }
				  ela.style.display = "block";
				}
			//}
		}
	}
}

// ++++++++++++++++++++++++ Cookie code +++++++++++++++++++++++++
    function setCookie(cname,value) {
	var timeout=60*60*24;
	var today = new Date();
	var the_date = new Date();
	the_date.setTime(today.getTime() + 1000 * timeout);
	var the_cookie_date = the_date.toGMTString();
	var the_cookie = cname +"="+value;
	var the_cookie = the_cookie + ";expires=" + the_cookie_date;
    document.cookie= the_cookie; 
    //E.g. setCookie("name1","dogg")
	}

    function getCookie(name) {
    	//alert(getCookie("name1"));
    	var result = ""; 
    	var myCookie = " " + document.cookie + ";";
    	var searchName = " " + name + "=";
    	var startOfCookie = myCookie.indexOf(searchName); 	
    	var endOfCookie; 
		if (startOfCookie != -1) {
        		startOfCookie += searchName.length; 
        		endOfCookie = myCookie.indexOf(";", startOfCookie); 
        		result = unescape(myCookie.substring(startOfCookie, endOfCookie)); 
        }
        	return result; 
    }
    //get multi value cookie value e.g. 
    //     Person=name=dogg&age=25;
    function getCookieSubKey(cookiename,cookiekey) {
        var cookievalue=getCookie(cookiename);
        if ( cookievalue == "")  return "";
        cookievaluesep=cookievalue.split("&");
        	for (c=0;c<cookievaluesep.length;c++)	{
            	cookienamevalue=cookievaluesep[c].split("=");
            	if (cookienamevalue.length > 1) {  //it has multi valued cookie
					if ( cookienamevalue[0] == cookiekey )
						return cookienamevalue[1].toString();			
                }
                else		
                	return "";		
            }	
    	return "";
	}
    //set multi value cookie value e.g. 
    //     Person=name=dogg&age=25;
	function setCookieSubKey(cookiename,cookiekey,cookiekeyvalue){
		var cookievalue=getCookie(cookiename);
        if ( cookievalue.trim() == "" ){
        	setCookie(cookiename,cookiekey+"="+cookiekeyvalue);
            return;
        }		
        //check if cookie already exist
        getcookiekeyvalue=getCookieSubKey(cookiename,cookiekey);
        newCookieValue=cookievalue.trim();
        if ( getcookiekeyvalue == "")	//key cookie never exist		
        	newCookieValue += "&" + cookiekey + "=" + cookiekeyvalue;
        else
		{
        	if ( newCookieValue.substr(0,cookiekey.length+1) == (cookiekey + "=") ) {  //Check if at first location . no beginning with &
		  	//pick rest keys = keylength+equalsign+cookiekeyvalue+nextampesand
             totalcookiekeylength=cookiekey.length+1+getCookieSubKey(cookiename,cookiekey).length+1;
             newCookieValue = newCookieValue.substr(totalcookiekeylength);
             if (newCookieValue.trim() == "")			
                newCookieValue = cookiekey + "=" + cookiekeyvalue;
             else
                newCookieValue += "&" + cookiekey + "=" + cookiekeyvalue;
           }
           else 
		   {
          	  fullcookiekey="&"+cookiekey+"="+getcookiekeyvalue;
              if ( newCookieValue.indexOf(fullcookiekey) != -1 ) //cookie key inside the cookie value
			  {
              	  newCookieValue = ReplaceAll(newCookieValue, fullcookiekey, "");
                  if (newCookieValue.trim() == "")			
                      newCookieValue = cookiekey + "=" + cookiekeyvalue;
                  else
                      newCookieValue += "&" + cookiekey + "=" + cookiekeyvalue;
               }
            }
		}
        setCookie(cookiename,newCookieValue);
	}
	//Replace all given string from a string
	//
	function ReplaceAll(varb, replaceThis, replaceBy){	
    	newvarbarray=varb.split(replaceThis);
        newvarb=newvarbarray.join(replaceBy);	
        return newvarb;
	}
	
	String.prototype.trim = function(){
    // Use a regular expression to replace
    //      leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
    }
// +++++++++ End Cookie code +++++++++++++++++++++++++++++++++++++++++++++++++

// ------------functions for codebox mod
function expand(el){
var id1='thecode'+el;
var codebox=document.getElementById(id1);
var txttype='firefox';
var scheight = codebox.scrollHeight +10
if (txttype=='opera') {
    codebox.style.height='100%';}
else if (txttype=='ie') {
    codebox.style.height=scheight+'px';
    codebox.style.overflowX='auto';
    codebox.style.overflowY='auto';}
else {
codebox.style.height=scheight+'px';
codebox.style.overflow='visible';}
}

function contract(el){
var id1='thecode'+el
var codebox=document.getElementById(id1)
codebox.style.height=45+'px'
codebox.style.overflow='auto';
}

// code selector
function selectCode(el){
var codebox=eval('document.selectcode'+el+'.thecode'+el)
codebox.focus();
codebox.select();
}
function dohelp(){
// Help Code Popup
var doPopUpHelpCodeX = (screen.width/2)-110;
var doPopUpHelpCodeY = (screen.height/2)-150;
var pos = "left="+doPopUpHelpCodeX+",top="+doPopUpHelpCodeY;
doPopUpHelpCodeWindow = window.open("code_help.asp","HelpCode","width=220,height=325,"+pos);
}
// ------------------ end codebox code


// RHDF Additions

function showHide(obj) {

 
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function openWindowPager(url) {
  popupWin = window.open(url,'pager','resizable,width=210,height=310,left=10,top=75,scrollbars=auto')
}
function openWindowPager1(url) {
  popupWin1 = window.open(url,'pager','resizable,width=710,height=410,left=10,top=75,scrollbars=auto')
}
