﻿var webtag = 'pegcomp';
var ForumName = 'HEPCITY';
var cssurl = 'http://acx.prospero.com/dir-css/712582/.css?fpid=-1';

function clearInputField(inputObject) { 
	if(inputObject.value.charAt(0) == '-') 
		{inputObject.value = '';} 
	return false; } 

function LWF(url) { 
	window.open(url,'RatingsWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=450'); 
return false; } 

function LBB(uName, wtag, uID){  
var ptWin = false; 
if (uID == null || LBB.arguments.length < 3) uID = ''; // username and wtag only passed in 
if (LBB.arguments.length == 1) uID = LBB.arguments[0]; // userid only passed in 
if (uID != '' || LBB.arguments.length == 1) { 
	var ptWin = window.open('/dir-app/bbcard/profile.asp?webtag=' + webtag +'&uID='+uID , 'u'+uID+'Window','scrollbars=yes,width=800,height=600,resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,copyhistory=yes'); 
} else { 
	var ptWin = window.open('/dir-app/bbcard/profile.asp?webtag=' + webtag +'&uName='+uName , 'ProfileWindow','scrollbars=yes,width=800,height=600,resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,copyhistory=yes'); 
	} 
if (!ptWin) { alert('Your popup stopper blocked a Member Profile window'); } 
return false;} 

function disableForm(theform) { 
if (document.all || document.getElementById) { 
	for (i = 0; i < theform.length; i++) { 
		var tempobj = theform.elements[i]; 
			if (tempobj.type.toLowerCase() == 'submit' || tempobj.type.toLowerCase() == 'reset') 
				tempobj.disabled = true;}}} 

function LLW() { 
	window.name = 'MsgWin'; 
	var popupList = window.open('/n/mb/list.asp?webtag=' + webtag + '&popup=true&gfc=1','popupList','width=245,height=600,toolbar=no,menubar=no,status=yes,scrollbars=yes,resizable=yes,screenX=10,screenY=10,left=10,top=10'); 
	popupList.focus(); 
	return false;} 

function LOW(folderId,otid) { 
	if (LOW.arguments.length == 0) folderId = '0'; 
	if (LOW.arguments.length < 2) otid = '0'; 
	window.name = 'MsgWin'; 
	var popupOutline = window.open('/n/mb/outline.asp?webtag=' + webtag + '&popup=true&gfc=1&fid=' + folderId + '&tid=' + otid,'popupOutline','width=500,height=600,toolbar=no,menubar=no,status=yes,scrollbars=yes,resizable=yes,screenX=10,screenY=10,left=10,top=10'); 
	popupOutline.focus(); 
	return false; } 

function fixPopup() { 
	var height, width  
	if (document.all) { //ie 
		height = document.body.offsetHeight; 
		width = document.body.offsetWidth; 
	} else { //nn4+  
		height = window.innerHeight; 
		width = window.innerWidth; 
		} 
	if (height > screen.availHeight) {  
		moveTo(10,10); resizeTo(width+10,screen.availHeight-30) 
		}  
}	

function launchIconWindow() { 
	window.open('/n/mydelphi/personalIcon.asp?webtag='+webtag, 'IconWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=450'); 
	return false; } 

function linkParent(url) { 
	opener.location.href = url; 
	opener.focus(); } 

window.onerror = handleErr; 

function handleErr(){ 
	arAccessErrors = ['permission','access']; 
	mess = arguments[0].toLowerCase(); 
	found = false; 
	for (i=0;i<arAccessErrors.length;i++) { 
		errStr = arAccessErrors[i]; 
		if (mess.indexOf(errStr)!=-1) found = true; 
	} 
	return found; } 

function CheckAll() 
{ 
	for (var i=0;i<document.qs.elements.length;i++) 
	{ 
		var e = document.qs.elements[i]; 
		if ((e.name != 'checkAll') && (e.name != 'confirm') && (e.type=='checkbox')) 
		e.checked = document.qs.checkAll.checked; 
	} 
} 

function CheckCheckAll() { 
	var TotalBoxes = 0; 
	var TotalOn = 0; 
	for (var i=0;i<document.qs.elements.length;i++) { 
		var e = document.qs.elements[i]; 
		if ((e.name != 'checkAll') && (e.type=='checkbox')) { 
			TotalBoxes++; 
		if (e.checked) { 
			TotalOn++; 
			} 
		} 
	} 
	if (TotalBoxes==TotalOn) 
	{document.qs.checkAll.checked=true;} 
	else 
	{document.qs.checkAll.checked=false;} 
} 

