// JavaScript Document
 function swapImages(){
      var $active = jq('#myGallery .active');
      var $next = (jq('#myGallery .active').next().length > 0) ? jq('#myGallery .active').next() : jq('#myGallery img:first');
      $active.fadeOut(1500,function(){
      $active.removeClass('active');
      $next.fadeIn(1500).addClass('active');
      });
    }
 

function pageInit(pageName,subName){
	
	switch (pageName){
	case "home":
	/*highlight=document.getElementById('home');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";*/
	break;
	
	case "products":
	highlight=document.getElementById('products');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";
	break;
	
	case "installations":
	highlight=document.getElementById('installations');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";
	break;
	
	case "finishes":
	highlight=document.getElementById('finishes');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";
	break;
	
	case "resources":
	highlight=document.getElementById('resources');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";
	break;
	
	case "contact":
	highlight=document.getElementById('contact');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";
	break;
	
	case "about":
	highlight=document.getElementById('about');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";
	break;
	
	case "revit":
	jq('#m60').change(function(){
	if (jq('#m60').attr('checked')){
	jq('#m60selection').prop('disabled',false);
	} else {
	jq('#m60selection').prop('disabled',true);	
	}
	});
	break;

	}//end switch
	
	if (subName=="dealer"){
	highlight=document.getElementById('home');
	highlight.style.color='#ffffff';
	highlight.style.backgroundPosition="left bottom";	
	}
	
	if(subName){
	//jq('#'+subName).css({'margin-bottom': '15px','border-bottom-width': '1px','border-bottom-style':'dotted','border-bottom-color':'#999999'});
	jq('#'+subName).css({'color': '#847a18'});
	}
	
	
	///HOME PAGE lightbox
	
	//if (pageName=="home" ){
		jq('#theVideo').click(function (e) {
		//var URL= String(window.location);
	//var query=URL.split("?");
	 
	
	  
  var id = '#dialog';
	
		//Get the screen height and width
		var maskHeight = jq(document).height();
		var maskWidth = jq(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		jq('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		jq('#mask').fadeIn(500);	
		jq('#mask').fadeTo("fast",0.7);	
	
		//Get the window height and width
		var winH = jq(window).height();
		var winW = jq(window).width();
              
		//Set the popup window to center
		jq(id).css('top',  winH/2-jq(id).height()/2);
		jq(id).css('left', winW/2-jq(id).width()/2);
	
		//transition effect
		jq(id).fadeIn(2000); 

	
	//if close button is clicked
	jq('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		stopper();
		jq('#mask').hide();
		jq('.window').hide();
		//$('#player').
	});		
	
	//if mask is clicked
	jq('#mask').click(function () {
		jq(this).hide();
		jq('.window').hide();
		stopper();
	});			
		
	})// end if pageName==home
		
		
		if (pageName=="home"){
			
			setInterval('swapImages()', 5000);
			
		}
		
	
	/*if (pageName=="contact"){
		
	jq("#contactForm").submit(function(){ 
									 
								theInfo=jq("#contactForm").serialize();
								
								jq.post("mailer.php", theInfo, function(data){ jq("#contactForm").html(data);});  
  																	 });  	
	}*/
	

jq(".swatch").click(function(){
							 // adjust for the underscore in the swatch title.
							 
			var theSwatch=jq(this).attr("name").split("|");				 
							 
			var propName=theSwatch[1].replace("_"," ");			
		
			jq("#swatchName").text(propName);
			
			
			
			jq("#mainSwatch").attr("src","../images/finishes/fabrics_new/"+theSwatch[0]+"/lg/"+theSwatch[1]+".jpg");
			jq("#mainSwatch").attr("alt",propName);
			jq("#mainSwatch").attr("title",propName);
			// set the alt and title of the swatch
			
			
			
							 });// end swatch click



/////////////////////////////////////------------------------------- designer area

/**//// 
if (subName=="designers"){
	
jq("#showLucci").click(function(){ 
								jq(".bio").css("display","none");
								jq("#lucci").css("display","block");
								jq(".headshot").removeClass("designActive");	
								jq(this).parent().addClass("designActive");							  
												  });
jq("#showMorrow").click(function(){ 
								jq(".bio").css("display","none");
								jq("#morrow").css("display","block");
								jq(".headshot").removeClass("designActive");
								jq(this).parent().addClass("designActive");								  
												  });
jq("#showBaldanzi").click(function(){ 
								jq(".bio").css("display","none");
								jq("#baldanzi").css("display","block");
								jq(".headshot").removeClass("designActive");
								jq(this).parent().addClass("designActive");								  
												  });
jq("#showDante").click(function(){ 
								jq(".bio").css("display","none");
								jq("#dante").css("display","block");
								jq(".headshot").removeClass("designActive");
								jq(this).parent().addClass("designActive");								  
												  });



}



}/// end page Init function


function stopper(){
	getFlashMovie("player").stopMovie();

}

function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
 // var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
  return (isIE) ? window[movieName] : document[movieName];
  
 alert(navigator.appVersion.indexOf("MSIE"));
}/**/




function showPic(whichpic) {

document.getElementById('placeholder').src = whichpic;	


}


function popImg(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=270,left=50,top=50');");
}



function pressPop(URL){
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=530,height=600,left=50,top=50');");
}

function cleanCodePop(URL){
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=450,left=100,top=100');");
}

function formChecker (FormName){
	
var x       = 0
var FormOk  = true

// common elements between the contact and the Revit Form
   if (document.getElementById('formName').value == ''){
        alert('Please enter your name and try again.');
        document.getElementById('formName').focus();
        FormOk = false ;
		return;
     }
	 
	  if (document.getElementById('formEmail').value == ''){
        alert('Please enter an email address and try again.');
        document.getElementById('formEmail').focus();
        FormOk = false ;
		return;
     }
	 
	 
	  if (document.getElementById('formCompany').value == ''){
        alert('Please enter a company name and try again.');
        document.getElementById('formCompany').focus();
        FormOk = false ;
		return;
     }
	 // Revit specific form check
if (FormName=='revitForm'){
	
	 if (document.getElementById('formPhone').value == ''){
        alert('Please enter a phone number and try again.');
        document.getElementById('formPhone').focus();
        FormOk = false ;
		return;
     }
	 
	if (document.getElementById('formCity').value == ''){
        alert('Please enter a city and try again.');
        document.getElementById('formCity').focus();
        FormOk = false ;
		return;
     }
	 
	 if (document.getElementById('formState').value == ''){
        alert('Please enter a state and try again.');
        document.getElementById('formState').focus();
        FormOk = false ;
		return;
     }



	var checkers=new Array ('m60','m60quad','m50','ft10','runner','q3000','st40','stsf','lectureModulamm','turner','blade','c100','e4000','c600','mercury','turandot','other');
	var count=0;
	for (i=0;i<checkers.length;i++){
		if (document.getElementById(checkers[i]).checked){
		count++;
		}// end if checked statement
	}// end for loop
	
	if (count==0){	
	alert('You must check a product name. If checking Other please detail your request in the comments box.');
	FormOk = false;
	return;
	}
	
	if (document.getElementById('other').checked) {
		
		if (document.getElementById('formComments').value==""){
		alert('You chose Other, please detail your request in the comments box.');
		document.getElementById('formComments').focus();
	FormOk = false;	
	return;
		}	
	}//end if other is checked
}//end Revit Specific Form check


if(FormOk){
document.forms[FormName].submit();	

}
}



