/**
 * @author Client1 Computer Amit Jain
 */
function startAd()
{
	//setTimeout(1000*60*3,getGAd());
	//setTimeout(1000*60*3,getSAd());
	getGAd();
	getSAd();
	
	//alert('startAd() called')
}

//var stateName='Goa';
//var destName='Panaji';

var  gAdObj;
function getGAd()
{
	//alert('###');
	if(window.ActiveXObject)
	{
		//gAdObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			gAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				gAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				gAdObj = false;
			}
		}

	}
	else
	{
		gAdObj = new XMLHttpRequest;
	}
	if(gAdObj)
	{
		gAdObj.onreadystatechange = setGAd;
		var url = '/servlet/AdvAjaxRes?state='+stateName+'&dest='+destinationName+'&level=N&position=RP&section=G&adCat=null&dummy='+Math.random();
		//var url = '/servlet/AdvAjaxRes?state=Goa&dest=null&level=N&position=RP&section=S&dummy='+Math.random();
		gAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			gAdObj.send();
		}
		else
		{
			gAdObj.send(null);
		}
	}
	setTimeout("getGAd()", 1000*60*5);
}
function setGAd()
{
	if(gAdObj.readyState==4)
	{
		if(gAdObj.status==200)
		{
			adAdv(gAdObj.responseText,'gold');
		}
	}
	
}