function launchChatWindow(url,bV) {
	if ((document.startchat.Name.value == '' ) && (bV==false))
		return false;

	window.open(url,'chatWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=638,height=620');
		return false;

}
function launchChatWindow2(url,bV) {
	if ((bV==false))
		return false;

	window.open(url,'chatWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=638,height=620');
		return false; }

function whereToGo2() {  
	if (document.chatctrl.where2go.options[document.chatctrl.where2go.selectedIndex].value == 'Stage') 
		{ top.location='/n/chat/pchat/e/main.asp?webtag='+webtag; } 
	if (document.chatctrl.where2go.options[document.chatctrl.where2go.selectedIndex].value == 'Speaker') 
		{ parent.location=parent.location.pathname+'?webtag='+webtag+'&nav=chat&spk=y'; } 
	if (document.chatctrl.where2go.options[document.chatctrl.where2go.selectedIndex].value == 'Auditorium') 
		{ parent.location=parent.location.pathname+'?webtag='+webtag+'&nav=chat&spk=n'; } 
	if (document.chatctrl.where2go.options[document.chatctrl.where2go.selectedIndex].value == 'Controls') 
		{ var ccWin = window.open('/'+webtag+'/controls','ccWin');  
		  ccWin.focus(); } 
	return false; 
	} 

function setChatUserCount(uCount) {
var found = false; 
var pf = parent.frames; 
var ppf = parent.parent.frames; 
var df = document.forms; 
if ( pf.length == 0 ) {
	 for ( var g = 0; g < df.length; g++ ) {
		  if ( df[g].name == 'mmForm' ) { 
				for ( var h = 0; h < df[g].elements.length; h++ ) {
				if ( df[g].elements[h].name == 'userCountField' ) { 
					df[g].elements[h].value = uCount;
					return false;
					}
				}
		  }
	 }
} 
else 
{ 
	 for ( var i = 0; i < pf.length; i++ ) {
		  for ( var j = 0; j < pf[i].document.forms.length; j++ ) {
				if ( pf[i].document.forms[j].name == 'mmForm' ) { 
					for ( var k = 0; k < pf[i].document.forms[j].elements.length; k++ ) {
						 if ( pf[i].document.forms[j].elements[k].name == 'userCountField' ) {
							  pf[i].document.forms[j].elements[k].value = uCount; 
							  found = true; 
							  return false;
						 }
					}
				}
		  }
	 } 
	 if (!found) { 
		  for ( var m = 0; m < ppf.length; m++ ) {
				for ( var n = 0; n < ppf[m].document.forms.length; n++ ) {
					if ( ppf[m].document.forms[n].name == 'mmForm' ) { 
						 for ( var p = 0; p < ppf[m].document.forms[n].elements.length; p++ ) {
							  if ( ppf[m].document.forms[n].elements[p].name == 'userCountField' ) {
									ppf[m].document.forms[n].elements[p].value = uCount; 
									found = true; 
									return false;
							  }
						 }
					}
				}
		  }
	 }
}
} 

function setPresence(uname) 
{ 
	var imgName = 'IS_' + uname + '_HERE'; 
	var imgList = document.getElementsByName(imgName); 
	var altText; 
	if (imgList[0] && imgList[0].fileSize) 
	{  
		if (imgList[0].fileSize > 50) 
			altText = uname + ' is online! Click the image to Launch Instant Messenger.'; 
		else 
			altText = uname + ' is not online'; 
		for (ix=0; ix < imgList.length; ix++) 
			imgList[ix].alt = altText; 
	} 
} 

function showPresenceStatus(uname) 
{ 
	var imgName = 'IS_' + uname + '_HERE'; 
	var imgList = document.getElementsByName(imgName); 
	if (imgList[0]) 
	{ 
		window.setTimeout('window.status = "' + imgList[0].alt + '"', 5); 
	} 
} 

function launchIM() 
{ 
	// if JabberWindow is already available, use it 
	var jabberWindow = window.open('','JabberWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=200,height=350'); 
	 
	var windowURL = jabberWindow.location.href 
	if (windowURL.substring(0, 58) != 'http://forums.prospero.com/n/chat/jabber/clientwindow.asp?') 
	{ 
		window.status = 'Launching Instant Messenger' 
		jabberWindow.location = 'http://forums.prospero.com/n/chat/jabber/clientwindow.asp?webtag=pegcomp'; 
	} 
	jabberWindow.focus(); 
	window.status = 'Instant Messenger Activated.' 
} 
var jabberWindow;
function launchJabberWindow(whosCalling)
{
if (jabberWindow && !jabberWindow.closed) return false;
	var launchIt = confirm(whosCalling + ' wants to talk with you. Do you want to launch Instant Messanger?');
	if (launchIt == true)
	{
		launchIM();
	}
	else
	{
		if (document.Presence) document.Presence.SetDND();
	}
return false;
}
var __gbl_qstr = stripQuery(this.location); 

