//retreives values specified by the parameter request
function getArg(arg)
	 {
		if(location.search=='')
		{
			return ''
		}
		argstring=location.search.substring(1,location.search.length)+'&'
		argstringpos=argstring.indexOf(arg)
		
		if(argstringpos>-1)
		{
			argstring=argstring.substring(argstringpos,argstring.length)
			argstringpos=argstring.indexOf('&')
			argstring=argstring.substring(0,argstringpos)
			argstringpos=argstring.indexOf('=')
			argstring=argstring.substring(argstringpos+1,argstring.length)
			return argstring
		}
	}
var groupLaunchURL
var groupWinParams
// for group modules to retrived the group moudle main page

function LaunchGroupModuleList(){
	
		top.courseWindow = window.open(top.groupLaunchURL,null,top.groupWinParams);
		top.courseWindow.focus();
		top.reloadGroup=true;
}

function  reloadGroupModuleList(){

	if(top.reloadGroup){
		URLpath=top.groupLaunchURL.replace("../../LMS_Resources/","../LMS_Resources/")
		top.courseWindow = window.open(URLpath,null,top.groupWinParams);
		top.courseWindow.focus();
	}
	top.reloadGroup=false;
}

function launchGroupModule(path,username,courseID,userID,m_width,m_height,mid,actname,moduletype){
	
	var data=parent.dbase.document.LMSDetails;
	var flashback="../../LMS_Pages/LMS_OldModules.aspx";
	var actpath="";
	
	if (moduletype=="new")
	{
		actpath="../LMS_Resources/" + mid + "/";
	}
	else
	{
		actpath="../../LMS_Resources/" + mid + "/";
	}
	username = username.replace('^',' ');
	//alert(data+":"+parent.dbase.document.LMSDetails);
	data.location.value=mid;
	data.UID.value =userID;
	data.uname.value =username;
	data.ltime.value='';
	data.maxscore.value='';
	data.status.value=''
	data.totalscore.value='';
	data.summary.value='';
	data.totalscore.value='';
	data.submit();
	
	m_launchURL = path + "?course_id=" + courseID + 
				  "&user_id=" + userID + 
				  "&resource_path=" + actpath + 
				  "&module_id=" + mid + 
				  "&flashback_path=" + flashback + 
				  "&flashback_url=" + flashback + 
				  "&url_flashback=" + flashback + 
				  "&actname=" + actname+
				  "&ms=" + new Date().getTime();
	m_winParams = "width=" + m_width + ",height=" + m_height + ",status=no,toolbar=no,menubar=no,location=no,resizable=no";
	top.courseWindow = window.open(m_launchURL,null,m_winParams);
	top.courseWindow.focus();
	top.reloadGroup=true;
}
//
function LaunchModule(path,username,courseID,userID,MDL_WINWIDTH,MDL_WINHEIGHT,mid,actname,moduletype) 
{
	
	var data=parent.dbase.document.LMSDetails;
	var flashback="../../LMS_Pages/LMS_OldModules.aspx";
	var actpath="";
	
	if (moduletype=="new")
	{
		actpath="../LMS_Resources/" + mid + "/";
	}
	else
	{
		actpath="../../LMS_Resources/" + mid + "/";
	}
	username = username.replace('^',' ');
	//alert("?"+parent.dbase.document);
	data.location.value=mid;
	data.UID.value =userID;
	data.uname.value =username;
	data.ltime.value='';
	data.maxscore.value='';
	data.status.value=''
	data.totalscore.value='';
	data.summary.value='';
	data.totalscore.value='';
	//data.submit();
	
	launchURL = path + "?course_id=" + courseID + 
				"&user_id=" + userID + 
				"&resource_path=" + actpath + 
				"&module_id=" + mid + 
				"&flashback_path=" + flashback + 
				"&flashback_url=" + flashback + 
				"&url_flashback=" + flashback + 
				"&actname=" + actname+
				"&ms=" + new Date().getTime();;
	winParams = "width=" + MDL_WINWIDTH + ",height=" + MDL_WINHEIGHT + ",status=no,toolbar=no,menubar=no,location=no,resizable=no";
	top.courseWindow = window.open(launchURL,null,winParams);
	top.courseWindow.focus();
	
		// updatating the group vars to be used by the next module if it is in a group
	top.groupLaunchURL=launchURL.replace("../LMS_Resources/","../../LMS_Resources/")
	top.moduleId=mid;
	top.groupWinParams=winParams
}
	
//Toggles text
function toggle(targetId) 
{
	target = document.all(targetId);
	if (target.style.display == "none")
	{
		target.style.display="";
	} 
	else {
		target.style.display="none";
	}
}

function IsNumber(source,arguments)
{
  var ValidChars = "0123456789.";
  var Char;
  var sText=document.getElementById(ctrl).value;
  for (i = 0; i < sText.length; i++) 
  { 
    Char = sText.charAt(i); 
    if (ValidChars.indexOf(Char) == -1) 
    {
       arguments.IsValid = false;
       return;
    }
  }
  return;
}
