{include file="header.tpl"}
<div class="box">
<div class="box_title" id="tba">Advertise Your Banner With Us</div>
<div class="box_body">
<script type="text/javascript" src="{"js/advertise.js"|encurl}"></script>
<table cellspacing=1 cellpadding=2 border=0 width=100%>
<tr><td colspan="5"><b style="color:green">We Currently Offers Banner Advertising:</b><br></td></tr>
<tr><th class="title">Ads Type</th>
<th class="title" align="center">Type</th>
<th class="title" align="center">Price / 7 days</th>
<th class="title" align="center">Available Slots</th>
<th class="title" align="center">Max Slots</th></tr>
{section name=ad loop=$allads}
<tr bgcolor={if $smarty.section.ad.rownum % 2 == 0}#FFFFFF{else}#F2F2F2{/if}>
<td><b>{$allads[ad].name}</b></td>
<td align="center">{$allads[ad].type}</td>
<td align="center"><font color="green">{if $allads[ad].minprice}${$allads[ad].minprice}-{/if}${$allads[ad].price}</font></td>
<td align="center">{$allads[ad].available}</td>
<td align="center">{$allads[ad].slot}</td>
</tr>
{/section}
<tr><td colspan="5" align="center" style="padding:15px 0 15px 0;">We accept <img src="{"images/LibertyReserve.gif"|encurl}"><b>{$settings.lracc}</b>  
 &nbsp; <img src="{"images/PerfectMoney.gif"|encurl}"><b>{$settings.perfectmoney_acc}</b></td></tr>
</table>
{if $errors}
<ul style="color:red">
{if $errors.turing}<li> Invalid turing image.</li>{/if}
{if $errors.email}<li> Please enter your e-mail addresss.</li>{/if}
{if $errors.invalid_email}<li> Please enter valid e-mail address.</li>{/if}
{if $errors.busy}<li> Sorry, This Ad place is not available now.</li>{/if}
</ul>
{/if}
<table cellSpacing=0 cellPadding=3 width="100%" style="border: 1px dotted #CCCCCC;">
<form name="frm" method="post" onsubmit="return validate(this)"> 
<input type=hidden name="a" value="advertise">
<input type=hidden name="action" value="preview">
<tr><td align="right"><b>Ad Type: </b></td>
<td><select name="ad_type" id="ad_type" class="inpts" onchange="change_AD(this.value);">
{section name=ads loop=$allads}<option value="{$allads[ads].id}"{if $frm.ad == $allads[ads].id || $frm.ad_type == $allads[ads].id} selected{/if}>{$allads[ads].name}</option>{/section}</select></td></tr>

{section name=x loop=$allads}{if $allads[x].type == 'Non-Rotating'}
<tr id="pos_{$allads[x].id}"><td align="right"><b>Ad Place:</b></td><td>
<select name="position[{$allads[x].id}]" class="inpts" onchange="SetPrice();">
{section name=y loop=$allads[x].slot}{if in_array($smarty.section.y.rownum,$allads[x].sold)}<option value="Sold">{$smarty.section.y.rownum}</option>{else}<option value="{$smarty.section.y.rownum}">{$smarty.section.y.rownum}</option>{/if}{/section}</select><span id="sold_{$allads[x].id}"></span></td></tr>
{/if}{/section}