function queryString(key, src) { 
  var __qstr = stripQuery(src); 
  var strIndex = __qstr.indexOf(key+'='); 
  if(strIndex == -1) return null; 
  var strReturn = '', ch = ''; 
 
  for(var i = strIndex + key.length; i < __qstr.length; i++) { 
	ch = __qstr.charAt(i); 
	if(ch == '&' || ch == ';') break; 
	if(ch == '+') strReturn += ' '; 
	else if(ch != '=') strReturn += ch; 
  } 
  return unescape(strReturn); 
} 

function stripQuery(src) { 
  if(src == null) return __gbl_qstr; 
 
  if(typeof src == 'string') { 
	var __qstr = new String(); 
	var __tmpNum = src.indexOf('?'); 
	 
	__qstr = (__tmpNum != -1) 
			 ? src.substr( 
				 __tmpNum + 1, src.length 
				) 
			 : null; 
	 
	delete __tmpNum; 
	return __qstr; 
  } 
  else if(typeof src == 'object') { // assumes the object is of type location 
	return location.search.substr(1, location.search.length); 
  } 
  else return __gbl_qstr; 
} 

function LLW() { 
	window.name = 'MsgWin'; 
	var popupList = window.open('/n/mb/list.asp?webtag=' + webtag + '&popup=true&gfc=1','popupList','width=245,height=600,toolbar=no,menubar=no,status=yes,scrollbars=yes,resizable=yes,screenX=10,screenY=10,left=10,top=10'); 
	popupList.focus(); 
	return false;} 

function print_page(){ 
	if ( navigator.userAgent.toLowerCase().indexOf("mac") != -1 && 
	!window.netscape){ 
	alert("Press Command + P to Print"); 
	}else{ window.print(); 
	} 
} 

function bookmark_page(msg){ 
	if ( navigator.userAgent.toLowerCase().indexOf("mac") != -1 || 
	window.netscape){ 
	alert("Bookmark feature is not supported for this browser. \nUse your browser's Favorites or Bookmarks menu to save this page."); 
	}else{ window.external.AddFavorite('http://://forums.delphiforums.com/' + webtag + '/messages?msg=' + msg,ForumName + ' #' + msg); 
	} 
} 

/* ---------------------- */

function loadJSON(url) {
  var headID = document.getElementsByTagName("head")[0];
  var newScript = document.createElement('script');
  newScript.type = 'text/javascript';
  newScript.src = url;
  headID.appendChild(newScript);
  }  

//Get forum keywords
function getmetaContents(mn){
	var m = document.getElementsByTagName('meta');
	for(var i in m){    
			if(m[i].name == mn){
			return m[i].content;
			}
		}
	}
if(getmetaContents('keywords')){	
	var keywords = getmetaContents('keywords');
	keywords = keywords.replace('\n',' ').toLowerCase();
	keywords = keywords.replace('\"',' ');
	keywords = keywords.replace('\'',' ');
	keywords = keywords.replace(/^\s+/gi, "");
	keywords = keywords.replace(/\s+$/gi, "");
	keywords = keywords.replace(/[\s,_-]/gi, " ");
	keywords = keywords.replace(/\s{2,}/gi, " ");
	keywords = keywords.replace(/^\s+|\s+$/g,"");
	var kwArray = keywords.split(" ");
	if (kwArray.length<3){
		var totKeywordsAmz = kwArray.length;
		} else {
		var totKeywordsAmz = 3;
		}
	if (kwArray.length<4){
		var totKeywordsEby = kwArray.length;
		} else {
		var totKeywordsEby = 4;
		}
	var amzKeywords = "";
	for(i=0; i<totKeywordsAmz; i++) {
		if(i>0){
			amzKeywords += "%20";
			}
		amzKeywords += kwArray[i];
		}
	var ebayKeywords = "@1+";
	for(i=0; i<totKeywordsEby; i++) {
		if(i>0){
			ebayKeywords += "+";
			}
		ebayKeywords += kwArray[i];
		}	
 }

