

function changeRightTitle(changeTo, Name) {//debugger;//Ed L.
	//*****************************************
	//used to update the image in the hdr.asp page for the right frame to show appropriate function
	//*****************************************
	 
	var hWindow = parent.parent.frames['top_header'];	

	if (changeTo == 'Calc') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_Calc.gif" align="middle"><strong> ' + Name + '</strong>';
	}
	if (changeTo == 'Dig') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_dig.gif" align="middle"><strong> ' + Name + '</strong>';
	}
	if (changeTo == 'Image') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/title_illustration.gif" align="middle">';
	}
	if (changeTo == 'Notes') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_notes.gif" align="middle"><strong> ' + Name + '\'s notes</strong>';
	}
	if (changeTo == 'EditNotes') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_notes.gif" align="middle"><strong> ' + Name + ' Note</strong>';
	}
	if (changeTo == 'AFib') {
		parent.frames['right'].location.pathname = '/notesAFib.asp';
	}
	if (changeTo == 'Quicklinks') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src="images/title_quicklinks.gif" align="middle">';
	}
	if (changeTo == 'WoundChart') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_Calc.gif" align="middle"><strong> ' + Name + '</strong>';
	}
	if (changeTo == 'Cme') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_question.gif" align="middle"><strong> ' + Name + '</strong>';
	}
	if (changeTo == 'NCLEX') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/nav_question.gif" align="middle"><strong> ' + Name + '</strong>';
	}
	if (changeTo == 'IV') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<img src = "images/iv_drip.gif" align="middle"><strong> ' + Name + '</strong>';
	}
	if (changeTo == 'DIGIV') {
		hWindow.document.getElementById('RightHdrCol').innerHTML = '<strong> ' + Name + '</strong>';
	}

}

function gotoLocation(target_anchor) {
	//*****************************************
	//used by Quicklinks page...
	//this will accept the "target_anchor" or named anchor tag 
	// to jump to in the main frame and direct it there...
	// if there is already an anchor loaded, it strips it off before adding this one on
	//*****************************************
	var location;
	var ptrBookmark;
	
	location = parent.frames['main_top'].location.href;
	ptrBookmark = location.indexOf('#');
	if (ptrBookmark > 0) {
		location = location.substring(0,ptrBookmark);
	}
	parent.frames['main_top'].location.href = location + '#' + target_anchor;			
}

function goBack(target_frame) {
	//*****************************************
	//used to go back in the main frame when user clicks the back arrow nav bar button
	// instead of just defaulting to going back in another frame (i.e. calc or notes) it should 
	// target the main frame and go back only in that frame - 
	// this is apparently not working properly though because it doesn't only go back in the main frame
	//*****************************************
	//first pop off the current page we are on
	try
	{
		var loc1 = parent.frames['top_header'].historyStack.pop();
	
		//now pop off the page we want to go to (it will be added back to the stack in the onLoad event of the page once it is called)
		var loc2 = parent.frames['top_header'].historyStack.pop();
		while (loc2.indexOf('javascript') !=-1)
		{
			loc2 = parent.frames['top_header'].historyStack.pop();
		}

		if (loc2 == 'undefined') 
		{
			alert('undefined');
			parent.frames[target_frame].location.href = loc1;
		}
		else 
		{
			if(loc2.indexOf('fl=') ==-1)
			{
				var temp = new Array();
				temp = loc2.split('?');
				loc2 = temp[0] + '?fl=1&'+temp[1];
			}

			parent.frames[target_frame].location.href = loc2;
		}
	
	}
	catch(e)
	{
		
	}

}

function pageClick(location) {
	//must append this location to the historyStack because it is an internal page link and won't fire the onLoad event again
	parent.frames['top_header'].historyStack.push(location);
	return true;	//allow the click to continue processing
}

function gotoTop(target_frame) {
	//*****************************************
	//used to go to top of page in main window when user clicks the up arrow nav bar button
	//*****************************************
	var location;
	var ptrBookmark;
	
	location = parent.frames[target_frame].location.href;
	ptrBookmark = location.indexOf('#');
	if (ptrBookmark > 0) {
		location = location.substring(0,ptrBookmark);
	}
	parent.frames[target_frame].location.href = location;			
}

	//preload the swap image for the notes
	myImage = new Image();
    myImage.src = '/images/minus.gif';