function adAdv(xmlString,section)
{
	//alert('res:-> '+xmlString);
	var doc;
	if(window.ActiveXObject)
	{
		doc = new ActiveXObject("Microsoft.XMLDOM")
        doc.async="false"
        doc.loadXML(xmlString)
	}
	else
	{
		var parser = new DOMParser()
        	doc = parser.parseFromString(xmlString, "text/xml");
	}
	var rootValue = doc.documentElement;
	var rootAtt = rootValue.attributes;
	var unitCount=0.0;
	var gapSpace;
	var totalGapSpace;
	var addFiller=false;
			
	try
	{
		//unitCount = rootAtt[1].value; AdUnit
		for(var i=0; i<rootValue.childNodes.length; i++)//Get adv 
        {
			unitCount = unitCount + Number(rootValue.childNodes[i].getAttribute("AdUnit"));
		}
		//alert('unitCount:-> '+unitCount);	
		
		// Gap Filler Modification  //
		var gapCount = rootValue.childNodes.length-1;
		if(gapCount==1){
			addFiller = true;
		}	
		//
	}
	catch(ex)
	{
		//alert('exception in counting unitCount');
	}
	
	var bodyObj;
	//alert('section:-> '+section);
	if(section=='gold')
	{
		if(addFiller){
			totalGapSpace = 400-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{			
			totalGapSpace = 400-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		//alert('gapSpace:-> '+gapSpace);
		removeRow('gAdvBody');
		bodyObj = document.getElementById('gAdvBody')
	}
	if(section=='silver')
	{
		//alert('silver');
		if(addFiller){
			totalGapSpace = 440-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 440-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		
		removeRow('sAdvBody');
		bodyObj = document.getElementById('sAdvBody')
	}
	
	if(section=='silverLPAd')
	{
		/*if(addFiller){
			totalGapSpace = 110-((unitCount*40)+2);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 110-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}*/
		addFiller = false;
		totalGapSpace = 300-(unitCount*40);
		gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		//alert('other');
		
		removeRow('adLPSilver');
		bodyObj = document.getElementById('adLPSilver')
	}
	
	if(section=='silverLPCatAd')
	{
		if(addFiller){
			totalGapSpace = 190-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 190-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		//alert('other');
		
		removeRow('catSilverLPAd');
		bodyObj = document.getElementById('catSilverLPAd')
	}
	
	if(section=='w2stay')
	{		
		if(addFiller){
			totalGapSpace = 520-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 520-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		
		removeRow('w2stayAdBody');
		bodyObj = document.getElementById('w2stayAdBody');
	}
	
	if(section=='press')
	{		
		if(addFiller){
			totalGapSpace = 520-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 520-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		
		removeRow('pressAdBody');
		bodyObj = document.getElementById('pressAdBody');
	}
	
	if(section=='photo')
	{		
		if(addFiller){
			totalGapSpace = 400-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 400-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		
		removeRow('photoAdBody');
		bodyObj = document.getElementById('photoAdBody');
	}
	
	
	
	if(section=='shop')
	{		
		//alert('unitCount:-> '+unitCount);	
		if(addFiller){
			totalGapSpace = 520-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 520-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		
		removeRow('shopRPAdvBody');
		bodyObj = document.getElementById('shopRPAdvBody');
	}
	
	
	if(section=='Blog')
	{		
		//alert('unitCount:-> '+unitCount);	
		if(addFiller){
			totalGapSpace = 400-((unitCount*40)+20);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length);
		}else{
			totalGapSpace = 400-(unitCount*40);
			gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		}
		removeRow('blogCPAdvBody');
		bodyObj = document.getElementById('blogCPAdvBody');
	}
	
	try
	{		
		
		for(var i=0; i<rootValue.childNodes.length; i++)//Get adv 
        {
			var tr = document.createElement("tr");//tr for adv. image or swf
				var td = document.createElement("td");
					//td.width='125';
					
					if(rootValue.childNodes[i].getAttribute("Format")=='SWF')
					{
						td.innerHTML='<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">'+
      									'<param name=\"movie\" value=\"'+rootValue.childNodes[i].getAttribute("Src")+'">'+
      									'<param name=\"quality\" value=\"high\">'+
      									'<param name=\"allowScriptAccess\" value=\"sameDomain\" />'+
										'<param name=\"menu\" value=\"false\" />'+
      									'<embed src=\"'+rootValue.childNodes[i].getAttribute("Src")+'\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" alt=\"'+rootValue.childNodes[i].getAttribute("Alt")+'\" title=\''+rootValue.childNodes[i].getAttribute("Alt")+'\'>'+
      									'</embed>'+
      									'</object>'										
					}
					else
					{
						if(rootValue.childNodes[i].getAttribute("Format")=='dgmTP'){
							td.innerHTML = rootValue.childNodes[i].getAttribute("URL");	
						}else{							
							td.innerHTML='<a href=\'javascript:void(0)\'><img align=\'center\' valign=\'top\' border=\'0\' src=\''+rootValue.childNodes[i].getAttribute("Src")+'\' alt=\''+rootValue.childNodes[i].getAttribute("Alt")+'\' onClick=\"addSense(\''+rootValue.childNodes[i].getAttribute("URL")+'\',\''+rootValue.childNodes[i].getAttribute("Id")+'\')\"></a>';
						//alert(rootValue.childNodes[i].getAttribute("Src"));
						}
					}
					td.valign='top';
					td.align='Center';
					//td.align='Right';
					//alert(td.align);
			tr.appendChild(td);
			//alert(tr.innerHTML);
			bodyObj.appendChild(tr);
			//alert('1');
			if(i<(rootValue.childNodes.length-1))
			{
				//alert('a');
				var tr = document.createElement("tr");//tr for gap
					var td = document.createElement("td");
						td.width='125';
						td.align='center';
						td.valign='top';
						//alert('gapSpace:-> '+gapSpace);
						td.height=gapSpace;
						//alert('b');
						//td.innerHTML='&nbsp;';
					tr.appendChild(td);
				bodyObj.appendChild(tr);
			}
			//alert('2');							
		}
		if(addFiller)
		{
			var tr = document.createElement("tr");//tr for gap
				var td = document.createElement("td");
					td.width='125';
					td.height=gapSpace;
					td.align='center';
					td.vAlign='top';
					//td.innerHTML='&nbsp;';
				tr.appendChild(td);
			bodyObj.appendChild(tr);
			
			var tr = document.createElement("tr");//tr for adv. image or swf
				var td = document.createElement("td");
					td.align='center';
					td.vAlign='top';
					td.innerHTML='<a href=\'javascript:void(0)\'><img align=\'center\' valign=\'bottom\' border=\'0\' src=\'/image/adv/Filler/Filler.gif\'></a>';
				tr.appendChild(td);
			bodyObj.appendChild(tr);
			addFiller = false;
		}
	}
	catch(ex)
	{
		//alert(ex);
	}
			
}

/* Get Adv for silver Section Right Panner*/
var  sAdObj;
function getSAd()
{
	if(window.ActiveXObject)
	{
		//sAdObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			sAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				sAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				sAdObj = false;
			}
		}
	}
	else
	{
		sAdObj = new XMLHttpRequest;
	}
	if(sAdObj)
	{
		sAdObj.onreadystatechange = setSAd;
		var url = '/servlet/AdvAjaxRes?state='+stateName+'&dest='+destinationName+'&level=N&position=RP&section=S&adCat=null&dummy='+Math.random();
		sAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			sAdObj.send();
		}
		else
		{
			sAdObj.send(null);
		}
	}
	setTimeout("getSAd()", 1000*60*5);
}
function setSAd()
{
	if(sAdObj.readyState==4)
	{
		if(sAdObj.status==200)
		{
			//alert(sAdObj.responseText)
			adAdv(sAdObj.responseText,'silver');
		}
	}	
}

/* Get Adv for silver Section Left Panner*/
var  sAdLPObj;
function getSLPAd()
{
	if(window.ActiveXObject)
	{
		//sAdLPObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			sAdLPObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				sAdLPObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				sAdLPObj = false;
			}
		}
	}
	else
	{
		sAdLPObj = new XMLHttpRequest;
	}
	if(sAdLPObj)
	{
		sAdLPObj.onreadystatechange = setSLPAd;
		var url = '/servlet/AdvAjaxRes?state='+stateName+'&dest='+destinationName+'&level=N&position=LP&adCat=null&section=S&dummy='+Math.random();
		sAdLPObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			sAdLPObj.send();
		}
		else
		{
			sAdLPObj.send(null);
		}
	}
	setTimeout("getSLPAd()", 1000*60*5);
}
function setSLPAd()
{
	if(sAdLPObj.readyState==4)
	{
		if(sAdLPObj.status==200)
		{
			//alert(sAdObj.responseText)
			adAdv(sAdLPObj.responseText,'silverLPAd');
		}
	}	
}

/* Get Adv for silver Category Section Left Panner*/
var  sCatAdLPObj;
function getSCatLPAd()
{
	if(window.ActiveXObject)
	{
		//sCatAdLPObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			sCatAdLPObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				sCatAdLPObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				sCatAdLPObj = false;
			}
		}
	}
	else
	{
		sCatAdLPObj = new XMLHttpRequest;
	}
	//alert(sCatAdLPObj);
	if(sCatAdLPObj)
	{
		sCatAdLPObj.onreadystatechange = setSCatLPAd;
		var url = '/servlet/AdvAjaxRes?state='+stateName+'&dest='+destinationName+'&level=N&position=LP&adCat=Air Ticket&section=S&dummy='+Math.random();
		//alert(url);
		sCatAdLPObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			sCatAdLPObj.send();
		}
		else
		{
			sCatAdLPObj.send(null);
		}
	}
	setTimeout("getSCatLPAd()", 1000*60*5);
}
function setSCatLPAd()
{
	if(sCatAdLPObj.readyState==4)
	{
		//alert(sCatAdLPObj.status);
		if(sCatAdLPObj.status==200)
		{
			//alert(sAdObj.responseText)
			adAdv(sCatAdLPObj.responseText,'silverLPCatAd');
		}
	}	
}