//AdSense Ads
function google_ad_request_done(google_ads) {
	if (google_ads.length > 0 ) {
		document.write("<table cellspacing=\"0\" cellpadding=\"0\" width=\"96%\" class=\"msgtable\"><tr><td class=msg valign=top><a name=\"a1\"> <\/a><table width=\"100%\" cellspacing=0 cellpadding=0 border=0><tr class=msghead><td width=\"1%\" class=\"msgbfr1\">&nbsp;<\/td><td><table border=0 cellpadding=0 cellspacing=0><tr class=msghead><td  width=\"1%\" align=right nowrap class=msgT>To:&nbsp;<\/td><td width=\"68%\" nowrap class=msgFname><b>ALL<\/b> <nobr><\/nobr>&nbsp;<\/td><td width=\"30%\" align=right nowrap class=msgDate><i>Advertisement<\/i>&nbsp;<\/td><\/tr><tr style=\"line-height: 3px;\"><td width=\"1%\">&nbsp;<\/td><td width=\"68%\" nowrap>&nbsp;<\/td><td align=right nowrap>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><tr><td width=\"1%\" rowspan=3 class=\"msgleft\">&nbsp;<\/td><td nowrap class=wintiny><div style=\"line-height:5px\">&nbsp;</div>");      
		if (google_info.feedback_url) {
			document.write("<a href=\"" + google_info.feedback_url + "\">Ads by Google</a>");
			} else {
			document.write("Ads By Google");
			}  
			document.write("&nbsp;<\/td><\/tr><tr><td height=8><\/td><\/tr><tr><td class=msgtxt>");
			if (google_ads[0].type == 'text') {
				for(i = 0; i < 4; ++i) {
					if(google_ads.length>=(i+1)){
						document.write("<b><a class=\"msgrlink\" href=\"" +  google_ads[i].url + "\" target=\"_top\" onmouseOver=\"status='" + google_ads[i].visible_url + "';return true\" onmouseOut=\"window.status='';return true\">" + google_ads[i].line1 + "</a></b><div>" + google_ads[i].line2 + " " + google_ads[i].line3 + "</div><a class=\"wintiny\" href=\"" +  google_ads[i].url + "\" target=\"_top\" onmouseOver=\"status='" + google_ads[i].visible_url + "';return true\" onmouseOut=\"window.status='';return true\">" + google_ads[i].visible_url + "</a><div style=\"line-height:20px\">&nbsp;</div>");
						}
					}
				}
			}    
	document.write("<\/td><\/tr><tr><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><\/table><p><\/p>");    
}

