var bHTML = '';
bHTML += '<table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; display: none;" id="i30tADVBox" align="center" style="text-align: center;">';
bHTML += '<tr height="100%"><td align="center" style="text-align: center;" width="100%" id="i30tADVBoxFrame"></td></tr>';
bHTML += '</table>';

if (!document.getElementById('i30tADVBox')) {
  document.write(bHTML);
  
  var i30tADVBoxCheck = false;
  var i30tADVBoxOverlap = new Array();
}

function i30tCheckBrowser() {
  this.type = 'IE';
  
  var ua    = navigator.userAgent;
  this.type = 'IE';
  if (ua.indexOf('MSIE') >= 0) this.type = 'IE';
  if (ua.indexOf('Netscape6/') >= 0) this.type = 'NS';
  if (ua.indexOf('Gecko') >= 0) this.type = 'NS';
}
var i30tBrowser = new i30tCheckBrowser();

function i30tADVBoxSetPosition() {
  var box = document.getElementById('i30tADVBox');
  if (i30tBrowser.type == 'IE') {
    box.style.top    = document.body.scrollTop;
    box.style.left   = document.body.scrollLeft;
    box.style.width  = document.body.offsetWidth - 25;
    box.style.height = document.body.offsetHeight - 5;
  } else {
    box.style.top    = window.scrollY;
    box.style.width  = window.innerWidth - 20;
    box.style.height = window.innerHeight;
  }
  
  if (i30tADVBoxCheck) window.setTimeout('i30tADVBoxSetPosition()', 1);
}

function i30tADVHideObjects() {
	var i; var t;
	var tags = ['SELECT', 'OBJECT', 'IFRAME'];
	
	for (t=0; t<tags.length; t++) {
  	for (i=0; i<document.all.tags(tags[t]).length; ++i) {
  		var obj = document.all.tags(tags[t])[i];
	  	if (!obj || !obj.offsetParent || (obj.style.visibility == 'hidden') || (obj.id == 'idI30TBoxFrame')) continue;
	  	
		  i30tADVBoxOverlap[i30tADVBoxOverlap.length] = obj;
  		obj.style.visibility = 'hidden';
  	}
	}
}

function i30tADVShowObjects() {
  var i = 0;
  for (i=0; i<i30tADVBoxOverlap.length; i++) i30tADVBoxOverlap[i].style.visibility = 'visible';
  i30tADVBoxOverlap = new Array();
}

function i30tADVShowBox(w, h, t) {
  i30tADVBoxCheck = true;

  var box = document.getElementById('i30tADVBox');
  try { box.style.display = 'table'; }
  catch (e) { box.style.display = 'block'; }
  
  var frame  = document.getElementById('i30tADVBoxFrame');
  var toShow = '';
  toShow += '<center>';
  toShow += '<div id="idI30TBoxView" style="width: ' + w + 'px; height: ' + h + 'px; padding: 0px; margin-top: 0px; margin-right: 0px; background-color: #FFFFFF; filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=5, OffY=5, Color=\'gray\', Positive=\'true\');">';
  toShow += t;
  toShow += '</div>';
  toShow += '</center>';
  frame.style.textAlign = 'center';
  frame.innerHTML = toShow;
  i30tADVHideObjects();
  
  i30tADVBoxSetPosition();
}

function i30tADVHideBox() {
  var box = document.getElementById('i30tADVBox');
  if (!box) return false;
  
  i30tADVBoxCheck = false;
  box.style.display = 'none';
  i30tADVShowObjects();
}

function i30tADVShowText(aID, aSite, aCode, s, d, w, h, id, bgColor, brColor, txColor, kaColor) {
  var t = '';
  
  t += '<center>';
  t += '<table cellpadding="0" cellspacing="0" width="100%" border="0" style="font-family: tahoma; font-size: 11px; border: 2px solid #' + brColor + '; background-color: #' + bgColor + '; color: #' + txColor + ';" dir="rtl">';
  t += '  <tr>';
  t += '    <td style="font-family: tahoma; font-size: 11px; padding: 2px; padding-bottom: 4px; text-align: right; background-color: #' + brColor + ';"><div onClick="i30tADVHideBox();" style="font-family: tahoma; font-size: 11px; font-weight: normal; color: #' + kaColor + '; cursor: hand; cursor: pointer;">بستن پنجره</div></td>';
  t += '    <td style="font-family: tahoma; font-size: 11px; padding: 2px; padding-bottom: 4px; text-align: left; background-color: #' + brColor + '; color: #' + kaColor + ';">تبلیغات I30T</td>';
  t += '  </tr>';
  t += '  <tr>';
  t += '    <td style="padding: 0px; text-align: justify;" dir="rtl" colspan="2">';
  t += '<iframe';
  t += ' id="idI30TBoxFrame"';
  t += ' width="100%"';
  t += ' height="' + (h - 23) + '"';
  t += ' src="http://script.i30t.com/click/?id=' + aID + '&site=' + aSite + '&adv=' + aCode + '&style=' + s + '&time=' + d + '"';
  t += ' frameborder="0"';
  t += ' scrolling="no"';
  t += ' marginwidth="0"';
  t += ' marginheight="0"';
  t += '>';
  t += 'برای مشاهده تبلیغ، نرم افزار مرورگر خود را به صورتی تنظیم نمایید که قابلیت نمایش IFrame را داشته باشد.';
  t += '</iframe>';
  t += '</td>';
  t += '</tr>';
  t += '</table>';
  t += '</center>';

  i30tADVShowBox(w, h, t);
}