function prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,systemextra)
{
	
	var objfrm=eval("document." + frmname);
	
	objfrm.elements["prth_act_"+objid].value=act;
	
	objfrm.elements["prth_orderby_"+objid].value=orderby;
	
	objfrm.elements["prth_cpage_"+objid].value=cpage;
	
	if(systemextra)
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;
		
	objfrm.submit();
}
var marked_row = new Array;
theDefaultStyleClass="gridrows";
thePointerStyleClass="gridrows_mouseover"; //mouseover
theMarkStyleClass="gridrows_mousedown"; //marking a row
function setPointer(theRow, theRowNum, theAction)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerStyleClass == '' && theMarkStyleClass == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        //currentColor = theCells[0].getAttribute('bgcolor');
		currentColor = theCells[0].className;
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].className;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultStyleClass.toLowerCase()) {
        if (theAction == 'over' && thePointerStyleClass != '') {
            newColor              = thePointerStyleClass;
        }
        else if (theAction == 'click' && theMarkStyleClass != '') {
            newColor              = theMarkStyleClass;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerStyleClass.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultStyleClass;
        }
        else if (theAction == 'click' && theMarkStyleClass != '') {
            newColor              = theMarkStyleClass;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkStyleClass.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerStyleClass != '')
                                  ? thePointerStyleClass
                                  : theDefaultStyleClass;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                //theCells[c].setAttribute('bgcolor', newColor, 0);
				theCells[c].className=newColor;
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                //theCells[c].style.backgroundColor = newColor;
				theCells[c].className=newColor;
            }
        }
    } // end 5

    return true;
} 
//Blank field validation

function NotBlank(obj,cap)
{
	if(obj)
	{
	    if(obj.value=="")
	    {
		    alert(cap + " is mandatory");
		    obj.focus();
		    return false;
	    }
	}
	return true;
}

function IsNumeric(obj,cap)
{
	if(isNaN(obj.value) || obj.value=="")
	{
		alert("Please Enter Valid " + cap);
		obj.focus();
		return false;
	}
	return true;
}

function IsDecimal(obj,cap)
{
	if(isNaN(obj.value) || obj.value=="")
	{
		alert("Please Enter Valid " + cap);
		obj.focus();
		return false;
	}
	return true;
}

function blank(obj)
{
	if(obj.value=="")
	{
		alert("All fields are mandatory");
		obj.focus();
		return false;
	}
	return true;
}
function check_blankval(obj)
{
	if(obj.value=="")
	{
		alert("All fields are mandatory");
		obj.focus();
		return false;
	}
	return true;
}

function check_blankval_fnc(obj)
{
	if(obj.value=="")
	{
		alert("* indicates required field");
		obj.focus();
		return false;
	}
	return true;
}
//Compare Two values which is greater
function comparetwovalues(obj1,obj2)
{
	if(parseInt(obj1.value)>parseInt(obj2.value))
	{
		alert("Between textbox value is not greater To textbox value");
		obj2.focus();
		return false;
	}
	return true;
}
//Number and decimal only enter
function checknum_decimal(obj)
{
	key=window.event.keyCode;
	if((key < 48 || key > 57) && key!=46)
	{
		alert("Enter only Number and Decimal Point");
		return false;
		obj.focus();
	}		
}
function check_radioval(obj1,obj2)
{
	if(!obj1.checked && !obj2.checked)
	{
		alert("Fields with * are mandatory");
		obj1.focus();
		return false;
	}
	return true;
}
function check_checkboxval(obj,cap)
{
	if(!obj.checked)
	{
		alert("You must be agree with Terms and Conditions");
		obj.focus();
		return false;
	}
	return true;
}
/*function check_emailval(obj,cap)
{
	var em=obj.value;
	if(obj.value=="")
	{
		alert(cap+" is mandatory");
		obj.focus();
		return false;
	}
	atspos=em.indexOf('@') + 1;
	dtspos=em.lastIndexOf('.');
	len=em.length-3;
	if(atspos < 2 || dtspos < 3  ||dtspos <= atspos || len<dtspos)
	{
		alert("Enter Valid E-mail Address");
		obj.focus();
		return false;
	}
	return true;
}*/
function check_emailval(obj,cap)
{
	if(obj.value=="")
	{
		alert("Email Address is mandatory");
		obj.focus();
		return false;
	}
	var str = obj.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;    
    if (!str.match(re))
	{
        alert("Enter Valid E-mail Address");
		obj.focus();
        return false;
    }
	else
	{
		dtspos=str.lastIndexOf('.');
		if(dtspos > 0)
		{
			if(str.substring(dtspos).length > 4)
			{
				alert("Enter Valid E-mail Address");
				obj.focus();
				return false;
			}
		}
        return true;
    }
	return true;
}
function check_blankcountry(obj)
{
	if(obj.value==0)
	{
		alert("Fields with * color are mandatory");
		obj.focus();
		return false;
	}
	return true;
}
function check_country(obj,cobj,eobj)
{
	if(obj.value=="United States")
	{
		eobj.value="";
		if(cobj.value==0)
		{
			alert("please Select State from List Box(just for USA)");
		}
		else
		{
			cobj.value;
			return true;
		}
		cobj.focus();
		return false;
	}
	else
	{
		cobj.value=0;
		if(eobj.value=="")
		{
			alert("Please enter State in text(other) box");
		}
		else
		{
			eobj.value;
			return true;
		}	
		eobj.focus();
		return false;
	}	
}
function check_confirm_password(mobj,cobj)
{
	if(mobj.value!=cobj.value)
	{
		alert("Your Password does not match with the Confirm Password")
		mobj.value="";
		cobj.value="";
		mobj.focus();
		return false;
	}
	return true;
}
function check_length(obj,leng)
{
    var objlen=obj.value.length
	if( objlen < leng )
	{
		alert("Length must be less than limited characters");
		obj.focus();
		return false;
	}
	return true;
}
//Used for checking valid amount >0
function validamount_nozero(obj,msg)
{
	if(obj.value == "" || isNaN(obj.value))
	{
		alert("Please enter valid "+msg)
		obj.value="0.00"
		obj.focus()
		return false;
	}
	else if(obj.value <=0)
	{
	 	alert("Please enter amount greater then 0")
		obj.value="0.00"
		obj.focus()
		return false;
	}
		return true;
}   
function requestParameter(name) 
{
    window.focus();
    var request = "" + window.location;
	var value = "";
	if (start = request.indexOf("?"+name+"=")+1) {
		value = request.substring(start+name.length+1);
	} else if (start = request.indexOf("&"+name+"=")+1) {
		value = request.substring(start+name.length+1);
	}
	if (value.indexOf("&")+1) {
		value = value.substring(0, value.indexOf("&"));
	}
	value = unescape(value);
	return value;
}

