//var websiteRoot = "http://localhost:8888/dit/ac/trunk/website";
var websiteRoot = "http://www.artistcraft.com";

function togglecategories(id) 
{
  var submenu = document.getElementById("section"+id);
  if (submenu.style.display == "none") {
     submenu.style.display = "";
  } else {
     submenu.style.display = "none";
  }
}

function popup(url,name,width,height)
{
  window.open(url, name,"toolbar=no,menubar=no,personalbar=no,width="+width+",height="+height+",scrollbars=no,resizable=yes,modal=yes,dependable=yes");
}

function popupsend()
{
    var docurl = document.location.href;
    var sendto = websiteRoot + "/email_page/index.php?docurl="+docurl;
    var mywin = window.open(sendto,'sendtofriend','width=480,height=514,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    mywin.focus();
    window.name = "main";
}

function showquoteform()
{
  var theform = document.getElementById("quoteform");
  theform.style.display = "block";
  setTimeout("window.scrollBy(200,200);",10);
}

function istoronto(item)
{
  var cell = document.getElementById("hideinstall");
  if (item.options[item.selectedIndex].value == "Toronto GTA") {
    cell.style.display = "";
  } else {
    cell.style.display = "none";
  }
}

function checkform(form)
{
  if (docheckform != 1) {
    return true;
  }

  errorstr = "";
  if (form.fname.value.length < 1) {
    errorstr += "You must fill in your first name.\n";
  }
  if (form.lname.value.length < 1) {
    errorstr += "You must fill in your last name.\n";
  }
  if (form.email.value.length < 1) {
    errorstr += "You must fill in your email address.\n";
  }
  if (form.zippostal.value.length < 1) {
    errorstr += "You must fill in your postal code.\n";
  }
  if (form.ap1.value.length != 3 || form.ap2.value.length != 3 || form.ap3.value.length != 4) {
    errorstr += "You must fill in your phone number.\n";
  }
  
  if (form.comments.value.length < 1) {
    errorstr += "You must fill in your requirements.\n";
  }
  if (errorstr.length > 1) {
    alert(errorstr);
    return false;
  }
  return true;
}

//try to block image saving
/*
msg = " \u00A9 Copyright 2005 Artistcraft";

bVer  = parseInt(navigator.appVersion)
NS = navigator.appName=="Netscape"
IE = navigator.appName=="Microsoft Internet Explorer"

function processClick(e) {
       if (NS && e.which > 1){
          alert(msg)
          return false;
       } else if (IE && (event.button >1)) {
         alert(msg)
         return false;
       }
}

document.onmousedown = processClick;
if (document.layers) window.captureEvents(Event.MouseDown);
if (NS && bVer<5) window.onmousedown = processClick;

var ref = document.referrer.toUpperCase();
if (ref) {
  if (ref.indexOf('HTTP://WWW.ARTISTCRAFT.COM') != 0 &&
      ref.indexOf('HTTP://ARTISTCRAFT.COM') != 0 ) {
    document.cookie = "refcookie="+escape(document.referrer) + "; path=/;";
  }
}
*/

var is_hover = 0;

function slideSwitch() {
	
	if(!is_hover)
	{
	    var $active = $('#frame img.active');
	
	    if ( $active.length == 0 ) $active = $('#frame img:last');
	
	    var $next =  $active.next().length ? $active.next()
	        : $('#frame img:first');
	
	    $active.addClass('last-active');
	    
	    if($next.attr("id") == 10)
	    {
    		$('#frame').attr('href', websiteRoot + '/steam_showers/Steam_Doors_In_Line_Enclosures/281');
	    }
	    else if($next.attr("id") == 15)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/neoangled_shower_enclosures/17');
	    }
	    else if($next.attr("id") == 20)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/neoangled_shower_enclosures/16');
	    }
	    else if($next.attr("id") == 25)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/inline_shower_enclosures/10/3668');
	    }
	    else if($next.attr("id") == 30)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/inline_shower_enclosures/10/3676');
	    }
	    else if($next.attr("id") == 35)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/inline_shower_enclosures/10/3678');
	    }
	    else if($next.attr("id") == 50)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/right_angled_shower_enclosures/14');
	    }
	    else if($next.attr("id") == 60)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/right_angled_shower_enclosures/14');
	    }
	    else if($next.attr("id") == 70)
	    {
    		$('#frame').attr('href', websiteRoot + '/shower_doors_shower_enclosures/shaped_shower_enclosures/20');
	    }
	    else if($next.attr("id") == 101)
	    {
    		$('#frame').attr('href', websiteRoot + '/tub_doors/bathtub_screens/33/3795');
	    }
	    else if($next.attr("id") == 105)
	    {
    		$('#frame').attr('href', websiteRoot + '/tub_doors/bathtub_screens/33');
	    }
	    else if($next.attr("id") == 110)
	    {
    		$('#frame').attr('href', websiteRoot + '/tub_doors/bathtub_screens/33/4305');
	    }
	    else if($next.attr("id") == 125)
	    {
    		$('#frame').attr('href', websiteRoot + '/tub_doors/bathtub_screens/285');
	    }
	    else
	    {
    		$('#frame').attr('href', websiteRoot + '/sandblasted/low_maintenance');
	    }
	    
	    $("#m" + $active.attr("id")).addClass('dn');
	    $("#m" + $next.attr("id")).removeClass('dn');

	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            $active.removeClass('active last-active');
        });
	}
}

$(document).ready(function() {
	$("#frame").hover(
	  function () {
		  is_hover = 1;
	  },
	  function () {
		  is_hover = 0;
	  }
	);
    setInterval("slideSwitch()", 5000);
});

