function getHTTP()
{
  if (window.XMLHttpRequest) 
  {
    http = new XMLHttpRequest();
  } 
  else if (window.ActiveXObject) 
  {
    http = new ActiveXObject("Microsoft.XMLHTTP");
  }
  return http;
}    

function checkTagAvailable()
{
  tag = document.getElementById('tagtitle').value;
  
  http = getHTTP();

  if (http != null) 
  {
    http.open("GET", "ajax.php?tagavailable="+tag, true);
    http.onreadystatechange = ajaxTagAvailable;
    http.send(null);
  }
}

function ajaxTagAvailable() 
{
  if (http.readyState == 4) 
  {
    document.getElementById("tagavailable").innerHTML = http.responseText;
  }
}

var content = '';
var boxheight=500;          //BACKGROUND BOX HEIGHT IN PIXELS.
var boxwidth=1200;          //BACKGROUND BOX WIDTH IN PIXELS.
var boxcolor="transparent";    //BACKGROUND BOX COLOR.
var speed=1;              //SPEED OF SCROLL IN MILLISECONDS (1 SECOND=1000 MILLISECONDS)..
var pixelstep=1;           //PIXELS "STEPS" PER REPITITION.
var goright=false;         //LEFT TO RIGHT=TRUE , RIGHT TO LEFT=FALSE
var pauseOnmouseover=true; //SET TO "true" TO ENABLE PAUSE WHEN MOUSEOVER, "false" TO DISABLE IT.

//** DO NOT EDIT BEYOND THIS POINT **
var outer,inner,ref,elementwidth;
var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;
var txt='';
var goscroll=true;
if(ns4){
txt+='<table cellpadding=0 cellspacing=0 border=0 height='+boxheight+' style="width:'+boxwidth+'%"><tr><td>';
txt+='<ilayer name="ref" bgcolor="'+boxcolor+'" width="'+boxwidth+'" height="'+boxheight+'"></ilayer>';
txt+='</td></tr></table>';
txt+='<layer name="outer"  bgcolor="'+boxcolor+'" visibility="hidden" width="'+boxwidth+'" height="'+boxheight+'" '+((pauseOnmouseover)? 'onmouseover="goscroll=false" onmouseout="goscroll=true"':'')+'>';
txt+='<layer name="inner"  visibility="hidden" left="2" top="2">';
txt+=content;
txt+='</layer></layer>';
txt = 'test';
}else{
txt+='<div id="ref" style="position:absolute; top:80px; left: 0px;width:'+boxwidth+'%; width: 100px; height:'+boxheight+'; visibility:visible; background-color:'+boxcolor+';" '+((pauseOnmouseover)? 'onmouseover="goscroll=false" onmouseout="goscroll=true"':'')+'></div>';
txt+='<div id="outer" style="position:absolute; width:100%; height:'+boxheight+'; visibility:hidden; background-color:'+boxcolor+'; overflow:hidden;">';
txt+='<div id="inner"  style="position:absolute; width:1200px; visibility:hidden; left:2px; top:2px; overflow:hidden; cursor:default;" '+((pauseOnmouseover)? 'onmouseover="goscroll=false" onmouseout="goscroll=true"':'')+'>';
txt+=content;
txt+='</div></div>';
}
document.write(txt);
txt=0;

function getPageLeft(el){
var x;
if(ns4)return el.pageX;
if(ie4||w3c){
x = 0;
while(el.offsetParent!=null){
x+=el.offsetLeft;
el=el.offsetParent;
}
x+=el.offsetLeft;
return x;
}}

function getPageTop(el){
var y;
if(ns4)return el.pageY;
if(ie4||w3c){
y=0;
while(el.offsetParent!=null){
y+=el.offsetTop;
el=el.offsetParent;
}
y+=el.offsetTop;
return y;
}}

function getElWidth(el){
if(ns4)return (el.document.width)? el.document.width : el.clip.right-el.clip.left;
else if(ie4||ie5)return (el.style.width)? el.style.width:el.clientWidth;
else if(w3c)return (el.style.width)?parseInt(el.style.width):parseInt(el.offsetWidth);
else return -1;
}

