var ua = navigator.userAgent.toLowerCase();
var win = ua.indexOf("win") != -1;
var mac = ua.indexOf("mac") != -1;
var ie = ua.indexOf("msie") != -1;
var ieosx = false;
if (mac && ie) {
	var ver = navigator.userAgent.match(/msie\s*([\d\.]+)/i);
	if (ver) ieosx = (parseFloat(ver[1]) >= 5.2);
}

var fp_done = false;
function Fp() {
	if (document.getElementById && !fp_done) {
		var objs = document.getElementsByTagName("img");
		for (var i=0; i<objs.length; i++) {
			var obj = objs[i];
			var png_src = obj.pngsrc;
			if (!png_src) {
				var att = obj.attributes;
				if (att) png_src = att.getNamedItem("pngsrc");
				if (png_src) png_src = png_src.value;
			}
			if (png_src) {
				if (document.all && win && typeof(obj.style.filter) != 'undefined') obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+png_src+"', sizingMethod='scale')";
				else if (win || (mac && !ie) || ieosx) obj.style.backgroundImage = 'url("'+png_src+'")';                  }
			}
		fp_done = true;
	}
}


function ShowSearchCriteria(search_type)
{
	ClearAll();
	
	if (search_type == 0)
	{
		tblAll.className = 'show';
		document.frmSearch.chkSearchAll.checked = true;
		
	}
	else if(search_type == 1)
	{
		tblCommittee.className = 'show';
		document.frmSearch.chkSearchCommittee.checked = true;
	}
	else if(search_type == 2)
	{
		tblMember.className = 'show';
		document.frmSearch.chkSearchMember.checked = true;
	}
	/*
	else if(search_type == 3)
	{
		tblEducation.className = 'show';
		document.frmSearch.chkSearchEducation.checked = true;
	}
	*/
	else if(search_type == 4)
	{
		tblDocument.className = 'show';
		document.frmSearch.chkSearchDocument.checked = true;
	}
}

function ClearAll()
{
	tblAll.className = 'hidden';
	document.frmSearch.chkSearchAll.checked = false;
	tblCommittee.className = 'hidden';
	document.frmSearch.chkSearchCommittee.checked = false;
	tblMember.className = 'hidden';
	document.frmSearch.chkSearchMember.checked = false;
	//tblEducation.className = 'hidden';
	//document.frmSearch.chkSearchEducation.checked = false;
	tblDocument.className = 'hidden';
	document.frmSearch.chkSearchDocument.checked = false;
}

function ShowHomeSearchCriteria(search_type)
{
	ClearHomeAll();
	
	if (search_type == 0)
	{
		tblAll.className = 'show';
		document.frmSearch.chkSearchAll.checked = true;
		
	}
	else if(search_type == 4)
	{
		tblDocument.className = 'show';
		document.frmSearch.chkSearchDocument.checked = true;
	}
}

function ClearHomeAll()
{
	tblAll.className = 'hidden';
	document.frmSearch.chkSearchAll.checked = false;
	tblDocument.className = 'hidden';
	document.frmSearch.chkSearchDocument.checked = false;
}

function DatePicker(thisForm,thisControl) 
{
	var url = "../UserControls/Calendars/CalendarPopup.aspx?FormName="+thisForm+"&ControlName="+thisControl;
	var w   = 231;
	var h   = 224; 
	if (document.all)var xMax = screen.width, yMax = screen.height;
	else
	{ if (document.layers) var xMax = window.outerWidth, yMax = window.outerHeight;
	else      var xMax = 640, yMax=480;
	}
	if (w>xMax) w = xMax * .9;
	if (h>yMax) h = yMax * .9;
	var l = (xMax - w)/2, t = (yMax-h)/2;
	handle_PUH = window.open(url,"DatePicker",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+w+',height='+h);
}


function viewSecuredDocument(document_id)
{
	var objIFrame = document.getElementById("ifDownload");
	
	if (objIFrame)
	{
		objIFrame.src = "/IAA/Templates/documentDownload.aspx?type=securedDocument&documentID=" + document_id;
	}
} 

function viewAssignmentUploadedDocument(candidate_number, assignment_id, course_id)
{
	var objIFrame = document.getElementById("ifDownload");
	
	if (objIFrame)
	{
		objIFrame.src = "/IAA/Templates/documentDownload.aspx?type=assignmentUploadFile&candidateNumber=" + candidate_number + "&assignmentID=" + assignment_id + "&courseID=" + course_id;
	}
} 

function viewAssignmentMarkingReport(assignment_id, course_id)
{
	var objIFrame = document.getElementById("ifDownload");
	
	if (objIFrame)
	{
		objIFrame.src = "/IAA/Templates/documentDownload.aspx?type=assignmentMarkingReport&assignmentID=" + assignment_id + "&courseID=" + course_id;
	}
}

function breadCrumbCSSClass()
{
	if(document.getElementById("BreadCrumb1_McmsBreadcrumbControl1"))
	{
		var htmlStr = document.getElementById("BreadCrumb1_McmsBreadcrumbControl1").innerHTML;
		while(htmlStr.indexOf("<A href=") != -1)
		{
			htmlStr = htmlStr.replace(/<A href=/i, "<A class='breadcrumb' href=")
		}
		
		document.getElementById("BreadCrumb1_McmsBreadcrumbControl1").innerHTML = htmlStr;
	}
}

function openPrinterFriendly(url)
{
	//var str = "/IAA/Templates/Education/PrinterFriendly.aspx?assignmentID=" + parseInt(assignmentID)+ "&candidateNumber=" + c;
	//var str = "/IAA/Templates/Education/PrinterFriendly.aspx?assignmentID=" + parseInt(assignmentID)+ "&candidateNumber=" + candidateNumber+ "&courseID=" + courseID;
	window.open(url,'popup','toolbar=yes,width=750,height=400,scrollbars=yes,resizeable=yes'); 
}

function xreplace(checkMe,toberep,repwith)
{
	alert("here: - "+ checkMe);
	var temp = checkMe;
	var i = temp.indexOf(toberep);
	while(i > -1)
	{
		temp = temp.replace(toberep, repwith);
		i = temp.indexOf(toberep, i + repwith.length + 1);
	}
	return temp;
}

function CheckKeysLogin()
{
	getEvent=event.keyCode;
	
    if (getEvent == "13")
    {
		document.all.item("btnLoginSubmit").click();
		return false;
    }
    else
    {
		return true;
    }
}
