var x=1;
function dims(val, name) {
	if (val=="Other") { document.getElementById(name + '_' + 'otherdims').style.display = 'block'; }
	else { 
		document.getElementById(name + '_' + 'otherdims').style.display = 'none';
		document.getElementById('b' + x + 'otherdimensions').value = '';
	}
}

function format(val, name) {
	if (val=="Other") { document.getElementById(name + '_' + 'otherfor').style.display = 'block'; }
	else { 
		document.getElementById(name + '_' + 'otherfor').style.display = 'none'; 
		document.getElementById('b' + x + 'otherformat').value = '';
		}
}

function addbanner(){
	x++;
	var txt = '';
	txt = txt +  '<fieldset class="fieldset" style="display:block;">';
	txt = txt +  '  <legend class="legend">Banner</legend>';
	txt = txt +  '    <img id="minus"' + x + ' src="minus.jpg" onclick=removebanner("' + x + '"); style="margin-left:550px;">';
	txt = txt +  '  <table class="table" width="400px" cellpadding="2" cellspacing="2" border="0">';
	txt = txt +  '    <tr>';
	txt = txt +  '      <td class="r1">Banner Format</td>';
	txt = txt +  '      <td class="r2">';
	txt = txt +  '        <select name="b' + x + 'format" onChange="format(this.value, this.name);">';
	txt = txt +  '          <option value="Static">Static</option>';
	txt = txt +  '          <option value="Flash">Flash</option>';
	txt = txt +  '          <option value="Expandable">Expandable</option>';
	txt = txt +  '          <option value="Floater to Fixed">Floater to Fixed</option>';
	txt = txt +  '          <option value="Sliding Billboard">Sliding Billboard</option>';
	txt = txt +  '          <option value="Video">Video</option>';
	txt = txt +  '          <option value="Other">Other</option>';
	txt = txt +  '        </select>';
	txt = txt +  '      </td>';
	txt = txt +  '    </tr>';
	txt = txt +  '  </table>';
	txt = txt +  '  <table class="table" width="400px" cellpadding="0" cellspacing="0" border="0">';
	txt = txt +  '    <tr id="b' + x + 'format_otherfor" style="display:none;">';
	txt = txt +  '  		<td class="r1">Enter Format:</td>';
	txt = txt +  '      <td class="r2"><input type="text" id="b' + x + 'otherformat" name="b' + x + 'otherformat" size="20" /></td>';
	txt = txt +  '    </tr>';
	txt = txt +  '  </table>';
	txt = txt +  '  <table class="table" width="400px" cellpadding="2" cellspacing="2" border="0">';
	txt = txt +  '    <tr>';
	txt = txt +  '      <td class="r1">Banner Dimensions</td>';
	txt = txt +  '      <td class="r2">';
	txt = txt +  '        <select name="b' + x + 'dimensions" onchange="dims(this.value, this.name);">';
	txt = txt +  '          <option value="300x250">300x250</option>';
	txt = txt +  '          <option value="728x90">728x90</option>';
	txt = txt +  '          <option value="160x600">160x600</option>';
	txt = txt +  '          <option value="120x600">120x600</option>';
	txt = txt +  '          <option value="300x600">300x600</option>';
	txt = txt +  '          <option value="Other">Other</option>';
	txt = txt +  '        </select>';
	txt = txt +  '      </td>';
	txt = txt +  '    </tr>';
	txt = txt +  '	</table>';
	txt = txt +  '	<table class="table" width="400px" cellpadding="0" cellspacing="0" border="0">';
	txt = txt +  '    <tr id="b' + x + 'dimensions_otherdims" style="display:none;">';
	txt = txt +  '			<td class="r1">Enter Size:</td>';
	txt = txt +  '      <td class="r2"><input type="text" id="b' + x + 'otherdimensions"  name="b' + x + 'otherdimensions" size="20" /></td>';
	txt = txt +  '    </tr>';
	txt = txt +  '	</table>';
	txt = txt +  '	<table class="table" width="400px" cellpadding="2" cellspacing="2" border="0">';
	txt = txt +  '    <tr>';
	txt = txt +  '      <td class="r1">Creative Instructions</td>';
	txt = txt +  '      <td class="r2"><textarea name="b' + x + 'instructions" wrap="hard" cols="45" rows="3"></textarea></td>';
	txt = txt +  '    </tr>';
	txt = txt +  '    <tr>';
	txt = txt +  '      <td class="r1">Banner Max File Size</td>';
	txt = txt +  '      <td class="r2"><input type="text" name="b' + x + 'filesize" size="20" /></td>';
	txt = txt +  '    </tr>';
	txt = txt +  '    <tr>';
	txt = txt +  '      <td class="r1">Banner Click Through</td>';
	txt = txt +  '      <td class="r2"><input type="text" name="b' + x + 'click" size="20" /></td>';
	txt = txt +  '    </tr>';
	txt = txt +  '    <tr>';
	txt = txt +  '      <td class="r1">Published Flash Version</td>';
	txt = txt +  '      <td class="r2">';
	txt = txt +  '        <select name="b' + x + 'version">';
	txt = txt +  '          <option value="Flash 6" selected="selected">Flash 6</option>';
	txt = txt +  '          <option value="Flash 7">Flash 7</option>';
	txt = txt +  '          <option value="Flash 8" selected>Flash 8</option>';
	txt = txt +  '          <option value="Flash 9">Flash 9</option>';
	txt = txt +  '          <option value="Flash 10">Flash 10</option>';
	txt = txt +  '        </select>';
	txt = txt +  '      </td>';
	txt = txt +  '    </tr> ';
	txt = txt +  '     <tr>';
	txt = txt +  '      <td class="r1">File Upload</td>';
	txt = txt +  '      <td class="r2"><input type="file" name="b' + x + 'file" size="20" /></td>';
	txt = txt +  '    </tr>';
	txt = txt +  '  </table>';
	txt = txt +  '  </fieldset>';
	var d = document.createElement('div');
	d.id = "child" + x;
	d.innerHTML=txt;
	document.getElementById('morebanners').appendChild(d);
	
	//TO TRACK NUMBER OF BANNERS
	document.uploader.bannercount.value=x;
}

function removebanner(y) { 
	var kill = "child" + y;
	document.getElementById(kill).innerHTML="";
}

function validate() {
	if (document.uploader.name.value != "" && document.uploader.phone.value != "" &&  document.uploader.email.value != "" && document.uploader.website.value != "" && document.uploader.cname.value != "" && document.uploader.duedate.value != "") {
  	document.uploader.submit();
	}
	else { 
		alert("Your Information and Campaign Information must be filled out."); 
	}
}