//Amazon inline ads
function amzJSONCallback(feed){
	var amzAdContent = "";
	if(feed.Item.length!=0){
		amzAdContent +="<table cellspacing=\"0\" cellpadding=\"0\" width=\"96%\" class=\"msgtable\"><tr><td class=msg valign=top><a name=\"a1\"> <\/a><table width=\"100%\" cellspacing=0 cellpadding=0 border=0><tr class=msghead><td width=\"1%\" class=\"msgbfr1\">&nbsp;<\/td><td><table border=0 cellpadding=0 cellspacing=0><tr class=msghead><td  width=\"1%\" align=right nowrap class=msgT>To:&nbsp;<\/td><td width=\"68%\" nowrap class=msgFname><b>ALL<\/b> <nobr><\/nobr>&nbsp;<\/td><td width=\"30%\" align=right nowrap class=msgDate><i>Advertisement<\/i>&nbsp;<\/td><\/tr><tr style=\"line-height: 3px;\"><td width=\"1%\">&nbsp;<\/td><td width=\"68%\" nowrap>&nbsp;<\/td><td align=right nowrap>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><tr><td width=\"1%\" rowspan=3 class=\"msgleft\">&nbsp;<\/td><td nowrap class=wintiny><div style=\"line-height:5px\">&nbsp;</div><a href=\"http://www.amazon.com/gp/search?ie=UTF8&keywords="+amzKeywords+"&tag=delphiforum00-20&index=blended&linkCode=ur2&camp=1789&creative=9325\" target=\"_blank\">Cool stuff from Amazon.com</a></div><\/td><\/tr><tr><td height=8><\/td><\/tr><tr><td class=msgtxt><hr align=\"left\" style=\"width: 98%\" size=\"1\" noshade>";	
	  var startPoint = Math.floor(Math.random()*5);
	  if(startPoint <0){
	  	startPoint = 0;
	  	}
	  if(startPoint >(feed.Item.length-3)){
	  	startPoint = feed.Item.length-3;
	  	}
	  if(feed.Item.length<4){
	  	startPoint = 0;
	  	}
	  if(feed.Item.length<3){
	  	var endPoint = feed.Item.length;
		}else{
		var endPoint = startPoint + 3;
		}
	  for(i=startPoint; i<endPoint; i++) {
	    if(feed.Item[i].imageSrc){
		  	var imgTag = "<a href='http://www.amazon.com/gp/product/"+feed.Item[i].ASIN+"?tag=delphiforums-20' target=\"_blank\"><img src=\""+feed.Item[i].imageSrc+"\" alt=\"Product Image\" width=\""+feed.Item[i].imageWdt+"\" height=\""+feed.Item[i].imageHgt+"\" hspace=\"10\" border=\"0\"></a>";
			var imgCellWidth = parseInt(feed.Item[i].imageWdt) + 20;
			} else {
			var imgTag = "<a href='http://www.amazon.com/gp/product/"+feed.Item[i].ASIN+"?tag=delphiforums-20' target=\"_blank\"><img src=\"/dir-icon/62/5/amzNoImage.icon\" alt=\"Product Image\" width=\"60\" height=\"60\" hspace=\"10\" border=\"0\"></a>";
			var imgCellWidth = 80;
			}
		if(feed.Item[i].price){
			var priceInfo = "<br>New from "+feed.Item[i].price;
			} else {
			var priceInfo = "";
			}
	  	if(i%2){
			amzAdContent +="<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"right\"><b><a href='http://www.amazon.com/gp/product/"+feed.Item[i].ASIN+"?tag=delphiforums-20' target=\"_blank\">"+feed.Item[i].itemName+"</a></b>"+priceInfo+"</td><td width=\""+imgCellWidth+"\">"+imgTag+"</td></tr></table>";
			} else {
			amzAdContent +="<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\""+imgCellWidth+"\">"+imgTag+"</td><td><b><a href='http://www.amazon.com/gp/product/"+feed.Item[i].ASIN+"?tag=delphiforums-20' target=\"_blank\">"+feed.Item[i].itemName+"</a></b>"+priceInfo+"</td></tr></table>";
			}
	  	amzAdContent +="<hr align=\"left\" style=\"width: 98%\" size=\"1\" noshade>";
		}
	  amzAdContent +="<div style=\"width: 98%; text-align: right\"><img src=\"http://www.assoc-amazon.com/e/ir?t=delphiforum00-20&l=ur2&o=1\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" /><a href=\"http://www.amazon.com/gp/search?ie=UTF8&keywords="+amzKeywords+"&tag=delphiforum00-20&index=blended&linkCode=ur2&camp=1789&creative=9325\" target=\"_blank\">See all "+feed.Items+" items like this on Amazon.com</a></div><\/td><\/tr><tr><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><\/table>"; 
  	} else {
	amzAdContent +="<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab\" id=\"Player_68063f4f-3834-42be-87bc-f0283752409c\"  WIDTH=\"468px\" HEIGHT=\"60px\"> <PARAM NAME=\"movie\" VALUE=\"http://ws.amazon.com/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822%2FUS%2Fdelphiforum00-20%2F8009%2F68063f4f-3834-42be-87bc-f0283752409c&Operation=GetDisplayTemplate\"><PARAM NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"bgcolor\" VALUE=\"#FFFFFF\"><PARAM NAME=\"allowscriptaccess\" VALUE=\"always\"><embed src=\"http://ws.amazon.com/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822%2FUS%2Fdelphiforum00-20%2F8009%2F68063f4f-3834-42be-87bc-f0283752409c&Operation=GetDisplayTemplate\" id=\"Player_68063f4f-3834-42be-87bc-f0283752409c\" quality=\"high\" bgcolor=\"#ffffff\" name=\"Player_68063f4f-3834-42be-87bc-f0283752409c\" allowscriptaccess=\"always\"  type=\"application/x-shockwave-flash\" align=\"middle\" height=\"60px\" width=\"468px\"></embed></OBJECT>";
	}
  document.getElementById('amzAd').innerHTML = amzAdContent;
  }

//For eBay inline ads
function parseTimeLeft(tl) {
	tl = tl.replace("P", " ");
	tl = tl.replace("T", " ");
	tl = tl.replace(/\d{1,2}S$/, "");
	tl = tl.replace("M", " minutes ");
	tl = tl.replace("H", " hours ");
	tl = tl.replace("D", " days ");
	tl = tl.replace(" 1 minutes", " 1 minute");
	tl = tl.replace(" 1 hours", " 1 hour");
	tl = tl.replace(" 1 days", " 1 day");
	return tl;
	}
	