/* Get Adv for Bronze Category*/
var  bAdLPObj;
function getBAd()
{
	if(window.ActiveXObject)
	{
		
		try 
		{
			bAdLPObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				bAdLPObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				bAdLPObj = false;
			}
		}
	}
	else
	{
		bAdLPObj = new XMLHttpRequest;
	}
	//alert(sCatAdLPObj);
	if(bAdLPObj)
	{
		bAdLPObj.onreadystatechange = setBAd;
		//var url = '/servlet/AdvAjaxRes?state='+stateName+'&dest='+destinationName+'&level=N&position=LP&adCat=Air Ticket&section=B&dummy='+Math.random();
		var url = '/servlet/AdvAjaxRes?state='+stateName+'&dest='+destinationName+'&level=N&position=LP&adCat=null&section=B&dummy='+Math.random();
		//alert(url);
		bAdLPObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			bAdLPObj.send();
		}
		else
		{
			bAdLPObj.send(null);
		}
	}
	setTimeout("getBAd()", 1000*60*5);
}
function setBAd()
{
	if(bAdLPObj.readyState==4)
	{
		//alert(sCatAdLPObj.status);
		if(bAdLPObj.status==200)
		{
			//alert(sAdObj.responseText)
			adBAdv(bAdLPObj.responseText);
		}
	}	
}

