<!--

var DTMENU1 = "<tr><td background=popimgs/left.gif></td><td bgcolor=#fff4ea align=right class=popxbtn><img src=popimgs/whtsp.gif border=0 width=3 height=1><img border=0 src=popimgs/cancel.gif onClick='exitPopup();' /></td><td background=popimgs/right.gif></td></tr>";
var DTMENU2 = "<tr><td background=popimgs/left.gif></td><td bgcolor=#fff4ea align=right class=popxbtn><img border=0 src=popimgs/fullpg.gif onClick='goFullPg();' /><img src=popimgs/whtsp.gif border=0 width=3 height=1><img border=0 src=popimgs/cancel.gif onClick='exitPopup();' /></td><td background=popimgs/right.gif></td></tr>";
var DTSTART1 = "<table bgcolor=#ffffff border=0 cellspacing=0 cellpadding=0><tr><td><img  border=0 src=popimgs/topl.gif></td><td background=popimgs/top.gif></td><td><img border=0 src=popimgs/topr.gif></td></tr>";
var DTSTART2 ="<tr><td background=popimgs/left.gif></td><td><table border=0 cellspacing=2 cellpadding=2><tr><td>";
var DTEND = "</td></tr></table></td><td background=popimgs/right.gif></td></tr><tr><td><img border=0 src=popimgs/botl.gif></td><td background=popimgs/bot.gif></td><td><img border=0 src=popimgs/botr.gif></td></tr></table>";
var POPUPHTML;
var popname = null;
var popposid = null;

var kwa = new Array("All","Advertise","Apartment","Apparel","Appliances","Astrology","Attractions","Automobile","Babies","Beauty","Bed & Bath","Bikes","Birthdays","Books","Bracelets","Bridal","Business","Cameras","Camping","Celebrity","Coffee","Computer","Contacts","Cooking & Food","Cosmetics","Courier","Deals","Desktops","Decoration","Diet","Education","Electronics","Employment","Entertainment","Family","Fashion","Finance","Flowers & Fruits","Fragrances","Furniture","Games","Glamour","Health","Hobbies","Home","Hotels","Immigration","Insurance","Internet","Jewelry","Language","Laptops","Legal","Magazines","Marketing","Math","Men","Movies","MP3 Players","Music","News","Office","Outdoors","Party","People","Pets","Pictures","Posters","Prom Dresses","Publications","Real Estate","Relations","Rentals","Schools","Science & Social","Shopping","Society","Software","Songs","Sports","Telephone","Theatres","Tools","Toys","Transport","Travel","Vacation","Video","Web","Women","Yellow Pages","Z-Miscellaneous");
function exitPopup()
{
  var element = document.getElementById(popname);
  element.innerHTML = POPUPHTML;
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}

function exitIf(prevpop)
{
  if (prevpop == null) {return false;}
  var prevelem = document.getElementById(prevpop);
  if (prevelem != null)
  {
      if (prevelem.style.visibility == "visible")
      {
        exitPopup();
      }
  }
}

function showWait()
{
  if (popname != null)
  {
    var x = document.getElementById(popname);
    if (x != null) 
    {
        x.innerHTML = DTSTART1 + DTSTART2 + "<table style='width:150px;height:40px;background:#ffffff;'><tr><td width=100% align=center><img src=popimgs/anim.gif border=0></td></tr></table>" + DTEND;
    }
  }
}


function showPopup(id, position_id, name, menu)
{
  exitIf(popname);
  var element = document.getElementById(id);
  if (element.style.visibility == "visible") {return false;}
  var x = 0; var y = -50;
  popname = id;
  popposid = position_id;

  var elemT = document.getElementById("poptitle");
  if (elemT != null && name.length > 1) {elemT.innerHTML = name;}

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";
  POPUPHTML = element.innerHTML;
  element.innerHTML = DTSTART1 + menu + DTSTART2 + POPUPHTML + DTEND;

  var position_element = document.getElementById(position_id);

  for (var p = position_element; p; p = p.offsetParent)
  if (p.style.position != 'absolute')
  {
      x += p.offsetLeft;
      y += p.offsetTop ;
  }

  x += position_element.clientWidth;

  if (y < 5) {y = 5;}
  var xdf = document.body.clientWidth - x;
  if (xdf < 200) {x += (xdf - 300); }

  element.style.left = x+'px';
  element.style.top  = y+'px';
}