function ebayJSONCallback(feed){
	var ebayAdContent = "";
	if(feed.TotalItems!=0&&feed.SearchResult[0].ItemArray.Item&&feed.SearchResult[0].ItemArray.Item.length!=0){
		ebayAdContent += "<table cellspacing=\"0\" cellpadding=\"0\" width=\"96%\" class=\"msgtable\"><tr><td class=msg valign=top><a name=\"a1\"> <\/a><table width=\"100%\" cellspacing=0 cellpadding=0 border=0><tr class=msghead><td width=\"1%\" class=\"msgbfr1\">&nbsp;<\/td><td><table border=0 cellpadding=0 cellspacing=0><tr class=msghead><td  width=\"1%\" align=right nowrap class=msgT>To:&nbsp;<\/td><td width=\"68%\" nowrap class=msgFname><b>ALL<\/b> <nobr><\/nobr>&nbsp;<\/td><td width=\"30%\" align=right nowrap class=msgDate><i>Advertisement<\/i>&nbsp;<\/td><\/tr><tr style=\"line-height: 3px;\"><td width=\"1%\">&nbsp;<\/td><td width=\"68%\" nowrap>&nbsp;<\/td><td align=right nowrap>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><tr><td width=\"1%\" rowspan=3 class=\"msgleft\">&nbsp;<\/td><td nowrap class=wintiny><div style=\"line-height:5px\">&nbsp;</div><a href=\"http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=3&campid=5336241025&toolid=10001&customid="+webtag+"&ext="+ebayKeywords+"&satitle="+ebayKeywords+"\" target=\"_blank\">Cool auctions from eBay</a></div><\/td><\/tr><tr><td height=8><\/td><\/tr><tr><td class=msgtxt><hr align=\"left\" style=\"width: 98%\" size=\"1\" noshade>";	
	  var startPoint = Math.floor(Math.random()*5);
	  if(startPoint <0){
	  	startPoint = 0;
	  	}
	  if(startPoint >(feed.SearchResult[0].ItemArray.Item.length-3)){
	  	startPoint = feed.SearchResult[0].ItemArray.Item.length-3;
	  	}
	  if(feed.SearchResult[0].ItemArray.Item.length<4){
	  	startPoint = 0;
	  	}
	  if(feed.SearchResult[0].ItemArray.Item.length<3){
	  	var endPoint = feed.SearchResult[0].ItemArray.Item.length;
		}else{
		var endPoint = startPoint + 3;
		}
	  for(i=startPoint; i<endPoint; i++) {
	  	var itemURL = "http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=2&campid=5336232048&toolid=10013&customid="+webtag+"&ext="+feed.SearchResult[0].ItemArray.Item[i].ItemID+"&item="+feed.SearchResult[0].ItemArray.Item[i].ItemID+"";
	    if(feed.SearchResult[0].ItemArray.Item[i].GalleryURL){
		  	var imgTag = "<a href='"+itemURL+"' target=\"_blank\"><img src=\""+feed.SearchResult[0].ItemArray.Item[i].GalleryURL+"\" alt=\"Product Image\" hspace=\"10\" border=\"0\"></a>";
			} else {
			var imgTag = "<a href='"+itemURL+"' target=\"_blank\"><img src=\"/dir-icon/62/5/amzNoImage.icon\" alt=\"Product Image\" width=\"60\" height=\"60\" hspace=\"10\" border=\"0\"></a>";
			}
		if(feed.SearchResult[0].ItemArray.Item[i].ConvertedCurrentPrice){
			var priceInfo = "<br><b>Current Bid:</b> $"+feed.SearchResult[0].ItemArray.Item[i].ConvertedCurrentPrice.Value.toFixed(2);
			} else {
			var priceInfo = "";
			}
	  	if(i%2){
			ebayAdContent += "<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"right\" width=\"99%\"><b><a href='"+itemURL+"' target=\"_blank\">"+feed.SearchResult[0].ItemArray.Item[i].Title+"</a></b>"+priceInfo+"&nbsp;&nbsp;<b>Time Left:</b> "+parseTimeLeft(feed.SearchResult[0].ItemArray.Item[i].TimeLeft)+"</td><td width=\"1%\">"+imgTag+"</td></tr></table>";
			} else {
			ebayAdContent += "<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"1%\">"+imgTag+"</td><td width=\"99%\"><b><a href='"+itemURL+"' target=\"_blank\">"+feed.SearchResult[0].ItemArray.Item[i].Title+"</a></b>"+priceInfo+"&nbsp;&nbsp;<b>Time Left:</b> "+parseTimeLeft(feed.SearchResult[0].ItemArray.Item[i].TimeLeft)+"</td></tr></table>";
			}
	  	ebayAdContent += "<hr align=\"left\" style=\"width: 98%\" size=\"1\" noshade>";
		}
	  ebayAdContent += "<div style=\"width: 98%; text-align: right\"><a href=\"http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=3&campid=5336241025&toolid=10001&customid="+webtag+"&ext="+ebayKeywords+"&satitle="+ebayKeywords+"\" target=\"_blank\">Find all "+feed.TotalItems+" items like these on eBay</a></div><\/td><\/tr><tr><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><\/table>";
  	} else {
	ebayAdContent += "<a href='http://rover.ebay.com/rover/1/711-53200-19255-43/1?campid=5336230160&toolid=56013&customid=&def=a3h&n3y=1&p9m=1&v1e=1&x6n=1&m9q=1&l3s=1&b4x=1&k4v=1&u7v=1&a3h=1&mpvc='><img border='0px' src='http://rover.ebay.com/ar/1/711-53200-19255-43/1?campid=5336230160&toolid=56013&customid=&adtype=1&size=468x60&def=a3h&n3y=1&p9m=1&v1e=1&x6n=1&m9q=1&l3s=1&b4x=1&k4v=1&u7v=1&a3h=1&mpvc=' alt=''></a>";	
	}
  document.getElementById('eBayAd').innerHTML = ebayAdContent;
  }

