// Functions for Changing images and display/hide corresponding div */
function changemouseOverEffect(ID)
{
	document.getElementById(ID).style.display = 'block';
	document.getElementById('dummy').style.display = 'none';
}
function changemouseOutEffect(ID)
{
	document.getElementById(ID).style.display = 'none';
	document.getElementById('dummy').style.display = 'block';
}

// Functions to trim feilds
function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}
// Function to validate email
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pat.test(tmpStr));
}
//------------------------------------------------------------------------------------
// Open an image in a pop up
//------------------------------------------------------------------------------------
function viewImage(imgURL)
{
	newWindow = window.open("","newWindow","titlebar=no,width=50,height=50,left=25,top=25,scrollbars=1");
	var doc = newWindow.document;
	doc.open();
	doc.write('<html>\n');
	doc.write('<head>\n');
	doc.write('<title>View Image</title>\n');
	doc.write('<meta http-equiv="imagetoolbar" content="no">\n');
	doc.write('</head>\n');
	doc.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" ondblclick="self.close();"  onblur="self.close();" onload="javascript:window.resizeTo(document.getElementById(\'theImage\').width + 10, document.getElementById(\'theImage\').height + 50)">\n');
	doc.write('<img src=\"'+imgURL+'\" alt=\"File: '+imgURL+'\n(Double Click to Close)\" border="0" name="theImage" id="theImage" />\n');
	doc.write('</body>\n');
	doc.write('</html>\n');
	newWindow.focus();
	doc.close();
}

function doDownload(fname)
{
	parent.frames['downloader'].location.href = 'download.php?file='+encodeURIComponent(fname);
}