var xmlHttp = null;
function GetXmlHttpObject()
{
    xmlHttp = null;
    try
    {
        xmlHttp = new XMLHttpRequest();  // fire fox, Opera 8.0+, Safari
    }
    catch (e)
    {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");  // Internet explorer
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    return xmlHttp;
}


function sendHttpGetRequest(url, fCallBack)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) { alert("Unable to create xml object"); return false; }

    xmlHttp.onreadystatechange = fCallBack;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    return false;
}

function sendHttpPostRequest(url, params, fCallBack)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) { alert("Unable to create xml object"); return false; }

    xmlHttp.onreadystatechange = fCallBack;
    xmlHttp.open('POST', url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
    return false;
}


function IsAlphaNum(str) {
  $cstr = new String(str);
  return $cstr.match(/^[a-zA-Z0-9 ]+$/);
}

function ltrim(str)
{
    while (str.substring(0,1) == ' ')
    {
        str = str.substring(1, str.length);
    }
    
    return str;
}


function checkValue(fld, nam, len)
{
    var txtStr = ltrim(fld.value);
    
    if (txtStr == "")
    {
        alert(nam + " can not be empty.");
        fld.focus();
        return false;
    }
    else if (txtStr.length < len)
    {
        alert(nam + " is too short.");
        fld.focus();
        return false;
    }
    
    return true;
}

function getKeyword(pid)
{
    pid = pid-1000;
    if (pid < 0 || pid >= kwa.length) {return "";}
    return kwa[pid];
}


var helpMsgArr = new Array(30);
helpMsgArr[0] = "<center><img src=popimgs/anim.gif border=0></center>";
helpMsgArr[1] = "Your phone number will be displayed along with your classified so that users can contact you.";
helpMsgArr[2] = "If you have a webpage with photos or other information related to this classfied, please enter the <b>url</b> here.";
helpMsgArr[3] = "If you want the users to send you an email please provide it here. Users will directly send email to you.";
helpMsgArr[4] = "Password is required to make changes to the classified and/or to view the responses posted by other users regarding this classified.";
helpMsgArr[5] = "Please provide short description (about 80 characters) about your classified. This is the description which will be displayed on classifieds page.";
helpMsgArr[6] = "Please provide the full description  about your classified. Please do not use HTML tags.";
helpMsgArr[7] = "Zip code is required to search the classifieds.";
helpMsgArr[8] = "Please enter the code shown. This is required to reduce spammers.";
helpMsgArr[9] = "If you want to change the password enter your new password.";
helpMsgArr[10] = "Your Password is required to make changes to the posting and/or to change your password.";
helpMsgArr[11] = "Please provide description about the classified being considered as SPAM.";
helpMsgArr[12] = "Please enter your email address. This is an optional field.";
helpMsgArr[13] = "Please enter a title for the webpage. This can be the search string or search phrase you used to find the webpage.(max 128 characters)";
helpMsgArr[14] = "Please enter the full url to the webpage. ex: www.mathslice.com. (max 255 characters)";
helpMsgArr[15] = "Please provide goog description about your advertisement (upto 96 characters). Please do not use HTML tags.";
helpMsgArr[16] = "Please select the number of days you want your advertisement to be active.";
helpMsgArr[17] = "Select the number of impressions per day.";
helpMsgArr[18] = "Password is required to make changes to the Ad. and/or to view the statistics.";
helpMsgArr[19] = "name of the song, book, actor, movie etc.";
helpMsgArr[20] = "For actors/actress/movies you can give an url to their website or for songs - may be an url to sample.";
helpMsgArr[21] = "Describe why this song, movie etc. is your favorite.";
helpMsgArr[22] = "Password is required to make changes or to view comments about your post.";
helpMsgArr[23] = "Please provide full description about the webpage (upto 255 characters). Please do not use HTML tags.";
helpMsgArr[24] = "Please enter a title for the advertisement.(max 36 characters)";
helpMsgArr[25] = "Please enter the full url to the webpage or website.(max 128 characters)";

