
/*-----------------------------------------------------------------------------------------------------------
  tour.js - method/browser check
------------------------------------------------------------------------------------------------------------*/
if(!document.getElementById)
{
  document.location.replace("nonw3c_browser.html");
}

/*-----------------------------------------------------------------------------------------------------------
  nav mouse events
------------------------------------------------------------------------------------------------------------*/
function pitovr(oTarget) //product image thumbs
{
  oTarget.style.backgroundColor='#ff9900';
  oTarget.style.cursor='hand';
}

function pitout(oTarget) //product image thumbs
{
  oTarget.style.backgroundColor='#ffffff';
}

function sstovr(oTarget) //screenhsot thumbs
{
  oTarget.style.backgroundColor='#848484';
  oTarget.style.cursor='hand';
}

function sstout(oTarget) //screenhsot thumbs
{
  oTarget.style.backgroundColor='#767676';
}

function rnOver(oTarget)//article logos
{
  oTarget.style.backgroundColor='#cccccc';
	oTarget.style.border='1px solid #666666'
}

function rnOut(oTarget)//article logos
{
  oTarget.style.backgroundColor='#8d8d8d';
	oTarget.style.border='1px solid #8d8d8d'
}

function tovr(oTarget)//testimonials
{
  oTarget.style.backgroundColor='#9a9a9a';
}

function tout(oTarget)//testimonials
{
  oTarget.style.backgroundColor='#898989';
}

function navOver(oName,oSrc)
{
	var x=document.getElementById(oName);
	if(x.id!=oName)
	{
		return;
	}
	x.src="img/"+oSrc+oName+"_s.gif";
}

function navOut(oName,oSrc)
{
	var x=document.getElementById(oName);
	if(nav==oName)
	{
		return;
	}
	x.src="img/"+oSrc+oName+".gif";
}

/*-----------------------------------------------------------------------------------------------------------
  utility functions
------------------------------------------------------------------------------------------------------------*/

function imgCache()
{
	ticN=new Image;
	ticN.src="img/nav_tic.gif";
	ticS=new Image;
	ticS.src="img/nav_tic_s.gif";
	piN=new Image;
	piN.src="img/nav_pi.gif";
	piS=new Image;
	piS.src="img/nav_pi_s.gif";
	ssN=new Image;
	ssN.src="img/nav_ss.gif";
	ssS=new Image;
	ssS.src="img/nav_ss_s.gif";
	tN=new Image;
	tN.src="img/nav_t.gif";
	tS=new Image;
	tS.src="img/nav_t_s.gif";
	rnN=new Image;
	rnN.src="img/nav_rn.gif";
	rnS=new Image;
	rnS.src="img/nav_rn_s.gif";
	buyN=new Image;
	buyN.src="img/buybar_buy.gif";
	buyS=new Image;
	buyS.src="img/buybar_buy_s.gif";
	ls300N=new Image;
	ls300N.src="img/buybar_ls300.gif";
	ls300S=new Image;
	ls300S.src="img/buybar_ls300_s.gif";
	ls100N=new Image;
	ls100N.src="img/buybar_ls100.gif";
	ls100S=new Image;
	ls100S.src="img/buybar_ls100_s.gif";
	personalizeN=new Image;
	personalizeN.src="img/buybar_personalize.gif";
	personalizeS=new Image;
	personalizeS.src="img/buybar_personalize_s.gif";
  contactN=new Image;
	contactN.src="img/buybar_contact.gif";
	contactS=new Image;
	contactS.src="img/buybar_contact_s.gif";
  pipN=new Image;
	pipN.src="img/pi_button_previous.gif";
	pipS=new Image;
	pipS.src="img/pi_button_previous_roll.gif";
	pinN=new Image;
	pinN.src="img/pi_button_next.gif";
	pinS=new Image;
	pinS.src="img/pi_button_next_roll.gif";
  sspN=new Image;
	sspN.src="img/ss_button_previous.gif";
	sspS=new Image;
	sspS.src="img/ss_button_previous_roll.gif";
	ssnN=new Image;
	ssnN.src="img/ss_button_next.gif";
	ssnS=new Image;
	ssnS.src="img/ss_button_next_roll.gif";
}

function showContent(oTarget)
{
	if(oTarget==content)
	{
		return;
	}
	var w=document.getElementById(content);
	var x=document.getElementById(oTarget);
  w.style.display='none';
	x.style.display='block';
	content=oTarget;
	hiliteNav(oTarget);
}

function hiliteNav(oNav)
{
  var oldNav=document.getElementById(nav);
  oldNav.src="img/nav_"+nav+".gif";
	var y=oNav.split("Content");
	var z=y[0];
	var x=document.getElementById(z);
	x.src="img/nav_"+z+"_s.gif";
	nav=z;
}

function swapPic(oImage,oDescription)
{
	var title=document.getElementById("picTitle");
  var image=document.getElementById("pic");
  title.src="img/pi_title_"+oImage+".gif";
  image.src="img/pi_"+oImage+".jpg";
  var description=document.getElementById(oDescription);
  var prevDescription=document.getElementById(blurb);
  prevDescription.style.display='none';
  description.style.display='block';
  blurb=oDescription;
  hiliteThumb(oDescription);
}

