function openPicture2(imageName,imageWidth,imageHeight,alt,posLeft,posTop,desc) {
	alt=titles[alt];
	desc=descriptions[desc];
	alert(desc);
}

function openPicture(imageName,imageWidth,imageHeight,alt,posLeft,posTop,desc) {
	alt=titles[alt];
	desc=descriptions[desc];
	newWindow = window.open("","","width=600,height=850,scrollbars=1,resizable=1");
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#ffffff" leftmargin="20" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<center><table border="0" cellpadding="0" cellspacing="0">');
	newWindow.document.write('<tr><td align="center"><table width="90%"><tr><td style="font-family: arial,helvetica,sans-seric; font-size: 9pt">'+unescape(desc)+'</td></tr></table></td></tr>');
	newWindow.document.write('<tr><td>&nbsp;</td></tr><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width="'+imageWidth+'"  alt="'+alt+'">'); 
	newWindow.document.write('</tr></td></table></center>');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function openSlideShow(keyval,slideNum) {
	newWindow = window.open("/cgi-bin/webdata_pro.pl?_cgifunction=adhub_slideshow&slideNum="+slideNum+"&keyval="+keyval,"","width=600,height=850,scrollbars=1,resizable=1");
}

function newwin(url,w,h) {
	if (w>screen.width) {w=screen.width-10};
	if (h>screen.height) {h=screen.height};
    options="width="+w+",height="+h+",scrollbars=1,resizable=1";
	nw=window.open('','',options);
	nw.document.write('<TABLE BORDER=0 WIDTH=100% HEIGHT=100%><TR><TD ALIGN=CENTER VALIGN=MIDDLE><H2>Loading <BLINK>....</BLINK></H2></TD></TR></TABLE>');
	nw.document.close();
	nw.location=url;
}


function newbrowser(url,w,h) {
	if (w>screen.width) {w=screen.width-10};
	if (h>screen.height) {h=screen.height};
    options="width="+w+",height="+h+",titlebar,location,directories,menubar,toolbar,scrollbars,resizable";
	nw=window.open(url,'',options);
}


function open_Demo_Window(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function clickthru(url,referrer,id) {
  result="http://www.adhub.com/cgi-bin/webdata_pro.pl?_cgifunction=clickthru"+
	     "&url="+escape(url)+"&referrer="+escape(referrer)+"&id="+id;
  frames['clickCount'].location.href=result;
}

function clickthru_new(url,referrer,id) {
  result="http://www.adhub.com/cgi-bin/webdata_pro.pl?_cgifunction=clickthru"+
	     "&url="+escape(url)+"&referrer="+escape(referrer)+"&id="+id+"&noredirect=1";
  frames['clickCount'].location.href=result;
}



function MM_openBrWindow(theURL,winName,features) { //v2.0 
  window.open(theURL,winName,features); 
} 


var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

function addToList(id,category) {
  var comment="";
  //comment=prompt('Add this company to my AdHub list. The list will pop-up automatically. Access your list under Search on the left navigation. Add comments below:','');
  //if (comment==null) {return};
  setCookie("favList_"+id,category+"|"+comment,365,'/','adhub.com');
  showFavList();
}

function removeAllFavorites() {
  if (!confirm('Are you sure you want to remove all companies?')) {return}
  var theCookies=document.cookie.split(';');
  for (i=0;i<theCookies.length;i++) {
    var parts=theCookies[i].split('=');
    var cookiename=new String(parts[0]);
    if (cookiename.indexOf('favList_')>-1) {
      setCookie(cookiename,"-1",-100,'/','adhub.com');
    }
  }
  location.reload(true);
}

function showFavList() {
  var favWin=window.open('/cgi-bin/webdata_pro.pl?_cgifunction=showFavoritesList','favWin','width=500,height=500,toolbar=1,menubar=1,scrollbars=1,resizable=1,status=1,screenX=5,screenY=5');
  favWin.focus();
}

function removeFav(id) {
  setCookie("favList_"+id,"-1",-100,'/','adhub.com');
}

function saveComment(id,comment) {
  var oldval=getCookie("favList_"+id);
  var parts=oldval.split('\|');
  parts[1]=comment;
  setCookie("favList_"+id,parts.join('\|'),365,'/','adhub.com');
}

//function setFavList(favList) {
//  var favList=getFavList();
//  for (var id in favList) {
//	  if (!id) {continue};
//	  if (!id.match(/^f[0-9]+$/)) {continue};
//	  id=id.replace('f','');
//	  setCookie('favList_'+id,favList[''+id+''],365,'/','adhub.com');
//  }
//}

//function getAllCookies() {
//  var results=new Array();
//  var ck=document.cookie;
//  var cookies=ck.split(/\; */);
//  for (i=0;i<cookies.length;i++) {
//    var cookie=cookies[i];
//    var parts=cookie.split('=');
//	if (parts[0]) {results.push(unescape(parts[0]))};
//  }
//  return results;
//}

//function getFavList() {
//  var favList=new Array();
//  var cookies=getAllCookies();
//  if (!cookies.length) {return favList};
//  for (i=0;i<=cookies.length;i++) {
//	var data_string=getCookie(cookies[i]);
//	var parts=data_string.split('\|');
//	var id=cookies[i];
//	id=id.replace('favList_','');
//	favList['f'+id+'']=parts[0]+"|"+parts[1];
//  }
//  return favList;
//}


function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {expires = expires * 1000 * 60 * 60 * 24};

	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
	( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
	( ( path ) ? ';path=' + path : '' ) +
	( ( domain ) ? ';domain=' + domain : '' ) +
	( ( secure ) ? ';secure' : '' );
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1 ;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1){ c_end=document.cookie.length};
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function toggle(n) {
  if (document.getElementById(n).style.display=="inline") {
	document.getElementById(n).style.display="none";
  } else {
	document.getElementById(n).style.display="inline";
  }
}
