var hook = document.getElementById("hook");
var pos = -200;
var anint = null;

if (typeof window.innerWidth != 'undefined')
{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
}

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
	 'undefined' && document.documentElement.clientWidth != 0)
{
		 viewportwidth = document.documentElement.clientWidth;
		 viewportheight = document.documentElement.clientHeight;
}

// older versions of IE

else
{
		 viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		 viewportheight = document.getElementsByTagName('body')[0].clientHeight;
}

window.onresize = function()
{
	if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth;
       viewportheight = document.documentElement.clientHeight;
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
       viewportheight = document.getElementsByTagName('body')[0].clientHeight;
 }

hook = document.getElementById("hook");
hook.style.left = viewportwidth - 170 + "px";
}

function moveHook()
{
	if(pos < viewportwidth - 150)
	{
		hook.style.left = pos + 20 + "px";
		pos += 20;
	}
	else 
	{
		window.clearInterval(anint);
		hook.style.left = viewportwidth - 170 + "px";
	}
}
function moveHook2()
{
	if(pos < viewportwidth - 150)
	{
		hook.style.left = pos + 20 + "px";
		pos += 20;
	}
	else 
	{
		window.clearInterval(anint);
		hook.style.left = viewportwidth - 170 + "px";
		window.location = "contact-us.php";
	}
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
	if(contact) {initialize();}
  var cookie = readCookie("anim");
  if(cookie != "visited")
	{
		hook = document.getElementById("hook");
		hook.style.left = "-200px";
		pos = -200;
		anint = window.setInterval("moveHook();",20);
		var title = "visited";
		createCookie("anim", title);
	}
	else
	{
		hook = document.getElementById("hook");
		hook.style.left = viewportwidth - 170 + "px";
	}
}

function clickMove()
{	
	hook = document.getElementById("hook");
	hook.style.left = "-200px";
	pos = -200;
	anint = window.setInterval("moveHook2();",20);
}