//For Half.com inline ads	
function halfJSONCallback(feed){
	var halfAdContent = "";
	if(feed.Ack=="Failure"){
		halfAdContent += "<a href='http://rover.ebay.com/rover/1/8971-56017-19255-23/1?campid=5336241648&toolid=8971560171925523&customid=" + webtag + "'><img border='0px' src='http://rover.ebay.com/ar/1/8971-56017-19255-23/1?campid=5336241648&toolid=8971560171925523&customid=" + webtag + "&mpt=" + Math.floor(Math.random()*999999999999) + "&adtype=1&size=468x60&mpvc=' alt='Click Here'></a>";
		} else {
		if(feed.Products.Product&&feed.Products.Product.length!=0){
		    var halfSearchUrl = "http://rover.ebay.com/rover/1/8971-56017-19255-0/1?type=7&campid=5336241645&toolid=10001&customid="+webtag+"&ext="+ebayKeywords+"&mpre=http%3A%2F%2Fsearch.half.ebay.com%2F"+ebayKeywords;
			halfAdContent += "<table cellspacing=\"0\" cellpadding=\"0\" width=\"96%\" class=\"msgtable\"><tr><td class=msg valign=top><a name=\"a1\"> <\/a><table width=\"100%\" cellspacing=0 cellpadding=0 border=0><tr class=msghead><td width=\"1%\" class=\"msgbfr1\">&nbsp;<\/td><td><table border=0 cellpadding=0 cellspacing=0><tr class=msghead><td  width=\"1%\" align=right nowrap class=msgT>To:&nbsp;<\/td><td width=\"68%\" nowrap class=msgFname><b>ALL<\/b> <nobr><\/nobr>&nbsp;<\/td><td width=\"30%\" align=right nowrap class=msgDate><i>Advertisement<\/i>&nbsp;<\/td><\/tr><tr style=\"line-height: 3px;\"><td width=\"1%\">&nbsp;<\/td><td width=\"68%\" nowrap>&nbsp;<\/td><td align=right nowrap>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><tr><td width=\"1%\" rowspan=3 class=\"msgleft\">&nbsp;<\/td><td nowrap class=wintiny><div style=\"line-height:5px\">&nbsp;</div><a href=\""+halfSearchUrl+"\" target=\"_blank\">Cool bargians from Half.com</a></div><\/td><\/tr><tr><td height=8><\/td><\/tr><tr><td class=msgtxt><hr align=\"left\" style=\"width: 98%\" size=\"1\" noshade>";	
		  var startPoint = Math.floor(Math.random()*feed.Products.Product.length);
		  if(startPoint <0){
		  	startPoint = 0;
		  	}
		  if(startPoint >(feed.Products.Product.length-3)){
		  	startPoint = feed.Products.Product.length-3;
		  	}
		  if(feed.Products.Product.length<4){
		  	startPoint = 0;
		  	}
		  if(feed.Products.Product.length<3){
		  	var endPoint = feed.Products.Product.length;
			}else{
			var endPoint = startPoint + 3;
			} 
			var i =startPoint;
		  while (i<endPoint) {	
		  	var itemURL = "http://rover.ebay.com/rover/1/8971-56017-19255-0/1?type=8&campid=5336241696&toolid=10001&customid="+webtag+"&mpre=http%3A%2F%2Fproduct.half.ebay.com%2F_W0QQtgZinfoQQprZ"+feed.Products.Product[i].ProductID[0].Value;
		    if(feed.Products.Product[i].DisplayStockPhotos){
			  	var imgTag = "<a href='"+itemURL+"' target=\"_blank\"><img src=\""+feed.Products.Product[i].StockPhotoURL+"\" alt=\"Product Image\" hspace=\"10\" border=\"0\"></a>";
				} else {
				var imgTag = "<a href='"+itemURL+"' target=\"_blank\"><img src=\"/dir-icon/62/5/amzNoImage.icon\" alt=\"Product Image\" width=\"60\" height=\"60\" hspace=\"10\" border=\"0\"></a>";
				}
			if(feed.Products.Product[i].MinPrice){
				var priceInfo = "<br>Best price: <b>$"+feed.Products.Product[i].MinPrice.Value.toFixed(2)+"</b>";
				} else {
				var priceInfo = "";
				}
		  	if(i%2){
				halfAdContent += "<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"right\" width=\"99%\"><b><a href='"+itemURL+"' target=\"_blank\">"+feed.Products.Product[i].Title+"</a></b>"+priceInfo+"</td><td width=\"1%\">"+imgTag+"</td></tr></table>";
				} else {
				halfAdContent += "<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"1%\">"+imgTag+"</td><td width=\"99%\"><b><a href='"+itemURL+"' target=\"_blank\">"+feed.Products.Product[i].Title+"</a></b>"+priceInfo+"</td></tr></table>";
				}
		  	halfAdContent += "<hr align=\"left\" style=\"width: 98%\" size=\"1\" noshade>";		
			i++;
			}
		  halfAdContent += "<div style=\"width: 98%; text-align: right\"><a href=\""+halfSearchUrl+"\" target=\"_blank\">Find more items like these on Half.com</a></div><\/td><\/tr><tr><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/table><\/td><\/tr><\/table>";
		}
  	}
  document.getElementById('halfAd').innerHTML = halfAdContent;
  }  
  
