/*
Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

function upload_validation_check(form, file)
{
	allowSubmit = true;
	//if (!file) return;

	//x= file.match(/[\'|;|&|\^|\%|\$|#|\/|\*|\?|\"|\<|\>|\|]/g);
	//alert("fm="+x);

	if (file.match(/[\'|;|&|\^|\%|\$|#|\/|\*|\?|\"|\<|\>|\|]/g))
	{
		allowSubmit = false;
	}

	if (allowSubmit) 
	{
		form.submit();
	}
	else
	{
		alert("Illegal character detected:\n \' ; ^ % $ # & / * ? \" < > |\n Please do not use in filename." );
	}
}

function showFiles(str)
{
	alert("str="+str);
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="administrator/components/com_broker/phpupload/getfiles.html";
alert("url0="+url);
url=url+"?q="+str;
url=url+"&sid="+Math.random();
alert("url="+url);
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtUploads").innerHTML=xmlhttp.responseText;
}
}

/* Art 05.26.11 Add Format Currency */
function formatCurrency(num) 
{
	num = num.toString().replace(/\$|\,/g,"");
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+","+
	num.substring(num.length-(4*i+3));
	return (((sign)?"":"-") + "$" + num + "." + cents);
}

/* Art 06.09.10 Custom JS for FORMS */
function quick_form_verify()
{
	var valid=0;
	msg = "Please fill out all fields.";
	if ((document.getElementById("email").value == "") || (document.getElementById("email").value == null))
	{
		valid++;
	}
	if ((document.getElementById("pass").value == "") || (document.getElementById("pass").value == null))
	{
		valid++;
	}
	if ((document.getElementById("confirm").value == "") || (document.getElementById("confirm").value == null))
	{ 
		valid++;
	}
	if (document.getElementById("pass").value != document.getElementById("confirm").value )
	{
		msg = "Password and Confirm does not match.";
		valid++;
	}
		
	if (valid > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
	
	//alert("document.frm_open.account_type="+document.frm_open.account_type);
	
	/*if (document.frm_open.account_type == "Copywriter")
	{
		document.frm_open.action = "/login/";
	}
	else
	{
		document.frm_open.action = "/thank-you.html";
	}*/
}

function quick_form_verify2()
{
	var valid=0;
	msg = "Please fill out all fields.";
	if ((document.getElementById("qfname").value == "") || (document.getElementById("qfname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("qlname").value == "") || (document.getElementById("qlname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("qemail").value == "") || (document.getElementById("qemail").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("qtel1").value == "") || (document.getElementById("qtel1").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("qtel2").value == "") || (document.getElementById("qtel2").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("qtel3").value == "") || (document.getElementById("qtel3").value == null))
	{ 
		valid++;
	}
		
	if (valid > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
}

function quick_form_verify3()
{
	var valid=0;
	msg = "Please fill out all fields.";
	
	//alert("qfv="+valid);
	if ((document.getElementById("ifname").value == "") || (document.getElementById("ifname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("ilname").value == "") || (document.getElementById("ilname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("ibname").value == "") || (document.getElementById("ibname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("iemail").value == "") || (document.getElementById("iemail").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("iphone1").value == "") || (document.getElementById("iphone1").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("iphone2").value == "") || (document.getElementById("iphone2").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("iphone3").value == "") || (document.getElementById("iphone3").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("heard_about_us").value == "") || (document.getElementById("heard_about_us").value == null))
	{
		valid++;
	}
	
	//alert("qfv2="+valid);
		
	if (valid > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
}

function quick_form_verify4()
{
	var valid=0;
	msg = "Please fill out all fields.";
	if ((document.getElementById("gfname").value == "") || (document.getElementById("gfname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("glname").value == "") || (document.getElementById("glname").value == null))
	{
		valid++;
	}
	if ((document.getElementById("gemail").value == "") || (document.getElementById("gemail").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("gphone1").value == "") || (document.getElementById("gphone1").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("gphone2").value == "") || (document.getElementById("gphone2").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("gphone3").value == "") || (document.getElementById("gphone3").value == null))
	{ 
		valid++;
	}
	if ((document.getElementById("heard_about_us").value == "") || (document.getElementById("heard_about_us").value == null))
	{
		valid++;
	}
		
	if (valid > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
}
