// mzk: modified fns.js to allow selection of a certain stripe.

var oBg_resize = {
	init: function() {
		this.eBg = $('#background')[0];
		this.eLayout = $('#layout')[0];

		if(RegExp('MSIE 6.0').test(navigator.userAgent)) {
			this.bIE6 = true;
//			this.stretch();
			this.width_fix();
			this.height_fix();

			window.onresize = function() {
				oBg_resize.stretch();
			}
		}

	},

	stretch: function() {
		this.eBg.style.width = document.body.clientWidth > 1300 ? '100%' : '1300px';
		this.width_fix();
		this.height_fix();
	},

	 	width_fix: function() {
	 		this.eLayout.style.width = document.body.clientWidth > 1000 ? '100%' : '1000px';
	 	},

	 	height_fix: function() {
	 		this.eLayout.style.height = document.body.clientHeight > 1000 ? '100%' : '1000px';
	 	}
};





var oSwitch_page = {
	init: function() {
		var clone;
		this.content = $('#content');
		var aePages = $.makeArray($('#content .stripe div'));
//		this.Images = $.makeArray($('#bottom_stuff div'));
		this.eStripe = $('#content .stripe')[9];

		if(RegExp('MSIE 6.0').test(navigator.userAgent)) {
			this.bIE6 = true;
		}

		this.get_direction();
	},

	get_direction: function() {
		var me = this;
		this.direction;
		this.boo = true;
			$('#content .page_switcher .pseudo_link').click(function() {
				var parent = $(this).parent();
				var deda = parent.parent();
				var pageId = deda.attr('class').split(' ')[0];
				var page = $('#' + pageId);
				var targetClass = $(this).attr('class').split(' ')[1];
				var targetLink = deda.siblings("div[class*="+targetClass+"]").find('div');
				var newPageId = $(this).attr('class').split(' ')[1];
				var newPage = $('#' + newPageId);
				if(me.boo){
					if(parent.is('.left')) {
						me.direction = 'prev';
					}
					else if(parent.is('.right')) {
						me.direction = 'next';
					}
					me.switch_pages(page, deda, targetLink, newPage, me);
				}


			});
	},

	switch_pages: function(page, deda, targetLink, newPage,me) {
		var oThis = this;
		this.eCurrent_content = page;
		this.eDeda = deda.find('div');
		this.eTargetLink = targetLink;
		this.newPage = newPage;

		// switch (this.direction) {
		// 	case 'next':
		// 		this.new_page = page.next('.page');
		// 		break
		// 	case 'prev':
		// 		this.new_page = page.prev('.page');
		// 		break
		// 	default:
		// 		return false;
		// }

		$('#bottom_stuff div').each(function() {
			if (!$(this).hasClass(oThis.newPage[0].id)) {
				$(this).fadeOut('slow');
			}
			else {
				$(this).fadeIn('slow');
			}
		});

		this.fader(me);
	},

	fader: function(me){
		var that = this;
		this.me = me;
		this.iStep = 0;
		this.iSteps = 20;
		this.iHalf_step = this.iSteps / 2;
		this.animation(me);
	},

	animation: function(me){
		this.iStep++;
		this.boo = false;
		if(this.iStep <= this.iSteps){
			if(this.iStep < this.iHalf_step){
				var iOpacity = (this.iHalf_step - this.iStep) / this.iHalf_step;
				this.eCurrent_content[0].style.opacity = iOpacity;
				this.eDeda.css('opacity', iOpacity - 0.1);
				var ix = 'alpha(opacity=' + (iOpacity - 0.1) * 99 + ')';
				this.eCurrent_content[0].style.filter = ix;
				this.eDeda.css('filter', ix);
			}
			if(this.iStep == this.iHalf_step){
				this.newPage[0].style.opacity = 0;
				this.eTargetLink.css('opacity', 0);
				this.newPage[0].style.filter = 'alpha(opacity=0)';
				this.eTargetLink.css('filter', 'alpha(opacity=0)');
				this.newPage[0].style.visibility = 'visible';
				this.eTargetLink.css('display', 'block');
				if(!this.eStripe.style.left) {
					this.eStripe.style.left = 0;
				}
				var start_left = parseInt(this.eStripe.style.left);

				switch (this.direction) {
					case 'next':
						this.eStripe.style.left = start_left - 100 + '%';
						break
					case 'prev':
						this.eStripe.style.left = start_left + 100 + '%';
						break
					default:
						return true;
				}
			}
			if(this.iStep >= this.iHalf_step){
				var iOpacity = (this.iStep - this.iHalf_step) / this.iHalf_step;
				this.newPage[0].style.opacity = iOpacity-0.01;
				this.eTargetLink.css('opacity', iOpacity);
				var iy = 'alpha(opacity=' + iOpacity * 100 + ')';
				this.newPage[0].style.filter = iy;
				this.eTargetLink.css('filter', iy);
			}
			var oThis = this;
			setTimeout(function(){oThis.animation();}, 0);
		}
		else {
			this.eDeda.css('display','none');
		}
		if(this.iStep == this.iSteps + 1){
			this.boo = true;
			this.newPage[0].style.filter = '';
			this.eTargetLink.css('filter', '');
		}
	}
};