function adBAdv(xmlString,section)
{
	//alert('res:-> '+xmlString);
	removeRow('bAdvCPBody');
		
	var doc;
	if(window.ActiveXObject)
	{
		doc = new ActiveXObject("Microsoft.XMLDOM")
        doc.async="false"
        doc.loadXML(xmlString)
	}
	else
	{
		var parser = new DOMParser()
        	doc = parser.parseFromString(xmlString, "text/xml");
	}
	var rootValue = doc.documentElement;
	var rootAtt = rootValue.attributes;
	if(rootValue.childNodes.length==0)
		return;
	
	//alert(rootValue.childNodes.length);
	
	//return;	
	try
	{
		var temp=0;
		var bodyObj = document.getElementById('bAdvCPBody');
		var trCP = document.createElement("tr");//tr for adv. image or swf
		
		for(var i=0;i<rootValue.childNodes.length;i++)		
		{
			if(i==0||i==rootValue.childNodes.length-1)
			{
				var tdObj;
				if(i==0)
				{
					tdObj = document.getElementById('LPB');
				}
			
				if(i==rootValue.childNodes.length-1)
				{
					tdObj = document.getElementById('RPB');
				}
				if(rootValue.childNodes[i].getAttribute("Format")=='SWF')
				{
					tdObj.innerHTML= 	'<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">'+
      									'<param name=\"movie\" value=\"'+rootValue.childNodes[i].getAttribute("Src")+'">'+
      									'<param name=\"quality\" value=\"high\">'+
      									'<param name=\"allowScriptAccess\" value=\"sameDomain\" />'+
										'<param name=\"menu\" value=\"false\" />'+
      									'<embed src=\"'+rootValue.childNodes[i].getAttribute("Src")+'\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" alt=\"'+rootValue.childNodes[i].getAttribute("Alt")+'\" title=\''+rootValue.childNodes[i].getAttribute("Alt")+'\'>'+
      									'</embed></object>';
					tdObj.align='center';
				}
				else
				{						
					if(rootValue.childNodes[i].getAttribute("Format")=='dgmTP'){
							tdObj.innerHTML = rootValue.childNodes[i].getAttribute("URL");
							tdObj.height='40';
							tdObj.align='center';
					}else{
						tdObj.innerHTML='<a href=\'javascript:void(0)\'><img align=\'center\' valign=\'top\' border=\'0\' src=\''+rootValue.childNodes[i].getAttribute("Src")+'\' alt=\''+rootValue.childNodes[i].getAttribute("Alt")+'\' onClick=\"addSense(\''+rootValue.childNodes[i].getAttribute("URL")+'\',\''+rootValue.childNodes[i].getAttribute("Id")+'\')\"></a>';
						tdObj.align='center';
						tdObj.vAlign='top';	
						tdObj.height='40';
					}
				}
			}
			else
			{				
				if(rootValue.childNodes[i].getAttribute("Format")=='SWF')				
				{
					var td = document.createElement("td");
					td.align='center';
					td.innerHTML='<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\">'+
      								'<param name=\"movie\" value=\"'+rootValue.childNodes[i].getAttribute("Src")+'">'+
      								'<param name=\"quality\" value=\"high\">'+
      								'<param name=\"allowScriptAccess\" value=\"sameDomain\" />'+
									'<param name=\"menu\" value=\"false\" />'+
      								'<embed src=\"'+rootValue.childNodes[i].getAttribute("Src")+'\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" alt=\"'+rootValue.childNodes[i].getAttribute("Alt")+'\" title=\''+rootValue.childNodes[i].getAttribute("Alt")+'\'>'+
      								'</embed>'+
      								'</object>';
					trCP.appendChild(td);
				}
				else
				{						
					//alert('i:-> '+i);
					var td = document.createElement("td");
					if(rootValue.childNodes[i].getAttribute("Format")=='dgmTP'){
							td.innerHTML = rootValue.childNodes[i].getAttribute("URL");	
							td.height='40';
							td.align='center';
					}else{
						td.innerHTML='<a href=\'javascript:void(0)\'><img align=\'center\' valign=\'top\' border=\'0\' src=\''+rootValue.childNodes[i].getAttribute("Src")+'\' alt=\''+rootValue.childNodes[i].getAttribute("Alt")+'\' onClick=\"addSense(\''+rootValue.childNodes[i].getAttribute("URL")+'\',\''+rootValue.childNodes[i].getAttribute("Id")+'\')\"></a>';
						td.align='center';
						td.vAlign='top';
						td.height='40';
					}
					trCP.appendChild(td);	
				}
				//alert('1');
				//trCP.appendChild(td);
				//alert('2');
				
				if((rootValue.childNodes.length-2)>2&&temp<2)
				{
					var td = document.createElement("td");
					td.innerHTML='';
					td.width='11';
					td.align='center';
					td.vAlign='top';
					td.height='40';
					trCP.appendChild(td);
					temp++;
				}
				if((rootValue.childNodes.length-2)==2&&temp<1)
				{
					var td = document.createElement("td");
					td.innerHTML='';
					td.width='22';
					td.height='40';
					td.align='center';
					td.vAlign='top';
					trCP.appendChild(td);
					temp++;
				}
			}	
		}
		//alert('3');
		//alert(trCP.innerHTML);		
		//alert(bodyObj);
		//alert(bodyObj.innerHTML);
		bodyObj.appendChild(trCP);
		//alert('4');
		
	}
	catch(ex)
	{
		//alert(ex);
	}		
}	

