// standard.js

function plainWindow(base_url,url,title,width,height) 
{
	var real_url = base_url + "popup.php?url=" + url + '&title=' + title;
	// alert(real_url);
	newWindow = window.open(real_url,'_blank',
			'top=150,left=150,status=0,resizable=1,scrollbars=0,toolbar=0,location=0,width='+width+',height='+height);
		newWindow.focus;
}

function popupWindow(url,width,height)
{
	newWindow = window.open(url,'_blank',
			'top=150,left=150,status=0,resizable=1,scrollbars=0,toolbar=0,location=0,width='+width+',height='+height);
	newWindow.focus;
}

function editPopupWindow(url,width,height)
{
	newWindow = window.open(url,'_blank',
			'top=150,left=150,status=0,resizable=1,scrollbars=0,toolbar=0,location=0,width='+width+',height='+height);
	newWindow.focus;
}

function databaseValue(field,sql)
{
	url = '/_handlers/database_value?sql='+escape(sql);
	strValue = window.showModalDialog(url,'','dialogWidth:0px;dialogHeight:0px;unadorned:yes;scroll:no;status:no');
	if (field)
		field.value = strValue;
}

function test1()
{
	alert('test');
}

function setDivHTML(div_id,html64)
{
	div = document.getElementById(div_id);
	div.innerHTML = base64_decode(html64);
}

function roundedCorners()
{
	var divs=document.getElementsByTagName('div');
	var rounded_divs=[]; 

	for (var i=0;i<divs.length;i++)
	{
		if (/\brounded\b/.exec(divs[i].className))
			rounded_divs[rounded_divs.length] = divs[i];
	}

	for (var i=0;i<rounded_divs.length;i++)
	{
		var original=rounded_divs[i];
		original.className=original.className.replace('rounded','');
		var tr=document.createElement('div');
		tr.className='rounded2';
		original.parentNode.replaceChild(tr,original);
		var tl=document.createElement('div');
		var br=document.createElement('div');
		tr.appendChild(tl);
		tl.appendChild(br);
		br.appendChild(original); 
	}
}

function radioValue(th)
{
	strValue='';

	for (var i=0;i<th.length;i++)
	{
		if (th[i].checked)
		{
			strValue=th[i].value;
			break;
		}
	}

	return(strValue);
}

function ajaxFunction(strURL)
{
	var xmlhttp;

	if      (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP.");
	}

	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState == 4)
		{
			document.myForm.time.value=xmlhttp.responseText;
		}
	}

	xmlhttp.open("GET",strURL,true);
	xmlhttp.send(null);
}

// DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)

function validEmail(str)
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);

	if (str.indexOf(at) == -1)
	{
		return false;
	}

	if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr)
	{
		return false;
	}

	if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr)
	{
		return false;
	}

	if (str.indexOf(at,(lat+1)) != -1)
	{
		return false;
	}

	if (str.substring(lat-1,lat) == dot || str.substring(lat+1,lat+2) == dot)
	{
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false;
	}

	if (str.indexOf(" ") != -1)
	{
		return false;
	}

	return true;
}
