// 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;
	

	}//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




}/// 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');");
}