/* Get Adv for W2Stay Category Section Right Pannel*/
var  w2stayAdObj;
function getW2StayAd()
{
	//alert('uQuery:-> '+uQuery);
	
	if(window.ActiveXObject)
	{
		//w2stayAdObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			w2stayAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				w2stayAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				w2stayAdObj = false;
			}
		}
	}
	else
	{
		w2stayAdObj = new XMLHttpRequest;
	}
	//alert(sCatAdLPObj);
	if(w2stayAdObj)
	{
		w2stayAdObj.onreadystatechange = setW2StayAd;
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=RP&adCat=w2stay&section=S&dummy='+Math.random();
		//alert(url);
		//return;
		w2stayAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			w2stayAdObj.send();
		}
		else
		{
			w2stayAdObj.send(null);
		}
	}
	//setTimeout("getW2StayAd()", 1000*20);
}
function setW2StayAd()
{
	//alert(w2stayAdObj.readyState);
	if(w2stayAdObj.readyState==4)
	{
		//alert(sCatAdObj.status);
		if(w2stayAdObj.status==200)
		{
			//alert(w2stayAdObj.responseText);
			//return;
			adAdv(w2stayAdObj.responseText,'w2stay');
		}
	}	
}

/* Get Adv for shop Category Section Right Pannel*/
var  shopAdObj;
function getShopAd()
{
	//alert('shop adv');
	if(window.ActiveXObject)
	{		
		try 
		{
			shopAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				shopAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				shopAdObj = false;
			}
		}
	}
	else
	{
		shopAdObj = new XMLHttpRequest;
	}
	
	if(shopAdObj)
	{
		shopAdObj.onreadystatechange = setShopAd;
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=RP&adCat=shop&section=S&dummy='+Math.random();
		//alert(url);
		//return;
		shopAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			shopAdObj.send();
		}
		else
		{
			shopAdObj.send(null);
		}
	}
	setTimeout("getShopAd()", 1000*60*5);
}
function setShopAd()
{	
//	alert(shopAdObj.readyState);
	if(shopAdObj.readyState==4)
	{
		
		if(shopAdObj.status==200)
		{
			//alert(shopAdObj.responseText);
			
			adAdv(shopAdObj.responseText,'shop');
		}
	}	
}


/* Get Adv for Shop Bronze section*/
var  shopBAdObj;
function getBShopAd()
{
	if(window.ActiveXObject)
	{
		
		try 
		{
			shopBAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				shopBAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				shopBAdObj = false;
			}
		}
	}
	else
	{
		shopBAdObj = new XMLHttpRequest;
	}
	//alert(shopBAdObj);
	if(shopBAdObj)
	{
		shopBAdObj.onreadystatechange = setShopBAd;
		
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=CP&adCat=shop&section=B&dummy='+Math.random();
		//alert(url);
		shopBAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			shopBAdObj.send();
		}
		else
		{
			shopBAdObj.send(null);
		}
	}
	setTimeout("getBShopAd()", 1000*60*5);
}
function setShopBAd()
{
	if(shopBAdObj.readyState==4)
	{
		//alert(shopBAdObj.status);
		if(shopBAdObj.status==200)
		{
			//alert(shopBAdObj.responseText)
			adShopBAdv(shopBAdObj.responseText);
		}
	}	
}

