  var fid_active = 0;
  function win(txt) { window.status = txt; return true;}
  function CheckAll() {
	for (var i=0;i<document.oForm.elements.length;i++) {
		var e = document.oForm.elements[i];
		if ((e.name != 'allbox') && (e.name != 'nocheck') && (e.type=='checkbox')) {
			e.checked = document.oForm.allbox.checked;
		}
	}
  }
  function CheckCheckAll() {
	var TotalBoxes = 0;
	var TotalOn = 0;
	for (var i=0;i<document.oForm.elements.length;i++) {
		var e = document.oForm.elements[i];
		if ((e.name != 'allbox') && (e.name != 'nocheck') && (e.type=='checkbox')) {
			TotalBoxes++;
			if (e.checked) {
				TotalOn++;
			}
		}
	}
	if (TotalBoxes==TotalOn) {
		document.oForm.allbox.checked=true;
	} else {
		document.oForm.allbox.checked=false;
	}
  }

	function toggleTable(el) {
	
	  var myelement = document.getElementById(el);
	  var myimg	= document.getElementById(el + "-img");
	  var myul = document.getElementById(el + "-ul");

	
	  if( !myelement.style.display || myelement.style.display == "none" ) {
	  	myimg.className = "min";
		myelement.style.display = "inline";
		myul.className = "white";
	  } else {
	  	myimg.className = "max";
		myelement.style.display = "none";
		myul.className = "grey";
	  }
	} 
	
	function showHide(id, img) {
		if (document.getElementById(id).style.display == "none") {
			document.getElementById(id).style.display = "inline";
			document.getElementById(img).className = "min";
		} else {
			document.getElementById(id).style.display = "none";
			document.getElementById(img).className = "max";
		}
	}
	
	function showBox(id, img) {
		if (document.getElementById(id).style.display == "none") {
			document.getElementById(id).style.display = "inline";
			document.getElementById(img).className = "min";
		}
	}	
	
	function cColor(id, num) {
		return alert("mouseover");
		if(num == 1) {
			document.getElementById(id).className = "titleOver";
		} else {
			document.getElementById(id).className = "titleOut";		
		}
	}
	
	
	function checkState() {
		var mValue = document.newCampaign.costType[document.newCampaign.costType.selectedIndex].value;

		if(mValue == "5") {
			document.getElementById("timeFrame").style.display = "inline";
			document.getElementById("sdmm").focus();
		} else {
			document.getElementById("timeFrame").style.display = "none";		
		}
	}
	
	function doTab(id, next, num) {
		var mLength = document.getElementById(id).value.length;
		if(mLength == num) {
			document.getElementById(next).focus();
		}	
	}
	


	function AddLanding(){
		if(load==false){
			if(land_count<=25){
				var container = document.getElementById("landing");
				var input = document.createElement("INPUT");
				var percentage = document.createElement("INPUT");
				input.type="text";
				input.style.width="200px";
				input.name="svar[c_url]["+(land_count+1)+"]";
				input.setAttribute("name","svar[c_url]["+(land_count+1)+"][url]");
				input.value="http://";
				percentage.type="text";
				percentage.style.width="22px";
				percentage.maxlength="3";
				percentage.name="svar[c_url]["+(land_count+1)+"][percentage]";
				percentage.value="0";
				var ws1 = document.createElement("SPAN");
				var ws2 = document.createElement("SPAN");
				var per = document.createElement("SPAN");
				var br = document.createElement("BR");
				var link = document.createElement("A");
				var link_caption = document.createTextNode("Delete");
				link.href="#";
				link.id="link_"+land_count;
				link.onclick = new Function ("removeLanding('"+land_count+"');");
				input.id="url_"+land_count;
				percentage.id="percentage_"+land_count;
				br.id="br_"+land_count;
				per.innerHTML = "%";
				ws1.innerHTML = "&nbsp;";
				ws2.innerHTML = "&nbsp;::&nbsp;";
				per.id="per_"+land_count;
				ws1.id="ws1_"+land_count;
				ws2.id="ws2_"+land_count;

				link.appendChild(link_caption);
				container.appendChild(input);
				container.appendChild(ws1);
				container.appendChild(percentage);
				container.appendChild(per);
				container.appendChild(ws2);
				container.appendChild(link);
				container.appendChild(br);
				land_count++;
			}else{
				alert("The maximum quantity of landung pages is achieved.");
			}
		}else{
			land_count=1;
			if(typeof(url_array) == "object"){
				var container = document.getElementById("landing");
				for(var index in url_array){
					var input = document.createElement("INPUT");
					var percentage = document.createElement("INPUT");
					input.type="text";
					input.style.width="200px";
					input.name="svar[c_url]["+(land_count)+"]";
					input.setAttribute("name","svar[c_url]["+(land_count)+"][url]");
					input.value=url_array[index]["url"];
					percentage.type="text";
					percentage.style.width="22px";
					percentage.maxlength="3";
					percentage.name="svar[c_url]["+(land_count)+"][percentage]";
					percentage.value=url_array[index]["percentage"];
					var ws1 = document.createElement("SPAN");
					var ws2 = document.createElement("SPAN");
					var per = document.createElement("SPAN");
					var br = document.createElement("BR");
					var link = document.createElement("A");
					var link_caption = document.createTextNode("Delete");
					br.id="br_"+land_count;
					link.href="#";
					link.id="link_"+land_count;
					link.onclick = new Function ("removeLanding('"+land_count+"');");
					input.id="url_"+land_count;
					percentage.id="percentage_"+land_count;
					per.innerHTML = "%";
					ws1.innerHTML = "&nbsp;";
					ws2.innerHTML = "&nbsp;::&nbsp;";					
					per.id="per_"+land_count;
					ws1.id="ws1_"+land_count;
					ws2.id="ws2_"+land_count;
					
					link.appendChild(link_caption);
					container.appendChild(input);
					container.appendChild(ws1);
					container.appendChild(percentage);
					container.appendChild(per);
					if(land_count>1){
						container.appendChild(ws2);
						container.appendChild(link);
					}
					container.appendChild(br);
					land_count++;
				}
				load = false;
			}
		}
		return false;
	}

	function removeLanding(id){
		var div = document.getElementById("landing");
		div.removeChild(document.getElementById("url_"+id));
		div.removeChild(document.getElementById("percentage_"+id));
		div.removeChild(document.getElementById("link_"+id));

		div.removeChild(document.getElementById("per_"+id));
		div.removeChild(document.getElementById("ws1_"+id));
		div.removeChild(document.getElementById("ws2_"+id));
		div.removeChild(document.getElementById("br_"+id));
		return false;
	}

	function changeTimeDate(id1, id2) {
		document.getElementById(id1).style.display = "inline";
		document.getElementById(id2).style.display = "none"; 
	}
		
	function changeAction() {
		if(document.getElementById('actionType').style.display == "inline") {
			document.getElementById('actionType').style.display = "none";
			document.getElementById('cost').disabled = false;
		} else {
			document.getElementById('actionType').style.display = "inline";
			document.getElementById('cost').disabled = true;
		}
	}
	
	function changeSA() {
		if(document.getElementById('action').style.display == "inline") {
			document.getElementById('action').style.display = "none";
			document.getElementById('sale').style.display = "inline";
		} else {
			document.getElementById('action').style.display = "inline";
			document.getElementById('sale').style.display = "none";
		}
	}	
	
	function newWin(u,n,f) {
	  window.open(u,n,f);
	}	
	
	function doPrint() {
		window.print();  
	}
	
	function pw(){
		window.open('?forgot','','width=270,height=120,left=10,top=10,status=no,toolbar=no,menubar=no,scrollbars=yes');
	}
	
	function ip(ip){
		window.open('?ip_check_sm&ip='+ip,'ip_search','width=350,height=75,left=10,top=10,status=no,toolbar=no,menubar=no,scrollbars=no,resize=no,alwaysRaised');
	}

	function ip_history(ip){
		window.open('?fraud_ip_history&ip='+ip,'ip_history_popup','');
	}

	function new_popup(url, name, style){
		if(url!=''){
			window.open(url,name,style);
		}else{
			alert("JS error. enter destination url")
		}
	}
