customQuery = ""
customCode = ""

function ExecuteChanges(colorUpdate)
{

 	if(colorUpdate == 1 && document.getElementById("bgColor").value.length != 7 && document.getElementById("bgColor").value.length >1 )
		return;

	if((colorUpdate == 1) && (document.getElementById("bgImg").value.length < 12) && (document.getElementById("bgImg").value.length >0))
		return;
	
	iframeObj = document.getElementById("graphIframe");
	iframeObj.src = "http://omgili.com/graph.search?" + customQuery;
	
	
}
function UpdateValues()
{
 	customQuery = ""
	customCode = "<IFRAME "
 	
	
	customQuery += "d=" + document.getElementById("graphType").value + "&";
	
	customQuery += "graph=" + document.getElementById("graphStyle").value + "&";
	customQuery += "tf=" + document.getElementById("timeFrame").value + "&";

	customQuery += "qa=" + encodeURI(document.getElementById("qa").value) + "&";
	customQuery += "qb=" + encodeURI(document.getElementById("qb").value) + "&";
	customQuery += "qc=" + encodeURI(document.getElementById("qc").value) + "&";
	customQuery += "qd=" + encodeURI(document.getElementById("qd").value) + "&";
	customQuery += "qe=" + encodeURI(document.getElementById("qe").value) + "&";
	
	customQuery += "la=" + encodeURI(document.getElementById("la").value) + "&";
	customQuery += "lb=" + encodeURI(document.getElementById("lb").value) + "&";
	customQuery += "lc=" + encodeURI(document.getElementById("lc").value) + "&";
	customQuery += "ld=" + encodeURI(document.getElementById("ld").value) + "&";
	customQuery += "le=" + encodeURI(document.getElementById("le").value) + "&";
	
	customQuery += "canvasBgAlpha=30&"

	switch(document.getElementById("graphSize").value)
	{
	 	case '0':
			 if(document.getElementById("displyForm").value == 2 || document.getElementById("displyForm").value == 1)
			 {
			 	document.getElementById("displyForm").value = 0
			 }
			 customQuery += "width=250&height=225&" 
			 customCode += "WIDTH=\"250\" HEIGHT=\"275\""
			 break;
		case '1':
			 if(document.getElementById("displyForm").value == 2)
			 {
			 	document.getElementById("displyForm").value = 1
			 }
			 	
			 customQuery += "width=360&height=260&" 
			 customCode += "WIDTH=\"360\" HEIGHT=\"310\""
			 break;
		case '2':
			 customQuery += "width=500&height=350&" 
			 customCode += "WIDTH=\"500\" HEIGHT=\"400\""
			 break;
	}
	
	customQuery += "formType=" + document.getElementById("displyForm").value + "&";

	if(document.getElementById("bgColor").value.length == 7)
		customQuery += "bgColor=" + document.getElementById("bgColor").value.replace("#","") + "&";
	if(document.getElementById("bgImg").value.length > 12)
		customQuery += "bgSWF=" + document.getElementById("bgImg").value;
	
	customCode += " SRC=\"http://omgili.com/graph.search?" + customQuery + "\""
	customCode += " FRAMEBORDER=\"0\"></IFRAME>";
	document.getElementById("htmlTxt").value = customCode
	document.getElementById("permLink").href = "http://omgili.com/graph.search?" + customQuery
	
}

function UpdateGraphStyle()
{
 	if(document.getElementById("graphType").value == 0)
	 	document.getElementById("graphStyleID").innerHTML = document.getElementById("sGraphStyles").innerHTML;
	else
		document.getElementById("graphStyleID").innerHTML = document.getElementById("dGraphStyles").innerHTML;
}