
function sizeCheck()
{	
	if ( screen.width <= 800 || screen.height <= 600 )
	{
			document.location.href = "Default.aspx?size=" + screen.width + "x" + screen.height;
	}
}

function search()
{	
	__doPostBack('_ctl0$topHeaderMenu$btnSearch','');
}

function ShowDiv(div)
{	
	var tmpPanel;

	if ( document.getElementById )
	{
		tmpPanel = document.getElementById(div)
		
		if ( tmpPanel != null )
		{						
			tmpPanel.style.display = "";
			tmpPanel.style.visibility = "visible";
		}
	}
}

function HideDiv(div)
{	
	var tmpPanel;
	
	if ( document.getElementById )
	{
		tmpPanel = document.getElementById(div)
		
		if ( tmpPanel != null )
		{						
			tmpPanel.style.display = "none";
			tmpPanel.style.visibility = "hidden";
		}
	}
}

function ShowHide(div)
{
	var tmpPanel;
		
	if ( document.getElementById )
	{
		tmpPanel = document.getElementById(div)
		
		if ( tmpPanel != null )
		{											
			if ( tmpPanel.style.display == "none" || tmpPanel.style.visibility == "hidden" )
			{
				ShowDiv(div);
			}
			else
			{
				HideDiv(div);
			}
		}
	}
}

function ShowHideGroup(div, id)
{	
	HideDiv('divAE_' + id);
	HideDiv('divFJ_' + id);
	HideDiv('divKO_' + id);
	HideDiv('divPT_' + id);
	HideDiv('divUZ_' + id);
	
	ShowDiv(div);
}

function ShowMenuDropDown(div)
{	
	ShowDiv(div);
}

function HideMenuDropDown(div)
{	
	HideDiv(div);
}

function ShowLeftBar()
{	
	ShowDiv('divPanel');
}

function HideLeftBar()
{
	HideDiv('divPanel');
}


function ShowBookingSummary(encId)
{
	ShowPopUpWindow('winBookCourse', 'CourseBookingSummary.aspx?id=' + encId, 600, 400, 'yes', 'no', 'yes');
}

function openCertDetails() {

	var referer = "";

	if (self.sampleReferer)
		referer = self.sampleReferer;
	else
		referer = window.location;
	
	certDetailsUrlWithReferer = "https://www.thawte.com/cgi/server/certdetails.exe?referer=" + referer;
	thewindow = window.open(certDetailsUrlWithReferer, "newWindow", config="height=500,width=516,toolbar=no,menubar=no," + "scrollbars=yes,resizable=no,location=no,directories=no,status=yes");

}
	
function isEmail(email) {
	var invalidCharString = " ,<>!\"?%^&*()+=*/\\\';:#~[]{}";
	var i = 0;
	
	for (i = 0; i < invalidCharString.length; i++) {
		if (-1 < email.indexOf(invalidCharString.charAt(i))) {
			return false;
		}
	}
	
	var firstAt = email.indexOf('@');
	var lastAt = email.lastIndexOf('@');
	var lastDot = email.lastIndexOf('.');
	if (!((0 < firstAt) && (1 < lastDot) && (firstAt == lastAt) && ((firstAt + 1) < lastDot) && (lastDot < (email.length - 2)))) 
	{
		return false;
	}
	else {
		return true;
	}
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function replace(string,text,by) {
	// Replaces 'text' with 'by' in 'string'
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function SetValue(id, newValue) {
	var identity=document.getElementById(id);
	identity.value=newValue;
}

function SetInnerHtml(id, newValue) {
	var identity=document.getElementById(id);
	identity.innerHTML=newValue;
}

function SetStyle(id, newClass) {
	var identity=document.getElementById(id);
	identity.className=newClass;
}

function AddStyle(id, newClass) {
	var identity=document.getElementById(id);
	if (identity.className != "false") {
		var style = identity.className;
		style = style + " " + newClass;
		identity.className = style;
	}
	else {
		identity.className = newClass;
	}
}

function RemoveStyle(id, oldClass) {
	var identity=document.getElementById(id);
	if (identity.className != "false") {
		var style = identity.className;
		style = replace(style,oldClass,"");
		identity.className = replace(identity.className,oldClass,"");
	}
}

function SetVisibility(id, visible) {
	var identity=document.getElementById(id);
	var style = "";
	if (identity.className) {
		style = identity.className;
	}
	if (visible) {
		style = replace(style,"hiddenElement","") + " visibleElement";
	}
	else {
		style = replace(style,"visibleElement","") + " hiddenElement";
	}
	identity.className = style;
}
			
function getRadioButtonValue(radioButtonArray) {
	var value = '';
	
	if (!radioButtonArray.length) {
		// Only one radio button, so form.radiobuttonname returns a radiobutton element, not an array
		if (radioButtonArray.checked) {
			value = radioButtonArray.value;
		}
	}
	else {
		for (var i=0; i<radioButtonArray.length; i++) {
			if (radioButtonArray[i].checked) {
				value = radioButtonArray[i].value;
				break;
			}
		}
	}
	
	return value;
}