window.onresize=function(){
if(ns4)setTimeout('history.go(0)', 400);
else{
outer.style.left=getPageLeft(ref)+'px';
outer.style.top=getPageTop(ref)+'px';
}}

function scrollbox()
{
  if(goscroll)
  {
    if(ns4)
    {
      inner.left+=(goright)? pixelstep: -pixelstep;
      inner.clip.right=(boxwidth-inner.left-2>boxwidth)? boxwidth-2 : boxwidth-inner.left-2;
      inner.clip.left=-inner.left+2;
      if(goright)
      {
        if(inner.left>boxwidth)inner.left=-elementwidth;
      }
      else
      {
        if(inner.left<-(elementwidth))inner.left=boxwidth+2;
      }
    }
    else
    {
      inner.style.left=parseInt(inner.style.left)+((goright)? pixelstep: -pixelstep)+'px';
      if(goright)
      {
        if(parseInt(inner.style.left)>boxwidth)inner.style.left=-elementwidth+'px';
      }
      else
      {
        if(parseInt(inner.style.left)<-parseInt(elementwidth))
        {
          inner.style.left=boxwidth+'px';
        }
      }
    }
  }
}


window.onload=function()
{

ref=(ns4)?document.layers['ref']:(ie4)?document.all['ref']:document.getElementById('ref');
outer=(ns4)?document.layers['outer']:(ie4)?document.all['outer']:document.getElementById('outer');
inner=(ns4)?outer.document.layers['inner']:(ie4)?document.all['inner']:document.getElementById('inner');
elementwidth=getElWidth(inner);

if(ns4){

outer.clip.width=boxwidth;
outer.clip.height=boxheight;
outer.moveTo(getPageLeft(ref),getPageTop(ref));
inner.left=(goright)? -elementwidth : boxwidth-2;
inner.clip.width=0
inner.clip.height=boxheight-4;
outer.visibility="show";
inner.visibility="show";

}
else{

outer.style.left=getPageLeft(ref)+'px';
outer.style.top=getPageTop(ref)+'px';
//inner.style.width=elementwidth+'px';
inner.style.left=((goright)? -elementwidth : boxwidth-2)+'px';
inner.style.visibility="visible";

}

setInterval('scrollbox()',speed);

}

function calcprice(newtag, currentsize, currentclicks)
{
  if (newtag == true)
  {
    currentsize = 12;
    currentclicks = 100;
  }
  
  size_sel  = document.getElementById('tagsize');
  click_sel = document.getElementById('tagclicks');

  size_idx  = size_sel.selectedIndex;
  click_idx = click_sel.selectedIndex;
  
  font_size = document.getElementById('tagsize').options[size_idx].value;
  click_package = document.getElementById('tagclicks').options[click_idx].value;
  
  document.getElementById('tagsample').style.fontSize = (font_size)+'px';
  
  var sum = 0;
  var clickprice = 0;
  
  if (newtag)
  {
    if (click_package == 300) clickprice = 5;
    if (click_package == 1000) clickprice = 10;
    sum = 10 + ((font_size-12)/4)*2 + clickprice;
  }
  else
  {
    if (currentclicks == 100)
    {
      if (click_package == 300) clickprice = 5;
      if (click_package == 1000) clickprice = 10;
    }
    else if (currentclicks == 300)
    {
      if (click_package == 1000) clickprice = 5;
    }
    sum = ((font_size-currentsize)/4)*2 + clickprice;
  }
  
  document.getElementById('price').innerHTML = '$'+sum;
}

function tagPreview()
{
  document.getElementById('tagsample').innerHTML = document.getElementById('tagtitle').value;
}

function showbox(tagid)
{
  document.getElementById(tagid).style.visibility = 'visible';
}

function hidebox(tagid)
{
  document.getElementById(tagid).style.visibility = 'hidden';
}
