var carr=["", "v3rify", "jugl3r", "t7hyw", "p8ib4l", "d3rbby", "ca8tch", "f7alr", "p4r9ps", "h88pn", "eur9c", "r4st3l", "debl8"];
var vmax=0;

var doDrag=false;
var ocurs=null;
var dObj=null;
var yoff=0;
var mPosy=0;
var banner=0;
var pic=1;
var bannern=0;
var picn=0;

function videoslide()
{ vmax=document.getElementById("vbox").scrollHeight-458;
  document.onmousedown=vdragger; }
function nowslide()
{ vmax=document.getElementById("nbox").scrollHeight;
  if (vmax>314) {vmax -= 314;}
  document.onmousedown=ndragger;
  bannern = banners.length;
  picn = picshows.length;
  document.getElementById("banner").style.backgroundImage="url(images/"+banners[0]+")";
  document.getElementById("picshow").style.backgroundImage="url(images/"+picshows[0]+")";
  setInterval(rebanner, 4000);
  setInterval(repic, 5000); }

function rebanner()
{ ++banner; if (banner==bannern) {banner=0;}
  document.getElementById("banner").style.backgroundImage="url(images/"+banners[banner]+")"; }
function repic()
{ ++pic; if (pic==picn) {pic=0;}
  document.getElementById("picshow").style.backgroundImage="url(images/"+picshows[pic]+")"; }

function vdragger(e)
{ var cu="-moz-grabbing";
  if (e==null) {e=window.event; cu="move"; var target=e.srcElement;}
  else {var target=e.target;}
  ocurs=target.style.cursor;
  var cn=target.className; 
  if (/vbottle/.test(cn))
  { dObj=target; 
    dObj.style.cursor=cu;
    doDrag=true;
    mouseCoords(e);
    yoff=mPosy-parseInt(dObj.offsetTop);
    document.onmousemove=vmover;
    document.onmouseup=cleanup;
    return false; } }
function ndragger(e)
{ var cu="-moz-grabbing";
  if (e==null) {e=window.event; cu="move"; var target=e.srcElement;}
  else {var target=e.target;}
  ocurs=target.style.cursor;
  var cn=target.className; 
  if (/nvinyl/.test(cn))
  { dObj=target; 
    dObj.style.cursor=cu;
    doDrag=true;
    mouseCoords(e);
    yoff=mPosy-parseInt(dObj.offsetTop);
    document.onmousemove=nmover;
    document.onmouseup=cleanup;
    return false; } }


function vmover(e)
{ if (e==null) {e=window.event;} 
  if (doDrag)
  { mouseCoords(e);
    var y=mPosy-yoff;
    if (y>386) { y=386; }
    else if (y<0) { y=0; }
    else
    { dObj.style.top=""+y+"px"; } 
    document.getElementById("vbox").scrollTop = (y*vmax)/386;
    return false; } }
function nmover(e)
{ if (e==null) {e=window.event;} 
  if (doDrag)
  { mouseCoords(e);
    var y=mPosy-yoff;
    var yy=y-170;;
    if (y>460) { y=460; }
    else if (y<170) { y=170; }
    else
    { dObj.style.top=""+y+"px"; } 
    document.getElementById("nbox").scrollTop = (yy*vmax)/290;
//    alert(document.getElementById("nbox").scrollTop);
    return false; } }



function mouseCoords(ev)
{ if (ev.pageX || ev.pageY) {mPosx=ev.pageX; mPosy=ev.pageY;}
  else
  { mPosx=ev.clientX + document.body.scrollLeft - document.body.clientLeft;
    mPosy=ev.clientY + document.body.scrollTop  - document.body.clientTop; } }
function cleanup(e)
{ document.onmousemove=null;
  document.onmouseup=null;
  dObj.style.cursor=ocurs;
  doDrag=false; }



function verifyBlog()
{ var f = document.blogf;
  var i = f.cod.value;
  if (carr[i] != f.blCode.value.toLowerCase() )
  { alert("Please enter security code exactly as shown."); return false; }
  if (f.blTit.value=="") { alert("Please enter headline."); return false; }
  f.submit();
  return false; }

function newCodex()
{ var f = document.blogf;
  var i = parseInt(f.cod.value) + 1;
  if (i>12) {i=1;}
  f.cod.value=i;
  if (i<10) {var n="0"+i;} else {var n=""+i;}
  document.getElementById("codex").src="lib/code"+n+".gif";
  return false; }

function emailValid(s)
{ var patt=/[^a-z0-9_-]/;
  s=s.toLowerCase();
  if (s.length<6 || s.length>128) {return false;}
  var x = s.split("@");
  if (x.length!=2) {return false;}
  if (x[0].length<1) {return false;}
  var a = x[0].split(".");
  for (var i=0; i<a.length; i++)
  { if (a[i].length<1) {return false;}
    if (patt.test(a[i])) {return false;} }
  if (x[1].length<4) {return false;}
  var a = x[1].split(".");
  var n = a.length-1;
  if (n==0) {return false;}
  for (var i=0; i<a.length; i++)
  { if (i==n && a[i].length<2) {return false;}
    if (a[i].length<1) {return false;}
    if (patt.test(a[i])) {return false;} }
 return true; }

function verifyEmail()
{ var em=document.emailer.email.value;
  if (emailValid(em))
  { document.emailer.submit(); }
  else
  { document.getElementById("mailerr").innerHTML = "Invalid email address!"; }
  return false; }

function showvid(v)
{ var newdiv = document.createElement("div");
  document.getElementById("obj").innerHTML = "";
  var txt = '<object width="425" height="344">\n';
  txt += '<param name="movie" value="http://www.youtube.com/v/'+v+'?hl=en&fs=1" />\n';
  txt += '<param name="allowFullScreen" value="true" />\n';
  txt += '<param name="allowscriptaccess" value="always" />\n';
  txt += '<embed src="http://www.youtube.com/v/'+v+'?hl=en&fs=1" type="application/x-shockwave-flash" ';
  txt += 'allowscriptaccess="always" allowfullscreen="true" width="425" height="344" />\n';
  txt += '</object>\n';
  newdiv.innerHTML = txt;
  var container = document.getElementById("obj");
  container.appendChild(newdiv);
  return false; }