function showHelp(posid, msgid)
{

    exitIf('popup_help');
    var helpelem = document.getElementById("helpmsgid");
    if (helpelem != null)
    {
        helpelem.innerHTML = helpMsgArr[msgid];
    }
    showPopup('popup_help', posid, "", DTMENU1);
}


function showcat(posid, pid, phpname)
{
    exitIf('popup_category');
    var helpelem = document.getElementById("tdcategoryid");
    if (helpelem != null)
    {
        var optionsstr = "<option value=1000>All</option>";
        for (var i = 1; i < kwa.length; i++)        
        {
            selstr = ""; if (pid == 1000+i) {selstr = "selected";}
            optionsstr = optionsstr + "<option value=" + (1000+i) + " " + selstr + ">" + kwa[i] + "</option>";
        }
        helpelem.innerHTML = "<form method=post action=" + phpname + "><select class=pnk12 name='pid' size=7>" + optionsstr + "</select><br><br><input class=popbtn type=submit name=submit value=' OK '></form>";
    }
    showPopup('popup_category', posid, "", DTMENU1);
}

function getOptionList(start, pid)
{
	var optionsstr = "";
	for (var i = start; i < kwa.length; i++)        
	{
	    selstr = "";if (pid == 1000+i) {selstr = "selected";}
	    optionsstr = optionsstr + "<option value=" + (1000+i) + " " + selstr + ">" + kwa[i] + "</option>";
	}
	return "<select class=pnk12 name='pid'>" + optionsstr + "</select>";
}

function showMap(addr)
{
    var escAddr = escape(addr);
    parent.location = "http://maps.google.com/maps?q=" + escAddr;
}

var fArray = new Array('All','Celebrity','Book','Food','Movie','Music','Pet','Place','Other');

function showfcat(posid, fid, phpname)
{
    exitIf('popup_category');
    var helpelem = document.getElementById("tdcategoryid");
    if (helpelem != null)
    {
        var optionsstr = "<option value=100>All</option>";
        for (var i = 1; i < fArray.length; i++)        
        {
            selstr = ""; if (fid == 100+i) {selstr = "selected";}
            optionsstr = optionsstr + "<option value=" + (100+i) + " " + selstr + ">" + fArray[i] + "</option>";
        }
        helpelem.innerHTML = "<form method=post action=" + phpname + "><select class=pnk12 name='fid' size=7>" + optionsstr + "</select><br><br><input class=popbtn type=submit name=submit value=' OK '></form>";
    }
    showPopup('popup_category', posid, "", DTMENU1);
}

function getFOptionList(start, fid)
{
	var optionsstr = "";
	for (var i = start; i < fArray.length; i++)        
	{
	    selstr = "";if (fid == 100+i) {selstr = "selected";}
	    optionsstr = optionsstr + "<option value=" + (100+i) + " " + selstr + ">" + fArray[i] + "</option>";
	}
	return "<select class=pnk12 name='fid'>" + optionsstr + "</select>";
}

function getFavorword(fid)
{
    fid = fid-100;
    if (fid < 0 || fid >= fArray.length) {return "";}
    return fArray[fid];
}

function do_clicks(a,b)
{
    var url = "do_clicks.php";
    var rnd = new Date().getTime() % 1000000;
    url = url + "?a=" + a + "&b=" + b + "&rnd=" + rnd;    
    sendHttpGetRequest(url, null);
    return false;
}


-->