var  blogAdObj;
function getblogAd()
{
	alert('shop adv');
	if(window.ActiveXObject)
	{		
		try 
		{
			blogAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				blogAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				blogAdObj = false;
			}
		}
	}
	else
	{
		blogAdObj = new XMLHttpRequest;
	}
	
	if(blogAdObj)
	{
		blogAdObj.onreadystatechange = setblogAd;
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=RP&adCat=Blog&section=S&dummy='+Math.random();
		alert(url);
		//return;
		blogAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			alert('sent');
			blogAdObj.send();
		}
		else
		{
			blogAdObj.send(null);
		}
	}
	alert('timeout');
	setTimeout("getblogAd()", 1000*60*5);
}
function setblogAd()
{	
//	alert(shopAdObj.readyState);
	if(blogAdObj.readyState==4)
	{
		
		if(blogAdObj.status==200)
		{
			alert(blogAdObj.responseText);
			
			adAdv(blogAdObj.responseText,'Blog');
			alert('seilver');
		}
	}	
}
/* blog bronze section*/
var  blogBAdObj;
function getBBlogAd()
{
	if(window.ActiveXObject)
	{
		
		try 
		{
			blogBAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				blogBAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				blogBAdObj = false;
			}
		}
	}
	else
	{
		blogBAdObj = new XMLHttpRequest;
	}
	//alert(shopBAdObj);
	if(blogBAdObj)
	{
		blogBAdObj.onreadystatechange = setblogBAd;
		
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=CP&adCat=Blog&section=B&dummy='+Math.random();
		//alert(url);
		blogBAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			blogBAdObj.send();
		}
		else
		{
			blogBAdObj.send(null);
		}
	}
	setTimeout("getBBlogAd()", 1000*60*5);
}
function setblogBAd()
{
	if(blogBAdObj.readyState==4)
	{
		//alert(shopBAdObj.status);
		if(blogBAdObj.status==200)
		{
			//alert(shopBAdObj.responseText)
			adBlogBAdv(blogBAdObj.responseText);
		}
	}	
}



function adBlogBAdv(xmlString,section)
{
	//alert('res:-> '+xmlString);
	removeRow('blogCPAdvBody');
		
	var doc1;
	if(window.ActiveXObject)
	{
		doc1 = new ActiveXObject("Microsoft.XMLDOM")
        doc1.async="false"
        doc1.loadXML(xmlString)
	}
	else
	{
		var parser = new DOMParser()
        	doc1 = parser.parseFromString(xmlString, "text/xml");
	}
	var widthCount=0.0;
	var totalGapSpace=0.0;
	var gapSpace=0.0;
	var rootValue = doc1.documentElement;
	var rootAtt = rootValue.attributes;
	if(rootValue.childNodes.length==0)
		return;
	
	try
	{
		//unitCount = rootAtt[1].value; AdUnit
		for(var i=0; i<rootValue.childNodes.length; i++)//Get adv 
        {
			//alert(rootValue.childNodes[i].getAttribute("AdUnit"));
			widthCount = widthCount + Number(rootValue.childNodes[i].getAttribute("AdUnit"));
		}
		//alert('widthCount:-> '+widthCount);		
		totalGapSpace = 460.0-widthCount;
		gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		//alert('gapSpace:-> '+gapSpace);
	}
	catch(ex)
	{
		//alert('exception in counting unitCount');
	}
	
	try
	{
		var temp=0;
		var bodyObj = document.getElementById('blogCPAdvBody');
		var trCP = document.createElement("tr");//tr for adv. image or swf
		//alert('1');
		for(var i=0;i<rootValue.childNodes.length;i++)		
		{			
			if(rootValue.childNodes[i].getAttribute("Format")=='SWF')				
			{
				var td = document.createElement("td");
					td.innerHTML='<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\">'+
      								'<param name=\"movie\" value=\"'+rootValue.childNodes[i].getAttribute("Src")+'">'+
      								'<param name=\"quality\" value=\"high\">'+
      								'<param name=\"allowScriptAccess\" value=\"sameDomain\" />'+
									'<param name=\"menu\" value=\"false\" />'+
      								'<embed src=\"'+rootValue.childNodes[i].getAttribute("Src")+'\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" alt=\"'+rootValue.childNodes[i].getAttribute("Alt")+'\" title=\''+rootValue.childNodes[i].getAttribute("Alt")+'\'>'+
      								'</embed>'+
      								'</object>'										
			}
			else
			{						
				//alert('i:-> '+i);
				if(rootValue.childNodes[i].getAttribute("Format")=='dgmTP'){
					var td = document.createElement("td");
					td.innerHTML=rootValue.childNodes[i].getAttribute("URL");
					td.heigth='40';
					td.align='center';
					td.vAlign='top';
					trCP.appendChild(td);
				}else{
					var td = document.createElement("td");
						td.innerHTML='<a href=\'javascript:void(0)\'><img width='+rootValue.childNodes[i].getAttribute("AdUnit")+' align=\'center\' valign=\'top\' border=\'0\' src=\''+rootValue.childNodes[i].getAttribute("Src")+'\' alt=\''+rootValue.childNodes[i].getAttribute("Alt")+'\' onClick=\"addSense(\''+rootValue.childNodes[i].getAttribute("URL")+'\',\''+rootValue.childNodes[i].getAttribute("Id")+'\')\"></a>';
						td.align='center';
						td.vAlign='top';
						trCP.appendChild(td);
				}
					
			}
			
			if(i<(rootValue.childNodes.length-1)){
				var td = document.createElement("td");
					td.innerHTML='&nbsp;';
					td.width=gapSpace+'px';
					td.align='center';
					td.vAlign='top';
					trCP.appendChild(td);	
				//alert('if gapSpace:-> '+gapSpace)
				//alert(trCP.innerHTML);
			}
		}
		
		bodyObj.appendChild(trCP);
	}
	catch(ex)
	{
		//alert(ex);
	}		
}







