    function MM_swapImgRestore() 
{ 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() 
{ 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function mouseover()
{
    var src =  $(this).children("img").attr("src");
      
    if (src.indexOf("services-head_03.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/Services-Roll-Home_03.gif");
	}
	
	if (src.indexOf("work-head_06.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/Work-Roll-Home_06.gif");	
	}
	
	if (src.indexOf("about-head_08.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/About-Roll-Home_08.gif");	
	}
	
	if (src.indexOf("social-head_10.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/Social-Roll-Home_10.gif");
	}
	
	if (src.indexOf("newsfeed-head_12.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/Newsfeed-Roll-Home_12.gif");
	}
}
	
function mouseout()
{
    
   if($(this).parent().children(".detail").hasClass("toggled")) return;
   
    var src =  $(this).children("img").attr("src");
    
    if (src.indexOf("Services-Roll-Home_03.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/services-head_03.gif");	
	}
	if (src.indexOf("Work-Roll-Home_06.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/work-head_06.gif");	
	}
	if (src.indexOf("About-Roll-Home_08.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/about-head_08.gif");
	}
	if (src.indexOf("Social-Roll-Home_10.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/social-head_10.gif");
	}
	if (src.indexOf("Newsfeed-Roll-Home_12.gif") != -1)
    {
	    $(this).children("img").attr("src","assets/images/newsfeed-head_12.gif");
	}
	
}

function makeInactive(parent)
{
        
    var src =  $(parent).children("img").attr("src");
    
    if (src.indexOf("Services-Roll-Home_03.gif") != -1)
    {
	    $(parent).children("img").attr("src","assets/images/services-head_03.gif");	
	}
	
	if (src.indexOf("Work-Roll-Home_06.gif") != -1)
    {
	    $(parent).children("img").attr("src","assets/images/work-head_06.gif");	
	}
	
	if (src.indexOf("About-Roll-Home_08.gif") != -1)
    {
	    $(parent).children("img").attr("src","assets/images/about-head_08.gif");
	}
	
	if (src.indexOf("Social-Roll-Home_10.gif") != -1)
    {
	    $(parent).children("img").attr("src","assets/images/social-head_10.gif");
	}
	
	if (src.indexOf("Newsfeed-Roll-Home_12.gif") != -1)
    {
	    $(parent).children("img").attr("src","assets/images/newsfeed-head_12.gif");
	}
	
}	


function getImageSet(index)
{
    switch(index)
   {
        case 1:
             html ='<ul>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/AlcanThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/AppletonThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/AurizonThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/BemisThumb.jpg" alt="" /></a></li>';
             html+='</ul>';
        break;
        case 2:
             html ='<ul>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/BerresThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/BreyersThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/ElmersThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/JvcThumb.jpg" alt="" /></a></li>';
             html+='</ul>';
        break;
        case 3:
             html ='<ul>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/KayteeThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/NorthernLabsThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/NylaboneThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/ScaThumb.jpg" alt="" /></a></li>';
             html+='</ul>';
        break;
        case 4:
             html ='<ul>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/FassonThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/ValleyBakersThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/WsThumb.jpg" alt="" /></a></li>';
             html+='<li><a href="./portfolio.aspx"><img src="assets/images/thumbs/KcThumb.jpg" alt="" /></a></li>';
            html+='</ul>';
        break;
    
   } 
   
   
   return html;
}


function validateForm()
{

    if($.trim($("input[name='name']").val()) == "")
    {
        alert("name is required");
        $("input[name='name']").focus();
        return false;
    }
   
    if($.trim($("input[name='email']").val()) == "")
    {
        alert("e-mail is required");
        $("input[name='email']").focus();
        return false;
    }
     
    if(!isEmail($("input[name='email']").val()))
    {
        alert("invalid email address");
        $("input[name='email']").focus();
        return false;
    }
    
    
    data ='name='+ $("input[name='name']").val() + '&email=' + $("input[name='email']").val() + '&company=' + $("input[name='company']").val() ;
    data += '&title=' + $("input[name='title']").val() + '&phone=' + $("input[name='phone']").val() + '&message='+ $("textarea[name='message']").val();
  
    $.ajax({
	  type: 'GET',
	  url: "./connect.aspx",
	  data: data,
	  dataType : "json",
	  success: function(response)
	  {
	       
	        //alert(response.status);
			if(response.status == "1")
			{
			   // window.location.href = 'thankyou.aspx'
			    wrap = $("a[rel]").overlay().getContent().find(".wrap");	
				html = '<p style="margin:8px 0 0 0;padding 0 0 0 0;width:100%;" align="left">';
				html += 'Thanks for your interest in Directions. Our team looks forward to talking with you soon.';
				//html += " You will receive an email shortly with the download link you requested.</p>";
				//html += '<div style="clear:both;float:left;padding-top:50px;"><a href="http://www.averydennison.com"><img src="/img/site/logos/ad_sm.gif"  alt="Avery Dennison"  style=" text-align:right; vertical-align:top"></a></div><br>';
				wrap = $("a[rel]").overlay().getContent().find(".wrap");	
				wrap.html("<div style='padding-top:110px;height:270px;color:#787878;font-size:12px;font-weight:bold;'>" + html + "</div>");
			}
			else
			{
				alert(response.message);
			}
	  }
	  
	});
	
	
}


function isEmail(inputvalue)
{	
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(inputvalue))
	{
		return true;
	}
	else
	{
		return false;
	}
}


$(function()
      {
          $("a[rel]").overlay(
                    {
                        effect: 'apple' ,
                        fadeInSpeed:'slow',
                        top:'20%',
                        expose: { 
						        color: '#fff', 
						        opacity: 0.7 
						        },
						closeOnClick : false,
						onStart :function() {
						                        var pageTracker = _gat._getTracker("UA-2967908-1");
                                                pageTracker._trackPageview("/connect.aspx");
						                        
						                        $(".overlay_apple :input").not("input[name='submit']").val(''); 
						                        $("input[name='name']").focus();
						                    }
					}
                    
                    );
      });