var aryFrames = Array();
//aryFrames[0] = "submit_icontact.php";
//aryFrames[1] = "submit_listmarketer.php";
//aryFrames[2] = "submit_aweber.php";

top.fArray = Array();

function spawnFrame(strFileName){
	numFrames = top.fArray.length;
	var qstring = "";
	var frm = document.getElementById("theForm");
	for (i=0; i<frm.elements.length;i++){
		if (qstring.indexOf("?")==-1){
			qstring+="?";
		}
		else{
			qstring+="&";
		}
		qstring+= frm.elements[i].name+"="+frm.elements[i].value;
	}
	qstring+="&frm="+numFrames;
	top.fArray[numFrames]=false;
	ifrm = document.createElement("IFRAME");
	ifrm.setAttribute("src", strFileName+qstring);
	ifrm.setAttribute("name","frm"+numFrames);
	ifrm.setAttribute("id","frm"+numFrames);
	ifrm.setAttribute("title","nsa");
	ifrm.style.width = 1+"px";
	ifrm.style.height = 1+"px";
	document.body.appendChild(ifrm);
}

var mainForm;
function checkFrames(){
	var bool=true;
	for (i=0; i<aryFrames.length;i++){
		if(bool && top.fArray[i])
			bool=true;
		else bool=false;
	}
	if(bool){
		document.getElementById('theForm').submit();
	} else {
		setTimeout('checkFrames()', 1000);
	}
}

function submitForm(form){
	mainForm = form;
	for (var i in aryFrames) {
		spawnFrame(aryFrames[i]);
	}
	checkFrames();
	return false;
}