function adShopBAdv(xmlString,section)
{
	//alert('res:-> '+xmlString);
	removeRow('shopCPAdvBody');
		
	var doc;
	if(window.ActiveXObject)
	{
		doc = new ActiveXObject("Microsoft.XMLDOM")
        doc.async="false"
        doc.loadXML(xmlString)
	}
	else
	{
		var parser = new DOMParser()
        	doc = parser.parseFromString(xmlString, "text/xml");
	}
	var widthCount=0.0;
	var totalGapSpace=0.0;
	var gapSpace=0.0;
	var rootValue = doc.documentElement;
	var rootAtt = rootValue.attributes;
	if(rootValue.childNodes.length==0)
		return;
	
	try
	{
		//unitCount = rootAtt[1].value; AdUnit
		for(var i=0; i<rootValue.childNodes.length; i++)//Get adv 
        {
			//alert(rootValue.childNodes[i].getAttribute("AdUnit"));
			widthCount = widthCount + Number(rootValue.childNodes[i].getAttribute("AdUnit"));
		}
		//alert('widthCount:-> '+widthCount);		
		totalGapSpace = 460.0-widthCount;
		gapSpace = totalGapSpace/Number(rootValue.childNodes.length-1);
		//alert('gapSpace:-> '+gapSpace);
	}
	catch(ex)
	{
		//alert('exception in counting unitCount');
	}
	
	try
	{
		var temp=0;
		var bodyObj = document.getElementById('shopCPAdvBody');
		var trCP = document.createElement("tr");//tr for adv. image or swf
		//alert('1');
		for(var i=0;i<rootValue.childNodes.length;i++)		
		{			
			if(rootValue.childNodes[i].getAttribute("Format")=='SWF')				
			{
				var td = document.createElement("td");
					td.innerHTML='<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\">'+
      								'<param name=\"movie\" value=\"'+rootValue.childNodes[i].getAttribute("Src")+'">'+
      								'<param name=\"quality\" value=\"high\">'+
      								'<param name=\"allowScriptAccess\" value=\"sameDomain\" />'+
									'<param name=\"menu\" value=\"false\" />'+
      								'<embed src=\"'+rootValue.childNodes[i].getAttribute("Src")+'\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" alt=\"'+rootValue.childNodes[i].getAttribute("Alt")+'\" title=\''+rootValue.childNodes[i].getAttribute("Alt")+'\'>'+
      								'</embed>'+
      								'</object>'										
			}
			else
			{						
				//alert('i:-> '+i);
				if(rootValue.childNodes[i].getAttribute("Format")=='dgmTP'){
					var td = document.createElement("td");
					td.innerHTML=rootValue.childNodes[i].getAttribute("URL");
					td.heigth='40';
					td.align='center';
					td.vAlign='top';
					trCP.appendChild(td);
				}else{
					var td = document.createElement("td");
						td.innerHTML='<a href=\'javascript:void(0)\'><img width='+rootValue.childNodes[i].getAttribute("AdUnit")+' align=\'center\' valign=\'top\' border=\'0\' src=\''+rootValue.childNodes[i].getAttribute("Src")+'\' alt=\''+rootValue.childNodes[i].getAttribute("Alt")+'\' onClick=\"addSense(\''+rootValue.childNodes[i].getAttribute("URL")+'\',\''+rootValue.childNodes[i].getAttribute("Id")+'\')\"></a>';
						td.align='center';
						td.vAlign='top';
						trCP.appendChild(td);
				}
					
			}
			
			if(i<(rootValue.childNodes.length-1)){
				var td = document.createElement("td");
					td.innerHTML='&nbsp;';
					td.width=gapSpace+'px';
					td.align='center';
					td.vAlign='top';
					trCP.appendChild(td);	
				//alert('if gapSpace:-> '+gapSpace)
				//alert(trCP.innerHTML);
			}
		}
		
		bodyObj.appendChild(trCP);
	}
	catch(ex)
	{
		//alert(ex);
	}		
}