function toggleNoteSection(Name, SwapImage){

    var currentElement = document.getElementById(Name);   //get a handle to the object we are hiding/showing
	var currentImage = document.getElementById(SwapImage); 
    
    if (Name != '') {  //as long as a user passes in a name
        if (currentElement.style.display == 'none') {  //if item is currently hidden, show it
            currentImage.src=myImage.src;
            currentElement.style.display = '';          
        } 
        else {  //item is currently being shown, lets hide it
            currentElement.style.display = 'none'; 
            currentImage.src='/images/plus.gif'
        } 
    }
}

function toggleSection(Name) { 
	//*****************************************
	// HTML OBJECTS WE ARE HIDING OR SHOWING, CAN BE TABLE, TR, DIV, ECT....
	// <tr id="nav1" style="position:relative; display:none;"> <!-- the style starts it off as hidden -->
	//*****************************************
    var currentElement = document.getElementById(Name);   //get a handle to the object we are hiding/showing
    if (Name != '') {  //as long as a user passes in a name
        if (currentElement.style.display == 'none') {  //if item is currently hidden, show it
            currentElement.style.display = ''; 
        } 
        else {  //item is currently being shown, lets hide it
            currentElement.style.display = 'none'; 
        } 
    } 
}

function CleanXMLText(strToClean) {
	var ret_str = '' + strToClean;
	ret_str = ret_str.replace(/\&/g, '&amp;');
	ret_str = ret_str.replace(/</g, '&lt;');
	ret_str = ret_str.replace(/>/g, '&gt;');
	ret_str = ret_str.replace(/\"/g, '&quot;');
    return ret_str; 
}

function RefreshNotes(){
var RightFrameHref = parent.frames[4].location.href.toLowerCase();
if  (RightFrameHref.indexOf('notes') > -1){
	parent.frames[4].location.href = '/Notes/ViewNotesFrame.aspx';
	}
}

function RefreshQuicklinks(){
	var sLinks = '';
	for (var i=0; i<arguments.length; i++) {
		sLinks += arguments[i];
	}
	parent.frames[4].location.href = '/Quicklinks.aspx?' + sLinks;
}

function loadPage() {

	if (top == self || (parent.frames[1].name != 'bottom'))
    top.location.href = 'http://www.pepidonline.com';

	parent.frames['top_header'].historyStack.push(parent.frames['main_top'].location.href);
	var sLinks = '';
	for (var i=0; i<arguments.length; i++) {
		sLinks += arguments[i];
	}
	parent.frames[4].location.href = '/Quicklinks.aspx?' + sLinks;
}

//This makes sure the current page is the parent
function FrameParentCheck() {
		var TopFrame = (top == self);
		if (!TopFrame) top.location.href = document.location.href;
 }
 
 function getDetail(I_ID, S_ID, SC_ID, O_ID, OC_ID) {
	document.getElementById('hdnI_ID').value = I_ID;
	document.getElementById('hdnS_ID').value = S_ID;
	document.getElementById('hdnSC_ID').value = SC_ID;
	document.getElementById('hdnO_ID').value = O_ID;
	document.getElementById('hdnOC_ID').value = OC_ID;
	document.forms['frmDIGList'].submit();
}

function Trim(trim_str) {
	if (trim_str.length < 1) {
        return '';
	}
    trim_str = RTrim(trim_str);
    trim_str = LTrim(trim_str);
    return trim_str;
}


function RTrim(trim_str) {
    var temp_str = '';

    if (trim_str.length < 1) {
        return '';
    }
    var iLen = trim_str.length - 1;

    while(iLen > -1) {
        if (trim_str.charAt(iLen) != String.fromCharCode(32)) {
            temp_str = trim_str.substring(0, iLen + 1);
            break;
        }
        iLen--;
    }
    return temp_str;
}

function LTrim(trim_str) {
    if (trim_str.length < 1) {
        return '';
    }
    var temp_str = '';
    var iLen = 0;

    while (iLen < trim_str.length) {
        if (trim_str.charAt(iLen) != String.fromCharCode(32)) {
            temp_str = trim_str.substring(iLen, trim_str.length);
			break;
        }
        iLen++;
    }
    return temp_str;
}

function PopupCentered(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops);
	//win.window.focus(); 
}

function SendInfo(form){
	PopupCentered('SendEmail.aspx?answer='+form.Answer[0].checked+'&email='+form.txtEmail.value+'&comments='+form.txtComments.value,'name','400','200','no');
}