var oWashing = {
    
	init: function() {
		this.shoes_clothes_bikinis();
	},


	shoes_clothes_bikinis: function() {
		var oThis = this;
		var eStripe = $('#content div.content div.container div.stripe')[0];

		var clothes = $('#clothes');
		var shoes = $('#shoes');
        var bikinis = $('#bikinis');
		var clothes_link = $('#content div.content h2.clothes_link span');
		var shoes_link =   $('#content div.content h2.shoes_link span');
		var bikinis_link = $('#content div.content h2.bikinis_link span');

		$('#content div.content h2 span').hover(
			function(){
				if($(this).is('.pseudo_link')){
					$(this).addClass('hover');
				}
			},
			function(){
				$(this).removeClass('hover');
			}
		);

		clothes_link.click( function() {
			$(this).removeClass('pseudo_link hover');
			shoes_link.addClass('pseudo_link');
            bikinis_link.addClass('pseudo_link');
            window.location.hash = "";
            bikinis.animate({opacity: 0}, 500, 'linear', function() {
            });
			shoes.animate({opacity: 0}, 700, 'linear', function() {
				eStripe.style.left = 0;
				clothes.animate({opacity: 1}, 1000, function() {
					clothes[0].style.filter = '';
					//clothes[0].style.opacity = '';
				});
			});
		});

		shoes_link.click( function() {
			$(this).removeClass('pseudo_link hover');
			clothes_link.addClass('pseudo_link');
            bikinis_link.addClass('pseudo_link');
            window.location.hash = "#webdev";
            bikinis.animate({opacity: 0}, 500, 'linear', function() {
            });
			clothes.animate({opacity: 0}, 700, 'linear', function() {
				eStripe.style.left = '-100%';
				shoes.animate({opacity: 1}, 1000, function() {
					shoes[0].style.filter = '';
					//shoes[0].style.opacity = '';
				});
			});
		});

        bikinis_link.click( function() {
            $(this).removeClass('pseudo_link hover');
            clothes_link.addClass('pseudo_link');
            shoes_link.addClass('pseudo_link');
            window.location.hash = "";
            clothes.animate({opacity: 0}, 500, 'linear', function() {
            });

            shoes.animate({opacity: 0}, 700, 'linear', function() {
                eStripe.style.left = '-200%';

                bikinis.animate({opacity: 1}, 1000, function() {
                    bikinis[0].style.filter = '';
//                    shoes[0].style.opacity = '';
//                    clothes[0].style.opacity = '';
                });
            });
        });
	},



//    ----------------------

    clothes_select: function() {
        var oThis = this;
        var eStripe = $('#content div.content div.container div.stripe')[0];

        var clothes = $('#clothes');
        var shoes = $('#shoes');
        var bikinis = $('#bikinis');
        var clothes_link = $('#content div.content h2.clothes_link span');
        var shoes_link =   $('#content div.content h2.shoes_link span');
        var bikinis_link = $('#content div.content h2.bikinis_link span');

        clothes_link.removeClass('pseudo_link hover');
        shoes_link.addClass('pseudo_link');
        bikinis_link.addClass('pseudo_link');

        bikinis.animate({opacity: 0}, 500, 'linear', function() {
        });
        shoes.animate({opacity: 0}, 700, 'linear', function() {
            eStripe.style.left = 0;
            clothes.animate({opacity: 1}, 1000, function() {
                clothes[0].style.filter = '';
                //clothes[0].style.opacity = '';
            });
        });
    },

    shoes_select: function() {
        var oThis = this;
        var eStripe = $('#content div.content div.container div.stripe')[0];

        var clothes = $('#clothes');
        var shoes = $('#shoes');
        var bikinis = $('#bikinis');
        var clothes_link = $('#content div.content h2.clothes_link span');
        var shoes_link =   $('#content div.content h2.shoes_link span');
        var bikinis_link = $('#content div.content h2.bikinis_link span');

        shoes_link.removeClass('pseudo_link hover');
        clothes_link.addClass('pseudo_link');
        bikinis_link.addClass('pseudo_link');

        bikinis.animate({opacity: 0}, 500, 'linear', function() {
        });
        clothes.animate({opacity: 0}, 700, 'linear', function() {
            eStripe.style.left = '-100%';
            shoes.animate({opacity: 1}, 1000, function() {
                shoes[0].style.filter = '';
                //shoes[0].style.opacity = '';
            });
        });
    },

    bikinis_select: function() {

        var oThis = this;
        var eStripe = $('#content div.content div.container div.stripe')[0];

        var clothes = $('#clothes');
        var shoes = $('#shoes');
        var bikinis = $('#bikinis');
        var clothes_link = $('#content div.content h2.clothes_link span');
        var shoes_link =   $('#content div.content h2.shoes_link span');
        var bikinis_link = $('#content div.content h2.bikinis_link span');

        bikinis_link.removeClass('pseudo_link hover');
        clothes_link.addClass('pseudo_link');
        shoes_link.addClass('pseudo_link');

        clothes.animate({opacity: 0}, 500, 'linear', function() {
        });

        shoes.animate({opacity: 0}, 700, 'linear', function() {
            eStripe.style.left = '-200%';

            bikinis.animate({opacity: 1}, 1000, function() {
                bikinis[0].style.filter = '';
//                    shoes[0].style.opacity = '';
//                    clothes[0].style.opacity = '';
            });
        });
    }

//    ----------------------

};




