﻿// JScript File

var sSrch;
var cSTID;

sSrch = "gps";

function getClientWidth() {
    return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight() 
{
    return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function RipDeal(strSearch)
{
    sSrch = strSearch;
    var CompDiv = document.getElementById('EnsureHidden');

    with (CompDiv.style)
    {
        var sTop = (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        //alert(sTop);
        CompDiv.style.top = sTop + "px";
        //alert(CompDiv.style.top);
    }

    if(document.documentElement)
    {
        document.body.scroll = "no";
        document.documentElement.style.overflow = "hidden"
    } else {
        document.body.style.overflow="hidden";
        document.body.style.marginRight='0px';
    }

    with (CompDiv.style)
    {
        display = "";
        visibility = "";
    }
}

function resizeIF()
{
  var sizeX = 600;
  var sizeY = 400;

  sizeX = getClientWidth() - 200;
  sizeY = getClientHeight();

  document.getElementById('EnsureDealFrame').style.width=sizeX + "px";
  document.getElementById('EnsureDealFrame').style.height=sizeY + "px" ;

}

function CloseIt()
{
  var CompDiv = document.getElementById('EnsureHidden');

  //Esc will lose focus and close it. Need an input field to focus on.
  with (CompDiv.style)
  {
    display = "none";
    visibility = "hidden";
  }

  if(document.documentElement) 
  {
    document.body.scroll = "auto";
    document.documentElement.style.overflow = "auto"
    document.body.style.overflow = "auto";
    document.body.style.marginRight='0px';
  } else {
    document.body.scroll = "auto";
    document.documentElement.style.overflow = "auto"
    document.body.style.overflow = "auto";
    document.body.style.marginRight='0px';
  }
}

function selectSite(selectedST)
{
    var STID = selectedST.id.substr(4);
    var wsrc = "";
    
    switch (STID)
    {
        case '1': { wsrc = "DealRow.htm"; break; }
        case '2': { wsrc = "http://www.Dealitem.com/"; break; }
        case '3': {  wsrc = "http://www.eDealInfo.com"; break; }
        case '4': {  wsrc = "http://www.DealNews.com"; break; }
        case '5': {  wsrc = "http://www.BensBargains.net"; break; }
        case '6': {  wsrc = "http://www.BradsDeals.com"; break; }
        case '7': {  wsrc = "http://www.Deals2Buy.com"; break; }
        case '8': {  wsrc = "http://www.FatWallet.com"; break; }
        case '9': {  wsrc = "http://www.CrazyCoolDealz.com"; break; }
        case '10': { wsrc = "http://www.CrazyTownDeals.com"; break; }
        case '11': { wsrc = "http://www.DealsatNet.com   "; break; }
        case '12': { wsrc = "http://www.DealTaker.com"; break; }
        case '13': { wsrc = "http://www.TechBargains.com"; break; }
        case '14': { wsrc = "http://www.KeepCash.com"; break; }
        case '15': { wsrc = "http://www.CheapStingyBargains.com"; break; }
        case '16': { wsrc = "http://www.DealCatcher.com"; break; }
        case '17': { wsrc = "http://www.RetailRetreat.com"; break; }
        case '18': { wsrc = "http://www.BargainJack.com"; break; }
        case '19': { wsrc = "http://www.Dealigg.com"; break; }
        case '20': { wsrc = "http://www.AntiRebate.com"; break; }
        case '21': { wsrc = "http://www.GottaDeal.com"; break; }
        default:   { document.write('<font>Error: ' + STID + '</font><br>'); break }
    }

    if (STID == "8" || STID == "33" )
    {
        window.open(wsrc, "_blank");
    } else {
        if (cSTID) if (cSTID == selectedST.id) return;
        //selectedST.className="SiteBarS";
        //selectedST.onmouseover="this.className='SiteBarH'";
        //selectedST.onmouseout="this.className='SiteBarS'";

        document.getElementById('EnsureDealFrame').src = wsrc;
        if (cSTID)
        {
            //document.getElementById(cSTID).className="SiteBar";
            //document.getElementById(cSTID).onmouseover="this.className='SiteBarH'";
            //document.getElementById(cSTID).onmouseout="this.className='SiteBar'";
        }
        cSTID = selectedST.id;
    }
}

function OMOV(divO)
{
   divO.className='SiteBarH';
}

function OMOT(divO)
{
   divO.className='SiteBar';
}

function SearchSubmit()
{
    document.getElementById('q1').focus();
    if (document.getElementById('q1').value == "")
    {
        alert('Please enter a value to search');
        return;
    }
    sSrch = document.getElementById('q1').value;
    document.getElementById('form1').action='http://www.Dealitem.com/Search.aspx?q=' + sSrch;
    document.getElementById('form1').submit();
}