/* Get Adv for Press Realese Category Section Right Pannel*/
var  pressAdObj;
function getPressAd()
{
	//alert('uQuery:-> '+uQuery);
	
	if(window.ActiveXObject)
	{
		//pressAdObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			pressAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				pressAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				pressAdObj = false;
			}
		}
	}
	else
	{
		pressAdObj = new XMLHttpRequest;
	}
	//alert(pressAdObj);
	if(pressAdObj)
	{
		pressAdObj.onreadystatechange = setPressAd;
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=RP&adCat=press&section=S&dummy='+Math.random();
		//alert(url);
		//return;
		pressAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			pressAdObj.send();
		}
		else
		{
			pressAdObj.send(null);
		}
	}
	//setTimeout("getPressAd()", 1000*60*5);
}
function setPressAd()
{
	//alert(w2stayAdObj.readyState);
	if(pressAdObj.readyState==4)
	{
		//alert(pressAdObj.status);
		if(pressAdObj.status==200)
		{
			//alert(pressAdObj.responseText);
			//return;
			adAdv(pressAdObj.responseText,'press');
		}
	}	
}


/* Get Adv for PhotoGallery Realese Category Section Right Pannel*/
var  pgAdObj;
function getPhotoAd(){
	//alert('uQuery:-> '+uQuery);
	
	if(window.ActiveXObject)
	{
		//pgAdObj = new ActiveXObject('Microsoft.XMLHTTP');
		try 
		{
			pgAdObj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				pgAdObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				pgAdObj = false;
			}
		}
	}
	else
	{
		pgAdObj = new XMLHttpRequest;
	}
	//alert(pressAdObj);
	if(pgAdObj)
	{
		pgAdObj.onreadystatechange = setPGAd;
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=RP&adCat=photo&section=S&dummy='+Math.random();
		//alert(url);
		//return;
		pgAdObj.open('Get',url,true);
		if(window.ActiveXObject)
		{
			pgAdObj.send();
		}
		else
		{
			pgAdObj.send(null);
		}
	}
	setTimeout("getPhotoAd()", 1000*20);
}
function setPGAd()
{
	//alert(pgAdObj.readyState);
	if(pgAdObj.readyState==4)
	{
		//alert(pgAdObj.status);
		if(pgAdObj.status==200)
		{
			//alert(pgAdObj.responseText);
			//return;
			adAdv(pgAdObj.responseText,'photo');
		}
	}	
}



function removeRow(tableid)
{
	//alert(tableid);
	var tbl = document.getElementById(tableid);
	//alert('Count Rows:-> '+tbl.rows.length);	
	while(tbl.rows.length)
	{
		//alert('xyz');
		tbl.deleteRow(0);
	}		
}
/*var  shopAdObj1;
function getShopAd1()
{
	//alert('shop adv');
	if(window.ActiveXObject)
	{		
		try 
		{
			shopAdObj1 = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				shopAdObj1 = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (E) 
			{
				shopAdObj1 = false;
			}
		}
	}
	else
	{
		shopAdObj1 = new XMLHttpRequest;
	}
	
	if(shopAdObj1)
	{
		shopAdObj1.onreadystatechange = setShopAd1;
		var url = '/servlet/AdvAjaxRes?state=null&dest=null&level=N&position=RP&adCat=Blog&section=S&dummy='+Math.random();
		//alert(url);
		//return;
		shopAdObj1.open('Get',url,true);
		if(window.ActiveXObject)
		{
			shopAdObj1.send();
		}
		else
		{
			shopAdObj1.send(null);
		}
	}
	setTimeout("getShopAd()1", 1000*60*5);
}
function setShopAd1()
{	
//	alert(shopAdObj.readyState);
	if(shopAdObj1.readyState==4)
	{
		
		if(shopAdObj1.status==200)
		{
			//alert(shopAdObj.responseText);
			
			adAdv(shopAdObj1.responseText,'shop');
		}
	}	
}
*/

