// JavaScript Document
function viewcat(){
	$('slider').setStyle('left','-661px');
}
function closecat(){
	$('slider').setStyle('left','0px');
}

window.addEvent('domready', function(){	
		var status = {
			'true': 'open',
			'false': 'close'
		};
		var from  = 0; 
		
		//load home.html
		var myContent = new Element('div', {id: 'container'});
		myContent.inject($('content'),'top');
		
		new Request.HTML({url:'pages/home.html', 
			onSuccess: function(html) {				
				$('container').adopt(html);
				//$('container').removeClass('ajax-loading');
				new ScrollControl($('container'), {'htmlElementPrefix': 'control_', 'createControls': true, 'scrollStepSize':15});
			}
		}).send();
		
		var myMenu = new Fx.Slide('navholder', {mode: 'horizontal'});
		myMenu.slideOut(); //hide menu first
		
		//var scroller = new Fx.Tween('scroller',{transition: Fx.Transitions.Circ.easeOut, duration: 1000 });

		$('navi').addEvent('mouseover', function(e){
			e.stop();
			myMenu.slideIn();
		});
		
		$$('a.menui').each(function(el) {
				el.addEvent('click', function(e) {
					
					var x = el.getProperty('tabindex');
					var p = el.getProperty('id');
					myMenu.toggle(); //if moused clicked - show or hide menu
					if(x < 10){
						$('container').dispose();
						$('control_contentmask').dispose();
						$('control_scrollcontainer').dispose();
						var to = 960 - (961 * x);
						new Fx.Tween('scroller',{
								transition: Fx.Transitions.Circ.easeOut, 
								duration: 1600,
								onComplete: function(){
									//create new content
									var myContent = new Element('div', {id: 'container'});
									myContent.inject($('content'),'top');
									new Request.HTML({url:'pages/loader.php?load='+p, 
										onSuccess: function(html) {				
											$('container').adopt(html);										
											new ScrollControl($('container'), {'htmlElementPrefix': 'control_', 'createControls': true, 'scrollStepSize':15});
											if($('contactForm')){
												$('inquiryForm').addEvent('submit', function(e) {
													e.stop();
													var log = $('log_res').empty().addClass('ajax-loading');
													this.set('send', {onComplete: function(response) { 
														log.removeClass('ajax-loading');
														log.set('html', '<strong>Your Inquiry has been receive. We will get back to you as soon as we can.<br /><br />Thank you.</strong>');
														$('inquiryForm').setStyle('display','none');
														$$('#contactForm legend').set('text','Thank you for your inquiry');
													}});
													this.send();
												});
											}
											if($('catslide')){ //if gowns
												$$('#catalog span').setStyle('cursor','pointer');
												var dir = $('catslide').getProperty('class');
												var catitem = $$('#catalog span img');
												var cnt  =0;
												catitem.each(function(it){
													var namer = it.getProperty('id');
													var linker = new Element('a', {href: 'pages/details.php?d='+dir+'&i='+namer, border:0, rel:'pics'});
													linker.wraps(it);
													SqueezeBox.assign($$('a[rel=pics]'), {
														size: {x: 700, y: 500},
														handler: 'iframe',
														ajaxOptions: {
															method: 'get' // we use GET for requesting plain HTML
														}
													});
													cnt += 1;
												});
												$('catalog').setStyle('width',cnt*135);
												//setup carousel
												var myScroller = new Scroller('catslide');
												myScroller.start();
											}
											
											if($('catslide2')){ //if access or shoes
												$$('#catalog span').setStyle('cursor','pointer');
												var dir = $('catslide2').getProperty('class');
												var catitem = $$('#catalog span img');
												var cnt  =0;
												catitem.each(function(it){
													var namer = it.getProperty('id');
													SqueezeBox.assign($$('a[rel=pics]'));
	
													cnt += 1;
												});
												$('catalog').setStyle('width',cnt*135);
												//setup carousel
												var myScroller = new Scroller('catslide2');
												myScroller.start();
											}
											
											if($('testislide')){ //if gowns
												$$('#catalog span').setStyle('cursor','pointer');
												var dir = $('testislide').getProperty('class');
												var catitem = $$('#catalog span img');
												var cnt  =0;
												catitem.each(function(it){
													var namer = it.getProperty('id');
													var linker = new Element('a', {href: 'testi/'+namer+'.html', border:0, rel:'boxed'});
													linker.wraps(it);
													SqueezeBox.assign($$('a[rel=boxed]'), {
														size: {x: 720, y: 500},
														ajaxOptions: {
															method: 'get' // we use GET for requesting plain HTML
														}
													});
													cnt += 1;
												});
												$('catalog').setStyle('width',cnt*135);
												//setup carousel
												var myScroller = new Scroller('testislide');
												myScroller.start();
											}
											
											if($('contact')){
												SqueezeBox.assign($$('a[rel=map]'));
											}
	
										},		
										onFailure: function() {				
											$('container').set('text', 'The request failed.');				
										}				
									}).send();
								}
						}).start('left',from, to);
						from = to;
						on = 0;
					}
				});
			});			
});

function MM_jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}