function hiliteThumb(oTarget)
{
  var x=oTarget.split("d");
  var y=x[1];
  var z="t"+y;
  var a=document.getElementById(z);
  var prevThumb=document.getElementById(thumb);
  prevThumb.style.borderColor='#ffffff';
  a.style.borderColor='#ff9900';
  thumb=z;
}

function swapPi(oNext)
{
	var u=thumb.split("t");
	var v=u[1];
	var w=parseInt(v)-1;
	var x="d"+w;
	var y=parseInt(v)+1;
	var z="d"+y;
	if(oNext)
	{
		if(y==piMax+1)//check for end of collection
		{
			swapPic("1","d1");//loop back to 1
		}
		else
		{
			swapPic(y,z);//go forward one
		}
	}
	else
	{
		if(w==0)//check for start of collection
		{
			var maxD="d"+piMax;
			swapPic(piMax,maxD);//go to end of collection
		}
		else
		{
			swapPic(w,x);//go back one
		}
	}
}

function swapShot(oImage,oDescription)
{
  var image=document.getElementById("shot");
  image.src="img/ss_"+oImage+".gif";
  var description=document.getElementById(oDescription);
  var prevDescription=document.getElementById(sblurb);
  prevDescription.style.display='none';
  description.style.display='block';
  sblurb=oDescription;
  hiliteShotThumb(oDescription);
}

function hiliteShotThumb(oTarget)
{
  var x=oTarget.split("sd");
  var y=x[1];
  var z="st"+y;
  var a=document.getElementById(z);
  var prevThumb=document.getElementById(sthumb);
  prevThumb.style.borderColor='#656565';
  a.style.borderColor='#ffffff';
  sthumb=z;
}

function swapSs(oNext)
{
	var u=sthumb.split("st");
	var v=u[1];
	var w=parseInt(v)-1;
	var x="sd"+w;
	var y=parseInt(v)+1;
	var z="sd"+y;
	if(oNext)
	{
		if(y==ssMax+1)//check for end of collection
		{
			swapShot("1","sd1");//loop back to 1
		}
		else
		{
			swapShot(y,z);//go forward one
		}
	}
	else
	{
		if(w==0)//check for start of collection
		{
			var maxD="sd"+ssMax;
			swapShot(ssMax,maxD);//go to end of collection
		}
		else
		{
			swapShot(w,x);//go back one
		}
	}
}

function swapArticle(oTitle,oArticle)
{
	var arrowImg="arrow"+oTitle;
	var oArrow=document.getElementById(arrowImg);
	var oldArrow=document.getElementById(arrow);
	oldArrow.src="img/shim.gif";
	oArrow.src="img/arrow_left.gif";
	var title=document.getElementById("rnTitle");
  title.src="img/rn_title_"+oTitle+".gif";
  var newArticle=document.getElementById(oArticle);
  var prevArticle=document.getElementById(article);
  prevArticle.style.display='none';
  newArticle.style.display='block';
  article=oArticle;
	arrow=arrowImg;
}

function swapTestimonial(oTitle,oImage)
{
  var tarrowImg="tarrow"+oTitle;
	var otArrow=document.getElementById(tarrowImg);
	var oldtArrow=document.getElementById(tarrow);
	oldtArrow.src="img/shim.gif";
	otArrow.src="img/arrow_left.gif";
  var image=document.getElementById("tpic");
  image.src="img/t_"+oImage;
  tarrow=tarrowImg;
}

function swapSubImage(oPath)
{
  var x=document.getElementById("shot");
  x.src=oPath;
}

function goParent(url)
{
  if(window.opener && !window.opener.closed)
  {
    window.opener.location=url;
    window.opener.focus();
  }
  else
  {
    newWindow(url,'name');
  }
}

function newWindow(oPage,oName)
{
  var win=null;
  var name="main";
  win=window.open(oPage,name);
  win.focus();
}

function val()
{
  if(checkReq(document.contactForm.first_name) && checkReq(document.contactForm.last_name) && checkReq(document.contactForm.email) && checkReq(document.contactForm.lead_source) && checkReq(document.contactForm.industry))
  {
    return true;
  }
  else
  {
    return false;
  }
}

function checkReq(oForm)
{
  if(oForm.name=="email")
  {
    if(failEmailCheck(oForm))
    {
      error(oForm);
    }
	else
	{
		return true;
	}
  }
  else if(oForm.value=="chooseone")
  {
  	error(oForm);
  }
  else if((oForm.value.length==0) || (oForm.value==null))
  {
    error(oForm);
  }
  else
  {
    return true;
  }
}

function failEmailCheck(oForm)
{
	if((oForm.value.length==0) || (oForm.value==null) || (oForm.value.indexOf('@')< 0) || (oForm.value.indexOf('.')< 0))
	{
		return true;
	}
}

function error(oField)
{
  switch(oField)
  {
    case document.contactForm.first_name: alert("Please enter your first name."); oField.focus();
    break;
		case document.contactForm.last_name: alert("Please enter your last name."); oField.focus();
    break;
    case document.contactForm.email: alert("Please enter a valid email address."); oField.focus();
    break;
		case document.contactForm.lead_source: alert("Please choose a Lead Source."); oField.focus();
    break;
		case document.contactForm.industry: alert("Please choose a Type."); oField.focus();
    break;
    default: alert("Your contact form is invalid. Please fix any errors and resubmit your message.");
  }
}