function open_preview(path,width,height)
{	
	var w = 480, h = 340;
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	objwnd=window.open(path,"objwnd","munubar=0,statusbar=yes,resizable=no,scrollbars=yes,width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd.focus();
}
function open_window(path,width,height)
{
	var w = 480, h = 340;
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2-5;
	objwnd=window.open(path,"objwnd","munubar=0,statusbar=no,resizable=yes,scrollbars=yes,width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd.focus();
}
function open_prev(path)
{	
	var w = 480, h = 340;
	var width=700,height=500;
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	objwnd1=window.open(path,"objwnd1","munubar=0,statusbar=yes,resizable=no,scrollbars=yes,width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd1.focus();
}
function inline_save(frmobj)
{
		
		frmsubmit_inline(frmobj);
		//if(!frmsubmit(frmobj));
		//else frmobj.submit();
		
}
function inline_delete(objid)
{
	if(confirm("Are you sure you want to delete clicked member?"))
	{
		location.replace("?prth_act=d&prth_inline_rowid=" + objid);
		return true;
	}
	return false;
}
function sendselected(actflag,selval)
{
	location.replace("?prth_act=" + actflag + "&prth_rowid=" + selval);
}
/*
function OpenToEdit(objid,selval)
{
	location.replace("?prth_act=edit&prth_obj_id=" + objid + "&prth_edit_id=" + selval);
}
function FetchOnChange(objfrm,fldname)
{
	objfrm.prth_act.value="FetchOnChangeBy" + fldname;	
	objfrm.submit();
}
function OpenToEdit(objid,selval)
{
	location.replace("?prth_act=edit&prth_obj_id=" + objid + "&prth_edit_id=" + selval);
}*/
function OpenToEdit(objid,objfrm,selval,act_val)
{
    objfrm.elements["prth_act_"+objid].value=act_val;
	objfrm.elements["prth_system_extra_"+objid].value=selval;
	objfrm.submit();
}
function FetchOnChange(objid,objfrm,fldname,act_val)
{
	objfrm.elements["prth_act_"+objid].value=act_val;	
	objfrm.submit();
}
function setprthact(objid,objfrm,act)
{
    objfrm.elements["prth_act_"+objid].value=act;	
	objfrm.submit();
}

function delete_textsnippet(frm)
{
	if (frm.text_id.value=="")
	{
		alert("Please Select any Text Snippets");
		frm.text_id.focus();
		return false;
	}
	if(confirm("Are you sure you want to delete this Text Snippets?"))
	{
		frm.prth_act_0.value='delete';
		frm.submit();
		//return true;
	}
	return false;
}
function check_duplicate(frm,templatename,objsel)
{
     if (objsel.options.length > 1 )
     {
        for(i=1;i < objsel.options.length;i++)
		{
			templatename=templatename.toLowerCase();
			templateidstr=objsel.options[i].text.toLowerCase();
			if (templatename==templateidstr)
			{
                return false;
			}
		}
       return true;    
    }
	return true; 
}
function hideshow(divid,aid)
{
   if(divid.style.display=="none")
   {
       divid.style.display="block";
       aid.innerHTML = "<img src='images/minus.jpg' border='0' width='20px' height='20px' />";
   }
  else
  {
        divid.style.display="none";
        aid.innerHTML = "<img src='images/plus.jpg' border='0' width='20px' height='20px' />";
  }
}
function valid_username(obj)
{
	if(!NotBlank(obj,"User Name"))return false;
	obj.value=Trim(obj.value);
	var tempstr;
	tempstr = obj.value;
	var reg = /[^A-Za-z0-9-._]/g;
	result = tempstr.match(reg);
	if(result != null)
	{
		obj.focus();	
		alert("Please enter valid User Name. \n\n Only alpha-numeric and the ., - and _ characters are allowed.")
		return false;
	}
	else
		return true;
}
function sethelpeditor(edt)
{
	edt.width="100%";
	edt.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.asp',640,500)";
	edt.btnFlash=true;
}
function setReporteditor(edt)
{
	edt.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.asp',640,500)";
}
function delete_confirm(msg)
{
	delmsg="this record";
	if(msg)
		if(msg!="")	delmsg=msg;
	
	if(confirm("Are you sure you want to delete "+delmsg+" ?"))
	{
		return true;
	}
	return false;
}
function DeleteRecord(objid,frmname,act,orderby,cpage,editid)
{
	if(delete_confirm())
	{
	    prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,editid);
	}
}
function HideAllButtons()
{
    var frm=document.frmprth_0;
    frm.save.disabled=true;
    frm.elements["delete"][0].disabled=true;
    frm.rename.disabled=true;
    frm.undo_eat.disabled=true;
    frm.addnode.disabled=true;
    frm.elements["delete"][1].disabled=true;
    frm.outdent.disabled=true;
    frm.indent.disabled=true;
    frm.up.disabled=true;
    frm.down.disabled=true;
}
function HideButtons()
{
    var frm=document.frmprth_0;
    frm.save.disabled=true;
    //frm.elements["delete"][0].disabled=true;
    //frm.rename.disabled=true;
    frm.undo_eat.disabled=true;
    //frm.addnode.disabled=true;
     //frm.elements["delete"][1].disabled=true;
    //frm.outdent.disabled=true;
    //frm.indent.disabled=true;
    //frm.up.disabled=true;
    //frm.down.disabled=true;
}
function CheckNodeName(objfrm)
{
    if(objfrm.prth_tree_id.value != '0')
    {
        if(objfrm.NodeName)
        {
            if(objfrm.NodeName.value=='')  
            {
                alert('Node name is mandotary.')
                document.frmprth_0.NodeName.focus();
                return false;
            }
        }
    }
    return true;
}
function EATNodeOperation(objfrm,optype)
{
    if(!CheckAnswerType(objfrm))	return false;
    if(objfrm.eahtfile_id.value)
    {
        if(CheckNodeName(objfrm))
        {
            objfrm.prth_act_0.value=optype;
            return true;
        }
    }
    return false;
}
function SaveUserAnswer(objfrm,optype)
{
    if(objfrm.eahtfile_id.value)
    {
        objfrm.prth_act_0.value=optype;
        return true;
    }
    return false;    
}
function CheckColorCode(obj,msg)
{
    if(isNaN(obj.value) || obj.value=="")
    {
        alert("Please Enter Valid " + msg);
        obj.focus();
        return false;
    }
    else if(obj.value.length != 6)
    {
        alert(msg + " must be 6 character long");
        obj.focus();
        return false;
    }
    return true;
}
function loadoriginalcontent(frm)
{
    if(confirm("Are you sure you want to revert changes and go back to an earlier version of the currently loaded page document...?"))
	{
		frm.prth_act_0.value='originalcontent';
        return true;
	}
    return false;
}
function loadeahtfile(frm)
{
   if(frm.eahtfile_id.value > 0)
   {
        if(Checkout_Process(frm)==true)
           frm.checkout_flag.value='true';
       else
           frm.checkout_flag.value='false';
               
       /*if (permissionarr[frm.eahtfile_id.value]=="w")
       {
           if(Checkout_Process(frm)==true)
               frm.checkout_flag.value='true';
           else
               frm.checkout_flag.value='false';
        }
        else
            frm.checkout_flag.value='false';*/
   }
   else
       frm.checkout_flag.value="";
       
  frm.elements["prth_act_0"].value="edit";
  frm.elements["checkout_action"].value="true";
  frm.elements["prth_system_extra_0"].value=frm.eahtfile_id.value;
  frm.submit();
}
function Checkout_Process(frm)
{
    var Msg="Do you want to checkout this selected document for editing or for reading . . . ? Clicking \"OK\" will checkout this document in Edit mode (and also will lock-out other users from editing it or saving it). Clicking \"Cancel\" will open it in Read Only mode (and also will lock you out from editing or saving it).";
    if(navigator.userAgent.toLowerCase().indexOf("aol") != -1)
        Msg="Do you want to checkout this selected document for editing or for reading . . . ? Clicking \"Yes\" will checkout this document in Edit mode (and also will lock-out other users from editing it or saving it). Clicking \"No\" will open it in Read Only mode (and also will lock you out from editing or saving it).";
    if(confirm(Msg))
         return true;
    else
      return false;
}
function DupDocRecord(objid,frmname,act,orderby,cpage,editid)
{
	var filename = prompt("Enter Duplicate File Name",document.getElementById(editid).innerHTML,"");
	if(filename)
    {
        if(filename==document.getElementById(editid).innerHTML)
        {
            alert("'" + document.getElementById(editid).innerHTML + "' is already in used. please Enter new duplicate name.")
            return false;
        }
        prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,editid+"|"+filename);
    }
    return false;
}

function change_criteria(objFrm,AnsType)
{
    //alert(objFrm.answer_type.value);
    switch(AnsType)
    {
        case "simple":
             document.getElementById("s_tcfilename").style.display="none";
             document.getElementById("search_criteria").style.display="none";
			 document.getElementById("s_report").style.display="none";
             document.getElementById("tc_criteria").style.display="none";
             break;
        case "dialog":
             document.getElementById("s_tcfilename").style.display="block";
             document.getElementById("search_criteria").style.display="none";
			 document.getElementById("s_report").style.display="none";
             document.getElementById("tc_criteria").style.display="block";
             break;
        case "extract_and_dialog":
             document.getElementById("s_tcfilename").style.display="block";
             document.getElementById("search_criteria").style.display="block";
			 document.getElementById("s_report").style.display="none";
             document.getElementById("tc_criteria").style.display="block";
             break;
        case "report":
             document.getElementById("s_tcfilename").style.display="block";
             document.getElementById("search_criteria").style.display="none";
             document.getElementById("tc_criteria").style.display="block";
			 document.getElementById("s_report").style.display="block";
             break;
        default:
             document.getElementById("s_tcfilename").style.display="none";
             document.getElementById("search_criteria").style.display="none";
             document.getElementById("tc_criteria").style.display="none";
			 document.getElementById("s_report").style.display="none";
             break;
    }
}

function CopyToAnswer(objFrm)
{
    //opener.document.frmprth_0.txtcontent.value=IDanswer.getXHTML();
    //opener.document.frmprth_0.submit();
    objFrm.txtanswer.value = IDanswer.getXHTML();
    objFrm.prth_act_0.value = "CopyContent";
    objFrm.submit();
}

function CopyToAnswerPopup(objFrm,EahtFileID,AnodeID,report_anodeid)
{
    HardCoreWebEditorSubmit();
    open_window("answer_editor.aspx?anodeid="+ AnodeID + "&sel_eahtfile_id="+EahtFileID+"&report_anodeid="+report_anodeid,790,500)
}

function open_dialogbox(path,width,height,resize,scroll,status,samewindow)
{	
	var w = 480, h = 340;
	
	if(!width)
		width="700";
	if(!height)
		height="500";
	if(!resize)
		resize="no";
	if(!scroll)
		scroll="no";
	if(!samewindow)
		samewindow="objwnd";
	if(!status)
		status="no";
	
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	objwnd=window.open(path,samewindow,"munubar=no,titlebar=no,status="+status+",resizable="+resize+",scrollbars="+scroll+",width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd.focus();
}
function open_topdialogbox(path,width,height,resize,scroll,status,samewindow,istop,title)
{	
	var w = 480, h = 340;
	
	if(!width)
		width="700";
	if(!height)
		height="500";
	if(!resize)
		resize="no";
	if(!scroll)
		scroll="no";
	if(!samewindow)
		samewindow="objwnd";
	if(!status)
		status="no";
	
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	if(istop)
	{
	    if(istop=='yes');
	    {
	        objDiv = null;
	        var CalledFrom = location.href;
	        
	        overflow = "scroll";
	        if(scroll=="no")
	            overflow = "hidden";
	        if(CalledFrom.indexOf("gwe_details.aspx") > -1)
	            objDiv = parent.document.getElementById("gwe_overlay");
	        else if(CalledFrom.indexOf("node_ev_form_facilitator.aspx") > -1)   
	            objDiv = document.getElementById("gwe_overlay");
	        else if(CalledFrom.indexOf("print_review_pf_form.aspx") > -1)   
	            objDiv = document.getElementById("gwe_overlay");
	        else if(CalledFrom.indexOf("facilitator_dialog_details.aspx") > -1)
	            objDiv = parent.document.getElementById("gwe_overlay");
	        else if(CalledFrom.indexOf("facilitator_book_data.aspx") > -1)
	            objDiv = parent.document.getElementById("gwe_overlay");
	        else if(CalledFrom.indexOf("student_exercise_section.aspx") > -1)
	            objDiv = parent.document.getElementById("gwe_overlay");
	        else
	            objDiv = null;
	        //alert(objDiv);
	        if(objDiv != null)
	        {
	            objDiv.innerHTML = "<iframe frameborder='0' width='"+width+"' height='"+height+"' id='gwe_top_dialog' src='"+path+"' scrolling='"+scroll+"' name='gwe_top_dialog'></iframe>";
	            objDivHandle = parent.document.getElementById("gwe_overlay_handle");
	            if(objDivHandle != null)
	            {
	                if(title && title != 'undefined')
	                    objDivHandle.innerHTML = "<b>"+title+"</b>";
	                objDivHandle.style.cssText = "padding:0px;padding-left:5px;";
				    objDivHandle.style.width=parseInt(width-7-27)+"px";
				    ShowOverlayDiv('GWE_BehaviorID',width,height);
				}	            
	        }
	    }    
	}
	else
	{
	    objwnd=window.open(path,samewindow,"munubar=no,titlebar=no,status="+status+",resizable="+resize+",scrollbars="+scroll+",width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ 0 +",screenX="+ leftPos +",screenY="+ topPos);	
	    objwnd.focus();
	}
}

function MenuClick(event,objID,CotrolName)
{
	hideMenu('');
	if(window.event)
		event = window.event;
	
	if (event.ctrlKey==true)
	{   
	    open_dialogbox("snippet_addedit.aspx?snippet_action=edit&text_id="+objID,"760","450","yes","yes",'',"newsnippet");
	}
	else
	{
	    var CodeStr = "document.frmprth_0." + CotrolName + ".value=" + "document.frmprth_0." + CotrolName + ".value + IDStr[" + objID + "]";  // + response.value + "'";
	    eval(CodeStr);
	}
}

function AddSnippet(objID,CotrolName)
{
    hideMenu('');
    var o_c = eval("document.frmprth_0." + CotrolName)
    if(o_c)     
    {
        var CodeStr = document.frmprth_0.elements[CotrolName].value= document.frmprth_0.elements[CotrolName].value + IDStr[objID];  // + response.value + "'";
	    //eval(CodeStr);
		document.frmprth_0.elements[CotrolName].focus();
    }
    else
        contenteditable_pasteContent(IDStr[objID]);
    /*document.frmprth_0.prth_act_0.value="AddSnippet";
    document.frmprth_0.prth_extra.value=objID;
    document.frmprth_0.submit();*/
}
function SnippetCopyClick(ControlName)
{
	hideMenu('');
	
	if(document.frmprth_0.elements[ControlName].value!="")
    {
	    var defaultsnippetname=document.frmprth_0.eahtfile_id[document.frmprth_0.eahtfile_id.selectedIndex].text + "_" + document.frmprth_0.snippettree_no.value + "_" +ControlName;
	    boolvar = prompt("Please enter new Snippet name",defaultsnippetname,"");
	    if(boolvar)
	    {
	       document.frmprth_0.text_name.value=boolvar;
	       document.frmprth_0.textsnippettype.value=ControlName;
	       document.frmprth_0.prth_act_0.value="copysnippet";
	       document.frmprth_0.submit();
	       return true;
	    }
	    else
	        return false;
	}
	else
	{
	    alert("Please enter the text to copy as snippet");
	    document.frmprth_0.elements[ControlName].focus();
	    return false;
	}
}
function SnippetMenuClick(event,objID,CotrolName,frm)
{
    if(frm == "")
        frm=document.aspnetForm;
    
    //Repeater1.ClientID & "_review_crieteria"
	hideMenu('');
	if(window.event)
		event = window.event;
	
	if (event.ctrlKey==true)
	{   
	    open_dialogbox("snippet_addedit.aspx?snippet_action=edit&text_id="+objID,"760","450","yes","yes",'',"newsnippet");
	}
	else
	{
	
	    var CodeStr = CotrolName + ".value=" + CotrolName + ".value + IDStr[" + objID + "]";  // + response.value + "'";
	    eval(CodeStr);
	}
}
function AnswerSnippetCopyClick(ControlName,is_html)
{
    tempControlName = ControlName
    hideMenu('');
	if(ControlName=="answer" || ControlName=="Answer")
		tempControlName="Answer";
    else
	    tempControlName= ControlName;
	    	
    if(tempControlName=="Answer" && document.frmprth_0.txtcontent)
    {
        HardCoreWebEditorSubmit();
        ControlName = "txtcontent";
    }
    
    if(document.frmprth_0.elements[ControlName].value!="")
    {
	    var defaultsnippetname=document.frmprth_0.eahtfile_id[document.frmprth_0.eahtfile_id.selectedIndex].text + "_" + document.frmprth_0.snippettree_no.value + "_" 
		if(ControlName == "txtcontent")
			defaultsnippetname = defaultsnippetname + "Answer";
		else
			defaultsnippetname = defaultsnippetname + ControlName;
		
	    boolvar = prompt("Please enter new Snippet name",defaultsnippetname,"");
	    if(boolvar)
	    {
	       document.frmprth_0.text_name.value=boolvar;
	       if(is_html=="1")
	       {
	        document.frmprth_0.is_html.value=1;
	       }
	       document.frmprth_0.textsnippettype.value=ControlName;
	       document.frmprth_0.prth_act_0.value="copysnippet";
	       document.frmprth_0.submit();
	       return true;
	    }
	    else
	        return false;
	}
	else
	{
	    alert("Please enter the text to copy as snippet");
	    return false;
	}
}
function ManageSnippetClick(SnippetType,eahtfile_id,course_id)
{
   hideMenu('');
   open_dialogbox("snippet_addedit.aspx?&snippets_type="+SnippetType+"&snippet_eahtfile_id="+eahtfile_id+"&snippet_course_id="+course_id,"760","450","yes","yes",'',"managesnippet");
}
function NewSnippetClick(is_html,SnippetType,eahtfile_id,course_id)
{
   hideMenu('');
   open_dialogbox("snippet_addedit.aspx?snippet_action=new&is_html="+is_html+"&snippets_type="+SnippetType+"&snippet_eahtfile_id="+eahtfile_id+"&snippet_course_id="+course_id,"760","450","yes","yes",'',"newsnippet");
}

function ManageBookSnippetClick(SnippetType,book_id,course_id)
{
   hideMenu('');
   open_dialogbox("snippet_addedit.aspx?&snippets_type="+SnippetType+"&snippet_book_id="+book_id+"&snippet_course_id="+course_id,"760","450","yes","yes",'',"managesnippet");
}
function NewBookSnippetClick(is_html,SnippetType,book_id,course_id)
{
   hideMenu('');
   open_dialogbox("snippet_addedit.aspx?snippet_action=new&is_html="+is_html+"&snippets_type="+SnippetType+"&snippet_book_id="+book_id+"&snippet_course_id="+course_id,"760","450","yes","yes",'',"newsnippet");
}
function SaveGrade(prthact)
{
    HardCoreWebEditorSubmit();
    objfrm=document.frmprth_0;
    if(!objfrm.student)
    {
        alert("Please select atleast one node to perform action");
        return false;
    }
    if(!NotBlank(objfrm.eahtfile_id,"QuESt File"))return false;
    if(!NotBlank(objfrm.student,"Student"))return false;
    objfrm.prth_act_0.value=prthact;
    return true;
}

function SaveProgressGate(objFrm,prthact)
{
    if(objFrm.anodeid.value!='' && objFrm.eahtfile_id.value!='' && objFrm.userid)
    {
	     objFrm.prth_act_0.value=prthact;
	     return true;
    }
    else
    {
        alert('* Indicates required field.')
        if(objFrm.eahtfile_id.value=='')
        {
            objFrm.eahtfile_id.focus();
            return false; 
        }
        if(objFrm.anodeid.value=='')
            objFrm.anodeid.focus();
        
        return false; 
    }
}

function htmleditor(objFrm)
{
    if(!IsNumeric(objFrm.pageid,"Region"))return false;
	objFrm.prth_act_0.value='savepagecontent';
    //objFrm.submit();
    return true;
}

function MouseDownEvent(aNodeID)
{
    document.frmprth_0.src_anode_id.value=aNodeID;
    document.frmprth_0.dest_anode_id.value='';
}
function MouseUpEvent(DestHtml)
{
    if(isNaN(DestHtml))
    {
        //alert("MouseUpEvent : " + DestHtml);
        if(DestHtml.indexOf("MouseUpEvent")>-1)
        {
            DestHtml = DestHtml.substring(DestHtml.indexOf("MouseUpEvent")+13);
            DestHtml = DestHtml.substring(0,DestHtml.indexOf(")"));
            document.frmprth_0.dest_anode_id.value=DestHtml;
            //alert("ID : " + document.frmprth_0.dest_anode_id.value);
            document.frmprth_0.prth_act_0.value='MouseUp';
            DragDropSubmit = true;
        }
    }
}

function ApplySearch(objFrm)
{
    if(objFrm.saved_criteria.value!='')
    {
        if(objFrm.saved_criteria.options.length)
        {
            var i=0;
            for(i=0; i<objFrm.saved_criteria.options.length; i++)    
            {
                //alert(objFrm.saved_criteria.options[i].selected)
                if(objFrm.saved_criteria.options[i].selected)
                {
                    opener.document.frmprth_0.criteria.value = objFrm.saved_criteria.value;
				    opener.document.getElementById("extract_criteria_name").innerHTML="<b>Criteria File:</b> "+objFrm.saved_criteria.options[i].text
                    self.close();
                }
            }
        }
        self.close();
    }
    else    alert('Please select Searched Criteria.');
}

function ApplyAnswer(objFrm)
{
    HardCoreWebEditorSubmit();
    objFrm.prth_act_0.value='save';
    objFrm.submit();    
}

function OpenExtractPopup(objFrm)
{
    var path = "compile.aspx?openaspopup=true&eahtfile_id=";
    var i=0;
    if(objFrm.eahtfile_id.options.length)
    {
        for(i=0; i<objFrm.eahtfile_id.options.length; i++)
        {
            if(objFrm.eahtfile_id.options[i].selected)
            {
                path = path + objFrm.eahtfile_id.options[i].value;
                break;
            }
        }
    }
    path = path + "&saved_criteria=" + objFrm.criteria.value
    open_window(path,780,570)
}

function CheckAnswerType(objfrm)
{
    if(objfrm.answer_type)
    {
        var i=0;
        var sts = false;
        for(i=1;i<objfrm.answer_type.options.length;i++)
        {
            if(objfrm.answer_type.options[i].selected)
            {
                sts = true;
                break;
            }
        }
        if(!sts)    
        { 
            alert('Please select Answer Type.'); 
            objfrm.answer_type.focus();
            return false; 
        }
    }
    return true;
}

function AnsProvCheckChange(objfrm)
{
    var i=0;
    var sts = false;
    for(i=1;i<objfrm.student.options.length;i++)
    {
        if(objfrm.student.options[i].selected) { sts = true;  break;  }
    }
    if(sts)
    {
        //if(confirm('Do you want to save the changed answer content?'))
        //{ 
		HardCoreWebEditorSubmit();  
		objfrm.prth_act_0.value='save_checkchange';
		//}
       // else    objfrm.prth_act_0.value='checkchange';
    }
    else objfrm.prth_act_0.value='checkchange';
    objfrm.submit();
}
function ExportCSV()
{
    frmobj=document.frmprth_0;
   open_dialogbox("gradcsvfile.aspx?student_name="+frmobj.student_name.value+"&select_node="+frmobj.select_node.value+"&eahtfile_id="+frmobj.eahtfile_id.value);
}
function HideShowBlock(divid)
{
	if(divid!="")
	{
		objdiv=document.getElementById(divid);
		if(objdiv)
		{
			objkeydiv=eval("document.getElementById('key_" + divid + "')");
			if(objkeydiv.src.indexOf("plus") == -1 )
			{
				objdiv.style.display="none";
				objkeydiv.src="images/plus_a.gif";
			}
			else
			{
				objdiv.style.display="block";
				objkeydiv.src="images/minus_a.gif";
			}
		}
	}
}
function TeacherPreviewAnswer(prthact,extra)
  {
	  objfrm=document.frmprth_0;
	  if(objfrm.prth_tree_id.value!='0')
	  {
		  open_window("answer_preview.aspx?selnodeid="
		  + objfrm.prth_tree_id.value + "&eahtfile_id=" + objfrm.eahtfile_id.value + "&calltype=" + prthact,600,350)
	  }
	  else
	  {
	  	if(prthact=="preview_anno")
			alert('To show other annotations please click the pushbutton labeled "Show Tree" first. Then select the appropriate node from within the tree.');
		else
			alert('To show other answers please click the pushbutton labeled "Show Tree" first. Then select the appropriate node from within the tree.');
	  }
  }
   function PreviewAnswer(prthact,extra)
  {
	  objfrm=document.frmprth_0;
	  if(objfrm.prth_tree_id.value!='0')
	  {
		  open_window("answer_preview.aspx?selnodeid="
		  + objfrm.prth_tree_id.value + "&eahtfile_id=" + objfrm.eahtfile_id.value + "&calltype=" + prthact,600,350)
	  }
	  else
	  {
	  	if(prthact=="preview_anno")
			alert('To show other users\' annotations please click the pushbutton labeled "Show Tree" first. Then select the appropriate node from within the tree.');
		else
			alert('To show other user\'s answers please click the pushbutton labeled "Show Tree" first. Then select the appropriate node from within the tree.');
	  }
  }
function CheckBlankQuESt(objFrm)
{
      if(objFrm.eahtfile_id.value=="")
      {
           alert("Please select QuESt to open")
            objFrm.eahtfile_id.focus(); 
           return false;
      }
}
function InitializeWith(objFrm)
{
	if(objFrm.initreport.value!="")
	{
		objFrm.prth_act_0.value='initreport';
		objFrm.submit();
	}
	else
	{
		alert("Plase select the node to initialize");
		objFrm.initreport.focus();
	}
}
function Submit_FormOnShowIndex(objfrm)
{
	RefreshWithEditorContent(objfrm,'show_index');
}
function RefreshWithEditorContent(objfrm,act)
{
	HardCoreWebEditorSubmit();
	objfrm.prth_act_0.value=act;
	objfrm.submit();
}
function SaveLastOpenNode(pagename)
{
	try
	{	HardCoreWebEditorSubmit();	}
	catch(e) {}
	objfrm=document.frmprth_0;
	objfrm.prth_act_0.value='saveonunload';
	objfrm.prth_redirectedpage.value=pagename;
	objfrm.submit();
}
function open_highlight_popup(classes_id,eahtfile_id,match_whole_word,case_sensitive)
{
    open_dialogbox('class_highlights.aspx?classes_id='+classes_id+'&eahtfile_id='+eahtfile_id+'&match_whole_word='+match_whole_word+'&case_sensitive='+case_sensitive,700,500,'yes','no','no');
}
function setForumPosteditor(oEdit1)
{
    oEdit1.width="100%";
	//oEdit1.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.asp',640,500)";
    oEdit1.features=["Undo","Redo","|","ForeColor","BackColor","|","Hyperlink","Image","Line","|","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
    oEdit1.height=300;
    oEdit1.btnCustomTag=false;
}
function iframe_option_popup(eahtfile_id,node_id)
{
    open_dialogbox('iframe_options.aspx?eahtfile_id='+eahtfile_id+'&nodeid='+node_id,700,370,'no','no','no');
}
function CheckBoxValidation(objfld,cap)
{
   var bool=false;
   if(objfld)
    {
        if(objfld.length)
        {
            for(i=0;i<objfld.length;i++)
			{
				
				if(objfld[i].checked)
				{
					bool=true;
					break;
				}
			}
        }
        else
		{
			if(objfld.checked)
				bool = true;
		}
		
    }
    if (bool==false)
    {
        alert("Please select atleast one "+cap);
        return false;
    }
    return true;
}
function prth_calendar_fnc_nevigation(objid,frmname,act,systemextra,seldate)
{
	
	var objfrm=eval("document." + frmname);
	objfrm.elements["prth_act_"+objid].value=act;
	objfrm.elements["prth_seldate_"+objid].value=seldate;
 	if(systemextra)
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;
		
	objfrm.submit();
}
function confirmdeleteevent(objfrm)
{
    if(confirm("Do you want to delete opened calendar event?"))
    {
        objfrm.prth_act_0.value='delete';
        return true;
    }
    return false
}
function Cancleevent(objfrm)
{
    objfrm.prth_act_0.value="cancel";
    objfrm.submit();
}
function Check_CheckboxSelection(objfld)
{
    var bool=false;
    if(objfld)
    {
        if(objfld.length)
        {
            for(i=0;i<objfld.length;i++)
			{
				
				if(objfld[i].checked)
				{
					bool=true;
					break;
				}
			}
        }
        else
		{
			if(objfld.checked)
			{
				bool = true;
			}
		}
		
    }
    return bool
}
function check_selctallevents(frmobj)
{
    if(!Check_CheckboxSelection(frmobj.sel_eventsid))
    {
        alert("Please select atleast one event to perform an action");
        frmobj.flt_action_menu.value = "";
        return false; 
    }
    if (frmobj.flt_action_menu.value == "eid_delete")
    {
         if (confirm("Are you sure you want to delete selected events?"))
	    {
		    frmobj.prth_act_0.value="change_action_menu";
            frmobj.submit();
            return true;
		} 
    }
    else if(frmobj.flt_action_menu.value == "hide" || frmobj.flt_action_menu.value == "clear")
    {
        frmobj.prth_act_0.value="change_action_menu";
        frmobj.submit();
        return true;
    }
    frmobj.flt_action_menu.value = "";
	return false;
}
function CheckAddToNews(frmobj,act)
{
    if(act!="")
    {
        frmobj.prth_act_0.value=act;
        return true;
    }
    return true;
}
function change_calendar_type(frmobj,tabid)
{
    if(frmobj.calendar_type.value=='monthly')
    {
        frmobj.action='calendar.aspx';
        frmobj.prth_act_0.value='comingfromlistview';
        frmobj.submit();
    }
    else
    {
        frmobj.action='calendar_listview.aspx';
        frmobj.prth_act_0.value='comingfrommonthly';
        frmobj.submit();
    }
}
function print_event_listview()
{
    //prth_filter_periodic, prth_filter_fromdate, prth_filter_todate
    //calendar_category
    var i=0;
    period="";
    objfrm = document.frmprth_0;
    for(i=0;i<objfrm.prth_filter_periodic.length;i++)
    {
        if(objfrm.prth_filter_periodic[i].checked)
        {
           period=objfrm.prth_filter_periodic[i].value;
        }
    }
    fromdate="";
    todate="";
    if(objfrm.prth_filter_fromdate)
      fromdate =  objfrm.prth_filter_fromdate.value;
      
    if(objfrm.prth_filter_todate)
      todate =  objfrm.prth_filter_todate.value;
    
    open_dialogbox('calendar_listview_print.aspx?prth_filter_periodic='+ period + '&prth_filter_fromdate='+ fromdate +'&prth_filter_todate='+ todate +'&calendar_category='+ objfrm.calendar_category.value +'&prth_obj_id_0=0&prth_act_0=save&prth_orderby_0='+objfrm.prth_orderby_0.value,760,550,'yes','yes');
}
function blog_contenteditor(oEdit1)
{
   oEdit1.features=["Undo","Redo","|","ForeColor","BackColor","|","Hyperlink","Image","Flash","Line","|","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
   oEdit1.height=300;
   oEdit1.btnCustomTag=false;
}
function hideshow_archivearea(id)
{
    var imgobj=document.getElementById("img_"+id)
    var divobj=document.getElementById(id)
    if(imgobj)
    {
        if(imgobj.src.indexOf("minus")>-1)
        {
            imgobj.src="images/plus.gif"
            divobj.style.display='none';
        }
        else
        {
            imgobj.src="images/minus.gif"
            divobj.style.display='block';
        }
    }
}
function ArchiveSelection(act,act_value)
{
    document.frmprth_blog.archieve_action.value=act;
    document.frmprth_blog.archieve_action_value.value=act_value;
    document.frmprth_blog.submit();
}
function DivShowForCType(obj)
{
    //if(document.frmprth_question.prth_system_extra_question.value!=0)
    //{
       if(obj.value=="5")
          { 
           cap_lines.style.display="block"
           field_lines.style.display="block"
          }
       else
          {
           cap_lines.style.display="none"
           field_lines.style.display="none"
          }
    //}
}
function TakeStudentTest(frm,eid)
{
    if(confirm("Once your start a Quiz or an Exam it cannot be deleted.\n\nAre you sure you want to start?"))
	{
		//frm.prth_act_0.value='take_test';
		var objfrm=eval("document." + frm);
		objfrm.elements["prth_act_0"].value='take_test';
		objfrm.eahtfile_id.value=eid;
		objfrm.submit();
	}
}
function QuitExam(e,frm)
{
    msg = "<div class=\"errormsg\"><b>Are you sure to quit the test?</b></div><br>";
	msg += "<div>If yes, please write <b>reason</b> in following box."
	msg += "<div><textarea class=\"textbox\" rows=\"4\" cols=\"45\" id=\"txt_reason\" name=\"txt_reason\"></textarea></div><br>";
	msg += "Click \"Yes\" button to click otherwise click \"No\" to cancel the quit operation.</div><br>"
    OpenDialog(e,msg,2,'quitexamyes,quitexamno',false);
}
function quitexamyes()
{
    document.frmprth_test.quit_reason.value = document.getElementById("txt_reason").value
    document.frmprth_test.prth_act_test.value='quittest';
    document.frmprth_test.submit();
}
function quitexamno()
{
    
}

function SetClock(maxtime)
{	
	var ss=parseInt(document.frmprth_test.fld_timer.value);
    if(isNaN(ss))
        ss=0;
	ss=ss+1;
	var newss=ss;
	document.frmprth_test.fld_timer.value=ss;	
	var mnt=0;
	mnt=ss/60;
	ss=ss%60;
	mnt=Math.floor(mnt);
	if(mnt<10)mnt="0" + mnt;
	if(ss<10)ss="0" + ss;
	//document.all.div_timer.innerText="Total Time: "+maxtime+ "    Elapsed Time:"+mnt + ":" + ss;
	document.getElementById("div_timer").innerText=""+mnt + ":" + ss;
	if(maxtime==newss)
    {
        alert("Your allocated time for the test is over");
        document.frmprth_test.prth_act_test.value='timeout';
        document.frmprth_test.submit();
    }
	else
	{
	   setTimeout("SetClock(" + maxtime + ")",1000);
	}
}
function check_selctallnews(frmobj)
{
    if(!Check_CheckboxSelection(frmobj.sel_newsid))
    {
        alert("Please select at least one News to perform an action");
        frmobj.flt_action_menu.value = "";
        return false; 
    }
    if (frmobj.flt_action_menu.value == "newsid_delete")
    {
         if (confirm("Are you sure you want to delete selected News?"))
	    {
		    frmobj.prth_act_0.value="change_action_menu";
            frmobj.submit();
            return true;
		} 
    }
    frmobj.flt_action_menu.value = "";
	return false;
}
function CpyReportEditor(frm)
{
    if(!frmsubmit(frm)) return false;
    opener.contenteditable_pasteContent(frm.result_editor.value);
    self.close();
}
function RevertWiki(frm,eid)
{
    if(confirm("If you have to revert the content then will be overwritten.\n\nAre you sure you want to overwrite the content?"))
	{
		var objfrm=eval("document." + frm);
		objfrm.elements["prth_act_0"].value='reverted_to';
		objfrm.prth_system_extra_0.value=eid;
		objfrm.submit();
	}
}
var TCEFlag=false;
function AddBlogContent(type,objID,CotrolName)
{
	if(type=="blogentry")
	{
		if(document.frmprth_0.elements[CotrolName])
			open_dialogbox('copy_blog_entry.aspx?prth_rowid='+objID+"&iseditor=false&tceflag=false&tceaddclass=",730,450,'yes','yes');			
		else
			open_dialogbox('copy_blog_entry.aspx?prth_rowid='+objID+"&iseditor=true&tceflag="+TCEFlag+"&tceaddclass="+TCEAddClass,730,450,'yes','yes');
	}
	else if(type=="forumreply")
	{
		if(document.frmprth_0.elements[CotrolName])
			open_dialogbox('copy_forum_reply.aspx?prth_rowid='+objID+"&iseditor=false&tceflag=false&tceaddclass=",730,450,'yes','yes');			
		else
			open_dialogbox('copy_forum_reply.aspx?prth_rowid='+objID+"&iseditor=true&tceflag="+TCEFlag+"&tceaddclass="+TCEAddClass,730,450,'yes','yes');
	}
}


function iframe_option_popup_project(eahtfile_id)
{
	if(eahtfile_id!="0")
	{
    	open_dialogbox('iframe_options_project.aspx?eahtfile_id='+eahtfile_id,700,370,'no','no','no');
	}
	else
	{
		alert("Please load QuESt file");
	}
}
function Open_Section(sectionid)
{
	if(!IsProject_Section_GridOpen)
	{
		theForm.OpenSection.value=sectionid;
		theForm.submit();
	}
	else
	{
		CloseAllOpenSelectedBlock('div_section_','div_section_'+sectionid)	
		location.replace('#section_'+sectionid);
	}
}
function CloseAllOpenSelectedBlock(prefix,opendedblockid)
{
	var div_tags=document.getElementsByTagName("div");  
	for(i=0;i<div_tags.length;i++)
	{
		divid=div_tags[i].id;
		if(divid!="" && divid.indexOf(prefix)>=0 && divid!=opendedblockid)
		{
			var imgobj=document.getElementById("img_"+divid)
		    var divobj=document.getElementById(divid)
		    //if(imgobj.src.indexOf("minus")>-1)
		    {
		        imgobj.src="images/plus.gif"
		        divobj.style.display='none';
		    }
		}
	}
	hideshow_archivearea(opendedblockid);
}
function OpenFinalReport(obj)
{
	if(obj.value>0)
	{
		open_dialogbox('copy_final_report.aspx?eahtfile_id='+obj.value,720,540,'yes','yes','yes');
	}
}
function Paste_Final_Report()
{
	contentSelection = contenteditable_selection();
    text="";
    if(contentSelection.type=="None")
    {
        HardCoreWebEditorSubmit();
        text=document.aspnetForm.txteditorcontent.value;
    }
    else
    {
        text = contenteditable_selection_text();
    }
    opener.contenteditable_pasteContent(text);
 	self.close();
	return false;
	/*if(!opener.IDdescription.checkFocus())
	{
		opener.IDdescription.hide();
		opener.IDdescription.focus();
	}
	str = IDContent.GetSelectedHTMLBody();
	opener.IDdescription.insertHTML(str);
	self.close();
	return false;*/
}
function OpenSkype()
{
    //alert("This feature is still under construction");
	open_dialogbox('open_skype.aspx',500,200,'no','no','no');
}
function SubmitWithAct(objid,act)
{
	objfrm=eval("document.frmprth_" + objid);
	objfrm.elements["prth_act_"+objid].value=act;
}
function SaveAsFinalReport(objid,act)
{
	objfrm=eval("document.frmprth_" + objid);
  	var filename = prompt("Enter Final Report name","","");
	if(filename)
	{
		objfrm.file_name.value = filename;
		objfrm.elements["prth_act_"+objid].value=act;
		return true;
	}
	else
		return false;
}
function DeleteFinalReport(objid,act)
{
	if(confirm("Are you sure you want to delete this record ?"))
	{
		objfrm.file_name.value = filename;
		objfrm.elements["prth_act_"+objid].value=act;
		return true;
	}
	else
		return false;
}
function article_contenteditor(oEdit1)
{
   oEdit1.features=["Undo","Redo","|","ForeColor","BackColor","|","PersonalReport","Hyperlink","Image","Flash","Line","|","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
   oEdit1.height=300;
   oEdit1.btnCustomTag=false;
}
function BackToPAGrid()
    {
        document.Form1.action.value="goto_grid";
    }
    function CheckValid()
    {
        document.Form1.Submit();        
    }
    
     function Checkdate(source, arguments)
    {   
    var arr=arguments.Value.split("/");    
    if (IsInteger1(arr[0]))
        {
                if (IsInteger1(arr[1]))
                {
                      if (IsInteger1(arr[2]))
                      {
                             if(isdate(arr[0],arr[1],arr[2]))
                             {         
                                arguments.IsValid=true;
                                return true;
                             }
                      }    
                }
        }                    
       
           arguments.IsValid=false;
           return false;
    }

    function isdate(mm,dd,yy)
    {
        if (mm > 12 || mm < 0 )
        {
            return false;
        }
        if (dd > 31 ||dd < 0)
        {
            return false;
        }
        if (yy < 0 )
        {
            return false;
        }
        if(mm==2)
        {
	        if(dd>29)
	        {
		        return false;
	        }
	        else if(dd==29 && ((yy%4)>0))
	        {
		        return false;
	        }
        }
        else if( dd > 30 && (mm==4 || mm==6 || mm==9 || mm==11))
        {
	        return false;
        }
        return true;
    	
    		
    }
    function IsInteger1(value)
    {
        if(value=="")
            return false;
        var tempstr;	
        tempstr = value;
        var nreg= /[^0-9]/g;
        nresult = tempstr.match(nreg);
        if(nresult != null)
        {
	        return false;
        }
        return true;
    }
    
    function refreshfinalreportcourse(val)
    {
        document.frmprth_0.prth_system_extra_0.value=val;
        document.frmprth_0.prth_act_0.value='edit';
        document.frmprth_0.submit();
    }
    
 function ManageDuplicateRecord()
{
	var filename = prompt("Enter Duplicate File Name","","");
	if(filename)
    {
        document.aspnetForm.dupfilename.value=filename;
        return true
    }
    return false;
}
function CopyResourceMaterial(frm)
{
    //opener.contenteditable_pasteContent(frm.txteditorcontent.value);
    contentSelection = contenteditable_selection();
    text="";    
    if(!contentSelection.type || contentSelection.type=="None")
    {
        HardCoreWebEditorSubmit();
        text=frm.txteditorcontent.value;
    }
    else
    {
        text = contenteditable_selection_text();
    }
    opener.contenteditable_pasteContent(text);
    self.close();
}

function DeleteForumReply(isparent)
{
    if(isparent==0)
    {
        if(confirm("Are you sure you want to delete this Reply?"))
            return true;
    }
    else
    {
        if(confirm("This Reply have multiple child replies.\n\nAre you sure you want to delete this post?"))
            return true;
    }
    return false;
}
function DeleteBlogComment()
{
    if(confirm("Are you sure you want to delete this Comment?"))
       {return true;}
    return false;
}

/*function ToggleFileAndCourse(frm)
{
   if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value == 4)
   {
        frm.eahtfile_id.disabled=true;
        frm.fk_course.disabled=false;
   }
   else if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value != 4)
   {
        frm.fk_course.disabled=true;
        frm.eahtfile_id.disabled=false;
   }
   else
   {
        frm.eahtfile_id.disabled=true;
        frm.fk_course.disabled=true;
   }
}

function DisableFileAndCourse()
{
    var frm = document.frmprth_0;    
    var eahtid = document.getElementById("eahtfile_id");
    var courseid = document.getElementById("fk_course");
    eahtid.disabled=true;
    courseid.disabled=true;
}
function CheckSnippetType(obj,msg)
{
    var frm = document.frmprth_0;  
    if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value == 4)
    {
        if(frm.fk_course.value==0)
        {
            alert("Please select course");
            frm.fk_course.focus();
            return false;
        }
    }
    else if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value != 4)
    {
        if(frm.eahtfile_id.value==0)
        {
            alert("Please select QuESt file");
            frm.eahtfile_id.focus();
            return false;
        }
    }
    else
    {
        return false;
    }
    return true;
}*/

function ToggleFileAndCourse(frm)
{
   var tbl = frm.getElementsByTagName("table").item(0); 
   var itbl = tbl.getElementsByTagName("table").item(0); 
   var FileTR = itbl.getElementsByTagName("tr").item(2); 
   var FileLTD = FileTR.getElementsByTagName("td").item(0); 
   var CourseTR = itbl.getElementsByTagName("tr").item(3); 
   var CourseLTD = CourseTR.getElementsByTagName("td").item(0); 
   var bFile = FileLTD.getElementsByTagName("b").item(0);
   var bCourse = CourseLTD.getElementsByTagName("b").item(0);
   var rs = "*";
   if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value == 4)
   {
        frm.eahtfile_id.disabled=true;
        frm.fk_course.disabled=false;
        bCourse.innerHTML=rs;
        bFile.innerHTML="";
   }
   else if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value != 4)
   {
        frm.fk_course.disabled=true;
        frm.eahtfile_id.disabled=false;
        bFile.innerHTML=rs;
        bCourse.innerHTML="";
   }
   else
   {
        frm.eahtfile_id.disabled=true;
        frm.fk_course.disabled=true;
        bFile.innerHTML="";
        bCourse.innerHTML="";
   }
}

function DisableFileAndCourse()
{
   var frm = document.frmprth_0; 
   //alert(frm.onsubmit);
   //frm.submitdisabledcontrols.value="true";
   //frm.attributes.add("onsubmit","return checkIt("+frm+");");
   //frm.onsubmit="return checkIt("+frm+");";
   //alert(frm.onsubmit);
   var tbl = frm.getElementsByTagName("table").item(0); 
   var itbl = tbl.getElementsByTagName("table").item(0); 
   var FileTR = itbl.getElementsByTagName("tr").item(2); 
   var FileLTD = FileTR.getElementsByTagName("td").item(0); 
   var CourseTR = itbl.getElementsByTagName("tr").item(3); 
   var CourseLTD = CourseTR.getElementsByTagName("td").item(0); 
   var bFile = FileLTD.getElementsByTagName("b").item(0);
   var bCourse = CourseLTD.getElementsByTagName("b").item(0);
   var rs = "*";
   
    var eahtid = document.getElementById("eahtfile_id");
    var courseid = document.getElementById("fk_course");
    if(eahtid)
    {
    eahtid.disabled=true;
    bFile.innerHTML="";
    }
    if(courseid)
    {
        courseid.disabled=true;   
        bCourse.innerHTML="";
    }
}


function CheckSnippetType(obj,msg)
{
    var frm = document.frmprth_0;  
    if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value == 4)
    {
        if(frm.fk_course.value==0)
        {
            alert("Please select course");
            frm.fk_course.focus();
            return false;
        }
    }
    else if(frm.text_snippets_type.value > 0 && frm.text_snippets_type.value != 4)
    {
        if(frm.eahtfile_id.value==0)
        {
            alert("Please select QuESt file");
            frm.eahtfile_id.focus();
            return false;
        }
    }
    else
    {
        return false;
    }
    return true;
}
function ChatDevice()
{
    document.write("<a href='javascript:OpenSkype();'><img src=\"images/skype_24.gif\" vspace=\"0\" style=\"\" align=\"absMiddle\" border=0 /></a>");
}
function check_eula(obj,cap)
{
    if(!obj.checked)
    {
        alert("Please read the  End User License Agreement and check the check box to accept it");
        return false;
    }
    return true;
}
function check_tos(obj,cap)
{
    if(!obj.checked)
    {
        alert("Please read the TOS Agreement and check the check box to accept it");
        return false;
    }
    return true;
}

/*
function AddQuota(str)
{
    var idx = 0;
    var temp = "";
    while (idx <= str.length) 
    {
        var ch = str.charAt(idx);
        if(ch == "'")
            temp += "\\'";
        else if(ch == '"')
            temp += '&quot;';
        else
            temp += ch;
        idx = idx+1;
    }
    return temp;
}*/


function showModalPopupViaClient(BehaviorID) 
{
    var modalPopupBehavior = $find(BehaviorID);
    //alert(BehaviorID + " - " + modalPopupBehavior);
    modalPopupBehavior.show();
}
function hideModalPopupViaClient(BehaviorID) 
{
    var modalPopupBehavior = $find(BehaviorID);
    modalPopupBehavior.hide();
    return false;
}
function AppendToDropDown(ControlID,Value,Caption,SetSlected)
{
	var index=$get(ControlID).options.length;
	$get(ControlID).options.length=index+1;
	$get(ControlID).options[index].value=Value;
	$get(ControlID).options[index].text=Caption;
	if(SetSlected==true)$get(ControlID).options.selectedIndex=index;
}


function ReturnObjectString(FilePath,Height,Width,IsLooping)
{
    if(!Height) Height="45";
    if(!Width) Width="400";
    PlayCountVal="1";
    if(IsLooping ==true) PlayCountVal="99999";
    
    //alert(Width + " - " + Height);
    
    return "<object id=\"ObjMediaPlayer\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"" + Width + "\" height=\"" + Height + "\"><param name=\"URL\" value=\"" + FilePath + "\" /><param name=\"AutoStart\" value=\"true\" /> <PARAM name=\"PlayCount\" value=\"" + PlayCountVal + "\"><embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/windows/mediaplayer/\" width=\""+Width+"\" height=\""+Height+"\" id=\"ObjMediaPlayer\" name=\"ObjMediaPlayer\" name=\"URL\" value=\""+FilePath+"\" autostart=\"true\" PlayCount=\"" + PlayCountVal + "\" /> </object>";
    //return "<object id=\"AudioMediaPlayer\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + Width + "\" height=\"" + Height + "\" type=\"application/x-shockwave-flash\"><param name=\"movie\" value=\"mp3player.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"flashvars\" value=\"file=" + FilePath + "&autostart=1\" /> <embed type=\"application/x-shockwave-flash\" src=\"mp3player.swf\" width=\""+Width+"\" height=\""+Height+"\" id=\"AudioMediaPlayer\" name=\"AudioMediaPlayer\" quality=\"high\" flashvars=\"file="+FilePath+"&autostart=1\" /> </object>";
}

function PauseMusicFile(id)
{
    //alert("PauseMusicFile - " + document.getElementById(id));
    document.getElementById(id).controls.pause();
}
function PlayMusicFile(id)
{
    //alert("PlayMusicFile - " + document.getElementById(id));
    document.getElementById(id).controls.play();
}


function replaceAll(str,from,to)
{
    var idx = str.indexOf(from);
    while (idx > -1) 
	{
        str = str.replace(from,to); 
        idx = str.indexOf(from);
    }
    return str;
}

function Trim(txt) {
	var strTmp = txt;
	//trimming from the front
	for (counter=0; counter<strTmp.length; counter++)
		if (strTmp.charAt(counter) != " ")
			break;
	//trimming from the back
	strTmp = strTmp.substring(counter,strTmp.length);
	counter = strTmp.length - 1;
	for (counter; counter>=0; counter--)
		if (strTmp.charAt(counter) != " ")
			break;
	return strTmp.substring(0, counter+1);
}

function RemoveDoubleSpace(obj)
{
    var valarr=obj.value.split(" ");
    var valstr=obj.value;
    if(valarr.length>0)
    {
        valstr="";
        for(i=0;i<valarr.length;i++)
        {
            if(valarr[i] != "" && valarr[i] != " ")
            {
                //alert(valarr[i]);
                valstr += " " + valarr[i];
            }
        }
        valstr=Trim(valstr);
    }
    obj.value=valstr;
}

function TrimValue(obj)
{
    obj.value=Trim(obj.value);
}

function righttrn(rightobj,leftobj,extraobj)
{
	if(rightobj.selectedIndex == -1 )return;
	if(extraobj)
	{
	    if(extraobj.value != "")
	    {
	        var currentval="," + extraobj.value + ",";
	        if(currentval.indexOf("," + rightobj[rightobj.selectedIndex].value + ",") > -1)
	        {
	            alert("This participant already added to this workgroup");
	            return;
	        }
	    }
	}		
	leftobj.options.length=leftobj.options.length+1;	
	selectedindex = rightobj.selectedIndex;
	if( selectedindex == -1 )return;
	if(extraobj)
	{
	    if(extraobj.value == "") extraobj.value=rightobj[selectedindex].value;
	    else extraobj.value += "," + rightobj[selectedindex].value;
	    //alert(extraobj.value);
	}
	leftobj.options[leftobj.options.length-1].text=rightobj[selectedindex].text;
	leftobj.options[leftobj.options.length-1].value=rightobj[selectedindex].value;
	for(var i=selectedindex; i<rightobj.options.length-1; i++)
	{
		rightobj.options[i].text=rightobj.options[i+1].text;
		rightobj.options[i].value=rightobj.options[i+1].value;
	}
	rightobj.options.length=rightobj.options.length-1;
}

function lefttrn(rightobj,leftobj)
{		
	if(leftobj.selectedIndex == -1 )return;
	rightobj.options.length=rightobj.options.length+1;		
	selectedindex = leftobj.selectedIndex;
	if( selectedindex == -1 )return;
	rightobj.options[rightobj.options.length-1].text=leftobj[selectedindex].text;
	rightobj.options[rightobj.options.length-1].value=leftobj[selectedindex].value;
	for(var i=selectedindex; i<leftobj.options.length-1; i++)
	{
		leftobj.options[i].text=leftobj.options[i+1].text;
		leftobj.options[i].value=leftobj.options[i+1].value;
	}
	leftobj.options.length=leftobj.options.length-1;	
}

function RedirectToDemoUser(querystr)
{
    document.getElementById("SPN_ProgreesMsg").style.display = "inline";
    location.replace(querystr);
}
function MoveLeftRight_DDItem(leftfieldobj,rightfieldobj)
{
	if( leftfieldobj.selectedIndex == -1 )return;
	for(i=0;i<rightfieldobj.length;i++)
    {
        if(rightfieldobj[i].value==leftfieldobj[leftfieldobj.selectedIndex].value)
        {
            alert("Sorry! field already exist in the Existing Field");
            return false;
        }
    }
    
	if(leftfieldobj.selectedIndex == -1 )return;		
	rightfieldobj.options.length=rightfieldobj.options.length+1;	
	selectedindex = leftfieldobj.selectedIndex;
	if( selectedindex == -1 )return;
	rightfieldobj.options[rightfieldobj.options.length-1].text=leftfieldobj[selectedindex].text;
	rightfieldobj.options[rightfieldobj.options.length-1].value=leftfieldobj[selectedindex].value;
	DeleteFromList(leftfieldobj);
}
function DeleteFromList(obj)
{
    var selectedindex=obj.selectedIndex;
    if( selectedindex == -1 )return;
    for(var i=selectedindex; i<obj.options.length-1; i++)
	{
		obj.options[i].text=obj.options[i+1].text;
		obj.options[i].value=obj.options[i+1].value;
	}
	obj.options.length=obj.options.length-1;	
}
function GetDropDopwnValues(objdrp,separator)//By Saurabh
{
	var rtnlist="";
	for(i=0;i<objdrp.length;i++)
	{
		rtnlist += separator+objdrp[i].value;
	}
	if(rtnlist!="")
	{
	    rtnlist=rtnlist.substring(rtnlist.length,1);
	}
	return rtnlist;
}