//Photobucket Integration
function photobucket_complete(inurl,width,height){
	if ((width != "" && height != "")&&(width != 0 && height != 0)){
		var imgTag = "<img src=\"" + inurl + "\" alt=\"\" width=\"" + width + "\" height=\"" + height + "\" border=\"0\">";
		} else {
		var imgTag = "<img src=\"" + inurl + "\" alt=\"\" border=\"0\">";
		}	
	if (location.pathname=="/n/mydelphi/myaccount.asp"){
		if (document.getElementById('compMsgTxt')){
			document.getElementById("mW").checked = true;
			document.getElementById("mH").checked = false;
			setMode(true);
			document.frames('idEdit').document.body.innerHTML += imgTag;
			} else {
			document.getElementById("signatureHtmly").checked = true;		
			document.myaccountinfo.signature.value += imgTag;
			}		
		}		
	if (location.pathname=="/n/control/welcomescreen.asp"){
		if (document.getElementById('compMsgTxt')){
				document.getElementById("mW").checked = true;
				document.getElementById("mH").checked = false;
				setMode(true);
				document.frames('idEdit').document.body.innerHTML += imgTag;
				} else {
				if (document.welcomeform.welcome){
					if(location.search.match('noHtml=no')){
					alert('You can\'t insert an image when in text mode.\nPlease click the \'Edit HTML Version\' link.');
					} else {	
					document.welcomeform.welcome.value += imgTag;
					}
				}		
			}	
		}
	}
function showPhotobucket(width,height,buttonText){
	document.write("<iframe name=\"plugin\" id=\"plugin\" src=\"http:\/\/photobucket.com\/plugin?width=" + width + "&height=" + height + "&pbaffsite=701&bg=%23FFFFFF&border=false&bordercolor=%23000000&linkType=url&textcolor=%23000000&linkcolor=%230000FF&media=image&btntxt=" + escape(buttonText) + "&searchenabled=false&dimensions=true&dividers=false&url=http:\/\/" + location.hostname + "\/delphidocsz\/photobucket\/script.html\" bgcolor=\"transparent\" width=\"" + width + "\" height=\"" + height + "\" frameborder=\"0\" scrolling=\"no\" style=\"border-width: 1px 0px 1px 0px; border-style: solid; border-color: #C0C0C0;\"><\/iframe>")
	}