// Original JavaScript code by Duncan Crombie: dcrombie at chirp.com.au
// Please acknowledge use of this code by including this header.

  var today = new Date();
  var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

  function getCookie(name) { // use: getCookie("name");
    var re = new RegExp(name + "=([^;]+)");
    var value = re.exec(document.cookie);
    return (value != null) ? unescape(value[1]) : null;
  }

  function setCookie(name, value) { // use: setCookie("name", value);
    document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
  }
  
  function TestCookie(ErrMsg)
  {
	var		tmp		= "";
	setCookie("lwcookietest", "true");
	tmp				= getCookie("lwcookietest");
	if(tmp != "true")
	{
		alert(ErrMsg);
		document.location.href	= "splash.aspx";
	}
  }


function exitSys() {
	window.open("exitSys.aspx",'Course','width=10,height=10,location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no');
}
function reload(country){
	window.location.href = "register.aspx?intCountry="+country;	
}

function enterCourse(link,h,w,r,s) {
//def height=540, width=780,resizable=no
	window.open(link,'Course','width='+w+',height='+h+',location=no,menubar=no,directories=no,toolbar=no,scrollbars='+s+',resizable='+r+',status=no');
}

function viewDemo(link) {
	window.open(link,'Demo','width=588,height=416,location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no');
}

function openPopup(link,name,style) {
	window.open(link,name,style);
}


function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function checkSettings(){
	var outp ="";
	if(document.forms["accForm"].intLanguage.value=="0")
	{
		outp+="Chose Language!\n";
	}

	if(document.forms["accForm"].strEmail.value!=document.forms["accForm"].strEmail2.value)
	{
		outp+="Your E-Mail adress is not matching!\n";
	}

	if(document.forms["accForm"].strEmail.value==""||document.forms["accForm"].strEmail2.value=="")
	{
		outp+="Your E-Mail adress is empty!\n";
	}	

	if(document.forms["accForm"].strTitle.value=="0")
	{
		outp+="Choosa a title!\n";
	}
	
	if(outp!="")
	{
		alert(outp);	
		return false;
	}else
	{
		return true;
	}
}

function ConfirmDel(intid)
{
	 if (confirm("Are you sure you want to delete this user?"))
	 {
	 	location.href = "deluser.aspx?intId="+intid;
	 }
}

function ConfirmDelete(id)
{
	if(id!=0)
	{
		return confirm('Are you sure you want to delete this user?');
	}
	else
	{
		return false;
	}
}

function OpenMessage(_sender)
{
	window.open("openmessage.aspx?intSender=" +_sender, 'OpenMessage' + _sender, 'width=400,height=300,location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=yes');
//	window.location.reload();
}

function ViewClassmate(_sender)
{
	var	intX	= (screen.width - 400) / 4;
	var	intY	= (screen.height - 300) / 2;
	window.open("viewclassmate.aspx?intUserId=" + _sender, 'ViewClassmate', 'top=' + intX + ',' + 'left=' + intY + ',' + 'width=400,height=300,location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=yes');
//	window.location.reload();
}

function CheckMsg(_form)
{
	if(document.forms["MyForm"].strMessage.value=="")
	{
		return false;
	}
	else
	{
		return true;
	}
}
function EnrollCourse(_course)
{
	window.location.href ="enroll.aspx?intCourseId="+_course;
}

function ShowHide(_var)
{
	if(document.getElementById(_var).className=="container_top_open")
	{
		document.getElementById(_var).className="container_top_closed";
		document.getElementById("Data"+_var.charAt(_var.length-1)).className = "container_content_hidden";
	}
	else
	{
		document.getElementById(_var).className="container_top_open";
		document.getElementById("Data"+_var.charAt(_var.length-1)).className = "container_content";
		
	}
}
function IsNumberOnly(param)
{
	var valid = true;
	var check = "0123456789";
	for(i=0;param.length;i++)
	{
		ch = param.charAt(i);
		if(check.indexOf(ch)==-1)
		valid = false;
		break;
	}
	if(param.length==0)
		valid = false;
		
	return valid;
}

function startClock()
{
	alert("startclock");
	setInterval('RefreshHidden()', 30000);
//	var	timer = setTimeout('RefreshHidden()',30000);
}
function RefreshHidden()
{
	 top.hidden.location = 'hidden.aspx';
	 window.status = 'Link to Server Refreshed ' + now.getDate(); 
}