<tr><td align="right"><b>Ad Period :</b></td>
<td><input type="text" class="inpts" onchange="SetPrice();" size="4" value="{$frm.ad_time|default:1}" name="ad_time" style="text-align:center">&nbsp;&nbsp; 
<input name="ad_time_type" type="radio" onclick="SetPrice();" value="Week" checked> &nbsp;<b>Weeks</b>&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="SetPrice();" type="radio" value="Month" name="ad_time_type">&nbsp;<b>Months</b></td></tr>
<tr><td align="right"><b>Program Name :</b></td>
<td><input type="text" class="inpts" size="40" name="ad_site_name" value="{$frm.ad_site_name|escape:html}"></td></tr>
<tr><td align="right"><b>Website Url :</b></td>
<td><input type="text" class="inpts" size="45" name="ad_site_url" value="{$frm.ad_site_url|escape:html}"></td></tr>
<tr><td align="right"><b>Banner Url :</b></td>
<td><input type="text" class="inpts" size="45" name="ad_banner_url" value="{$frm.ad_banner_url|escape:html}"> <span id="bsize"></span></td></tr>
<tr><td align="right"><b>Program Description :</b></td>
<td><textarea class="inpts" name="ad_desc" rows="5" cols="42">{$frm.ad_desc|escape:html}</textarea></td></tr>
<tr><td align="right"><b>Advertiser Email :</b></td>
<td><input type=text class="inpts" size="45" name="ader_mail" value="{$frm.ader_mail|escape:html}"></td></tr>
<tr><td align="right"><b>Payment Options:</b></td>
<td><select name="processor" class="inpts">
<option value="LibertyReserve">LibertyReserve</option>
<option value="PerfectMoney">PerfectMoney</option>
</select></td></tr>
<tr><td align="right"><b>Price :</b></td><td><b>$&nbsp;<span id="total_price"></span> (USD)</b></td></tr>
<input type="hidden" name="total_prices">
{if $settings.use_turing}
<tr>
  <td align="right"><img src="{"?a=turing&`$sesname`=`$sesid`&r=`$rand`"|encurl}" alt="turing code"></td>
  <td><input type=text name="turing" maxlength="6" size="10" class="inpts"></td>
</tr>
{/if}
<tr><td>&nbsp;</td><td><input class="sbmt" type="submit" value="Preview"></td></tr>
<tr><td>&nbsp;</td></tr></form></table></td></tr>
<tr><td align=center><div id="show_ad_site"></div></td></tr>
</table>
</div></div>
<script type="text/javascript">
{literal}
function SetPrice(){
{/literal}
var adstep = new Array();
{section name=stp loop=$allads}
adstep[{$allads[stp].id}] = '{$allads[stp].step}';
{/section}
var adfee = new Array();
{section name=fe loop=$allads}
adfee[{$allads[fe].id}] = '{$allads[fe].price}';
{/section}
{literal}
var adtime = document.frm.ad_time;
var adtype = document.frm.ad_time_type;
var adtp = document.frm.ad_type.value;
if (isNaN(adtime.value)) {alert("Please Enter Numeric Value for Ad Time.");	
adtime.value=1;	 adtime.focus(); return (false);
}
{/literal}

{section name=cl loop=$allads}
var aid = '{$allads[cl].id}';
{literal}
if(adtp == aid){
if(adtype[0].checked) { 
var eledf = document.frm.elements["position["+aid+"]"];
if (eledf) 
 { 
  var mypos = eledf.value;
  if (mypos == 'Sold'){
document.getElementById("sold_"+aid).innerHTML = '&nbsp; <font color="red">Sold</font>';
mypos = eledf.options[eledf.selectedIndex].text;
  } else { document.getElementById("sold_"+aid).innerHTML = '&nbsp; <font color="green">Available</font>'; }
  jsprice = parseFloat(adtime.value*(adfee[aid]-(mypos-1)*adstep[aid]));
 }
  else { jsprice = parseFloat(adtime.value*adfee[aid]); }
 }
else if(adtype[1].checked) {
var eledf = document.frm.elements["position["+aid+"]"];
if (eledf)
 { 
  var mypos = eledf.value;
  if (mypos == 'Sold'){
document.getElementById("sold_"+aid).innerHTML = '&nbsp;  <font color="red">Sold</font>';
mypos = eledf.options[eledf.selectedIndex].text;
  } else { document.getElementById("sold_"+aid).innerHTML = '&nbsp; <font color="green">Available</font>'; }
  jsprice = parseFloat(adtime.value*4*(adfee[aid]-(mypos-1)*adstep[aid]));
 }
  else { jsprice = parseFloat(adtime.value*4*adfee[aid]);  }
 }

}
{/literal}
{/section}
{literal}
document.getElementById("total_price").innerHTML = jsprice.toFixed(2);
document.frm.total_prices.value=jsprice.toFixed(2);
}
{/literal}
change_AD({$frm.ad_type});
</script>
{include file="footer.tpl"}