// JavaScript Document
var theImages = new Array()
var theURLs = new Array()
var theAlts = new Array();

theImages[0] = 'http://newnmedia.com/adv/images/11.gif'
theImages[1] = 'http://newnmedia.com/adv/images/12.gif'
theImages[2] = 'http://newnmedia.com/adv/images/13.gif'

theURLs[0] = "http://www.newnmedia.com/contact.html"
theURLs[1] = "http://www.newnmedia.com/contact.html"
theURLs[2] = "http://www.newnmedia.com/contact.html"

theAlts[0] = "Place your Advertisement here @ Rs.600/-"
theAlts[1] = "Place your Advertisement here @ Rs.400/-"
theAlts[2] = "Place your Advertisement here @ Rs.400/-"

var imgCt = theImages.length;
var currentAd = Math.round(Math.random()*(imgCt-1));
function cycle() {
  if (currentAd == imgCt) {
    currentAd = 0;
  }
var banner = document.getElementById('adBanner');
var link = document.getElementById('adLink');
  banner.src=theImages[currentAd]
  banner.alt=theAlts[currentAd]
  document.getElementById('adLink').href=theURLs[currentAd]
  currentAd++;
}
  window.setInterval("cycle()",10000);


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function removeHtmlTag(strx,chop){ 
	if(strx.indexOf("<")!=-1)
	{
		var s = strx.split("<"); 
		for(var i=0;i<s.length;i++){ 
			if(s[i].indexOf(">")!=-1){ 
				s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); 
			} 
		} 
		strx =  s.join(""); 
	}
	chop = (chop < strx.length-1) ? chop : strx.length-2; 
	while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++; 
	strx = strx.substring(0,chop-1); 
	return strx+'...'; 
}

function createSummaryAndThumb(pID){
	var div = document.getElementById(pID);
	var imgtag = "";
	var img = div.getElementsByTagName("img");
	var summ = summary_noimg;
	if(img.length>=1) {	
		imgtag = '<span style="float:left; padding:0px 10px 5px 0px;"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/></span>';
		summ = summary_img;
	}
	
	var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
	div.innerHTML = summary;
}
