//************************************************************************************************************//
//												CONFIG
//************************************************************************************************************//

var browser = getBrowser();
var ROOT_URL = 'http://df.acondu.it';
var color_array = {
	'ezine': 'red',
	'blog': 'orange',
	'drawing': 'yellow',
	'color': 'green',
	'painting': 'blue',
	'materials': 'purple',
	'glossary': 'tan',
	'gallery': 'brown'
}

//************************************************************************************************************//
//												THE BASICS
//************************************************************************************************************//

// Sometimes I still like this instead of jQuery...
function getArrayByClass(tag_name,requested_class) {
	var dest_array = new Array();
	var all_elements_w_class = document.getElementsByTagName(tag_name);
	var obj_counter = 0;
	for (i=0; i<all_elements_w_class.length; i++) {
		var this_elements_class = all_elements_w_class[i].getAttribute("class");
		if (this_elements_class == requested_class) {
			dest_array[obj_counter] = all_elements_w_class[i];
			obj_counter++;
		}
	}
	return dest_array;
}

// Returns exponential sloping values instead of linear - use w/ setInterval().
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
    var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return Math.ceil(stepp) 
}

// Preload image script...
function preloadImages() {
	var image_array = new Array();
	for (i=0; i<preload_array.length; i++) {
		image_array[i] = new Image;
		image_array[i].src = preload_array[i];
	}
}

// Create an IMG table with absolute divs. Create a global array with img name variations for this to work.
function divTable(img_array,x_inc,y_inc,cols) {
	var html_string = "";
	var counter = 1;
	var x_increment = x_inc;
	var y_increment = y_inc
	var x_pos = 0;
	var y_pos = 0;
	
	for (i=0; i<img_array.length; i++) {
		
		html_string = html_string + ("<div id='" + img_array[i] + "' style='position:absolute;top:" + y_pos + "px;left:" + x_pos + "px;' class='div_table'><a class='slideshow' href='Media/almeria_" + img_array[i] + "_large.jpg' rel='group1'><img src='Media/almeria_" + img_array[i] + "_small.jpg' /></a></div>");
		
		if (counter <= cols - 1) {
			x_pos = x_pos + x_increment;
			counter++;
		}
		else {
			counter = 1;
			x_pos = 0;
			y_pos += y_increment;
		}
	}
	document.getElementById("img_container").innerHTML = html_string;	
}

// jQuery based Coda-style rising fade-out.
function codaExit(id) {
	var anim_time = 200;
	jQuery("#" + id).animate({'top' : '-=10px','opacity' : '0.0'},anim_time);
}

// Browser finder - could add on to this over time...
function getBrowser() {
	var browser;
	if (navigator.userAgent.match(/chrome/i)) {
	browser = "chrome";
	}
	else if (navigator.userAgent.match(/safari/i) && !(navigator.userAgent.match(/chrome/))) {
	browser = "safari";
	}
	else if (navigator.userAgent.match(/firefox/i)) {
	browser = "firefox";
	}
	else if (navigator.userAgent.match(/MSIE/i)) {
	browser = "ie";
	}
	return browser;
}

// Easy img rollover function. Add attr hover='IMGSRC' and class="rollover" to any image.
function initRollovers() {
	jQuery('.rollover').hover(function() {
        var currentImg = $(this).attr('src');
        var this_id = $(this).attr('name');
        
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
        $("#" + this_id).css('z-index','20');
    }, function() {
        var currentImg = $(this).attr('src');
        var this_id = $(this).attr('name');
        
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
        $("#" + this_id).css('z-index','1');
    });
}

// Simple boolean string checker.
function isString(input){
	return typeof(input)=='string';
}


// Validate email thru regex.
function emailIsValid(email) { 
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ 
	return email.match(re) 
}

//************************************************************************************************************//
//												INITIALIZATION SECTION
//************************************************************************************************************//

// 
function initColorNav() {
	initPalette();
	initColors();
	browserAdjust();
}

// This deals with the palette growth animation.
function initPalette() {
	if(palette_state == 0) {
		/* Revert spilled colors. */
		palette_state = 0;
		/* jQuery("#spilledcolors").css("opacity","0.0"); */
	
		document.getElementById("hiddenpalette").style.display = "block";
		document.getElementById("colors").style.display = "block";
		document.getElementById("spilledcolors").style.display = "block";
		palette_state = 1;
	}
	else {
	/* Palette growth stuff */
		palette_grower = new Grower("palette",-30);	
		palette_shrinker = new Grower("palette",470);	
			
		jQuery("#hiddenpalette").hover(function() {
			if(palette_state == 1) {
				if (spilled_state == 0) {
					spilled_state = 1;
					jQuery("#spilledcolors").fadeTo(200,1);
				}
				// We only want to activate this if an OUTER link isn't automatically shrinking the palette...
				if (outer_request_url == 0) {palette_grower.grow(150,250,1);}
			}
		},function() {
			if(palette_state == 1) {
				if (outer_request_url == 0) {palette_grower.grow(150,250,0);}
			}
		});
		
		/* Offset color links to match palette */
		var colors_offset = palette_grower.amount * 0.6;
		offsetColorLinks(colors_offset);
		/* Fade in saturated colors on hover. */
		jQuery("#colors").css("opacity","0.0");
		jQuery("#hiddenpalette").hover(function() {
			jQuery("#colors").fadeTo(350,1);
		},function() {
			jQuery("#colors").fadeTo(250,0);
		})
	}
}

// Changes the color link positions to match pre-shrunken palette(should've just made a smaller image to start with but c'est la vie...
function offsetColorLinks(offset) {
	jQuery("#colors > div").each(function() {
		var this_pos = $(this).position();
		jQuery(this).css("top",(this_pos.top - offset) + "px");
		jQuery(this).css("left",(this_pos.left - offset) + "px");
	});
	var hidden_pos = jQuery("#hiddenpalette").position();
	jQuery("#hiddenpalette").css("top",(hidden_pos.top - offset) + "px");
	jQuery("#hiddenpalette").css("left",(hidden_pos.left - offset) + "px");					
}


// These two deal with creating the palette rollover animations, and setting their onclick functions appropriately.
function initColors() {
	var spilled_color_array = getArrayByClass("div","spilledcolors");
	var color_link_array = document.getElementById("palettemap").getElementsByTagName("area");
	for (i=0; i<color_link_array.length; i++) {
		var this_id = spilled_color_array[i].getAttribute("id").toString();
		activateColorLink(color_link_array[i],this_id);					
	}
}

function activateColorLink(link,target_id) {
	/* Set initial color opacity to 0... */
	jQuery("#" + target_id).css("opacity","0.0");
	
	link.onmouseover = function() {
		jQuery("#" + target_id).fadeTo(200,1);
		jQuery("#" + target_id).css("z-index","10");
	}
	link.onmouseout = function() {
		jQuery("#" + target_id).fadeTo(200,0.1);
		jQuery("#" + target_id).css("z-index","1");
	}
	link.onclick = function() {
		changePage(link);
		return false;
	}
}

// Sets rollovers animations for the page nav area.
function initPageNav() {
	jQuery("#pagenav > div > a").hover(function(){
		var nav_link_name = this.getAttribute('name');
		if (nav_link_name != current_link) {
			var this_img = this.firstChild;
			var this_div_id = this.parentNode.getAttribute("id");
			var on_img_path = OUTER_MEDIA_PATH + "Colors/" + this_div_id + "_on.png";
			this_img.src = on_img_path;
		}
	}, function() {
		var nav_link_name = this.getAttribute('name');
		if (nav_link_name != current_link) {
			var this_img = this.firstChild;
			var this_div_id = this.parentNode.getAttribute("id");
			var off_img_path = OUTER_MEDIA_PATH + "Colors/" + this_div_id + "_off.png";
			this_img.src = off_img_path;
		}
	})
}

// Simple function to drop palette after all INIT is done. Done for cosmetic reasons, mostly.
function dropPalette() {
	jQuery("#nav").animate({'top' : '135px'},410);
	
	// Automatically move the palette...
	if (outer_request_url) {
		palette_grower.grow(150,250,1);
		setTimeout(function() {changePage('outer');},500);
	}
}

// Site specific layout adjustments for different browsers - can't figure out why they display the divs differently...
function browserAdjust() {
	var browser = getBrowser();
	if (browser == "firefox") {
		jQuery("#pagenav").css("left","48px");
		jQuery("#pagenav").css("top","238px");
	}
	else if (browser == "chrome") {
		jQuery("#pagenav").css("left","48px");
		jQuery("#pagenav").css("top","238px");
	}
	else if (browser == "safari") {
		jQuery("#pagenav").css("left","48px");
		jQuery("#pagenav").css("top","238px");
	}
}

//************************************************************************************************************//
//												ACTIONS SECTION!!! YEAH!!!
//************************************************************************************************************//

// Main master action orchestrator for a palette or page nav ONCLICK event.
function changePage(link) {
	
	// IF PALETTE IS BIG DO THESE THINGS:
	if (palette_state == 1) {
	
		// Set palette state to 0, i.e. shrunken.
		palette_state = 0;
		
		// Generate target page URL string from outer request url.
		if (link == "outer") {
			var target_page = "/inner/" + outer_request_url;
			var this_link = page;
		}
		else {
			var this_link = link.getAttribute("title");
			
			if (this_link == 'search') {
				var target_page = getSearchURL(link);
			}
			else {
				var target_page = "/inner/" + this_link + "/";
			}
		}
		// Only do stuff if different link is clicked on.
		if (this_link != current_link) {
		
			// IFRAME SECTION -------------------------->
		
			// Hide content div for aesthetic reasons.
			jQuery("#content").css("opacity","0");
			jQuery('#loading').css('display','block');
			
			// Relocate iframe content.
			document.getElementById('contentcontainer').style.top = "475px";
			document.getElementById('contentcontainer').style.zIndex = "12";
			window.frames['contentframe'].location = target_page;
			jQuery('#framesource a').first().attr('href',target_page);
			
			// END --------------------------------------<
			
			// Deactivate palette layer functionality. 
			document.getElementById("hiddenpalette").style.display = "none";
			document.getElementById("colors").style.display = "none";
			document.getElementById("spilledcolors").style.display = "none";
			
			// Shrink and move palette.
			if ((this_link == "search" || this_link == "rss" || this_link == "quiz") && link != "outer") {palette_grower.grow(150,250,1);}
			var move_duration = 400;
			jQuery("#palette").animate({left:"-=310px",top:"+0px"},move_duration);
			palette_shrinker.controlledGrow(move_duration,move_duration,0.6,0,0);
			
			// Add link functionality to shrunk palette.
			document.getElementById("palette").onclick = function() {
				backToHome(move_duration,'home');
			}
			
			// If from quiz signup, save email thru dajax.
			if (this_link == "quiz" && link != "outer") {
				var email = quizform_signup_email;
				Dajaxice.main.add_signup(Dajax.process,{'email': email});
			}
			
			// Activate page icon. 
			var page_icon_src = OUTER_MEDIA_PATH + "page_icons/icon_" + this_link + ".png";
			document.getElementById("pageicon").style.opacity = 0;
			document.getElementById("pageicon").style.display = "block";
			document.images['pageicon'].src = page_icon_src;
			jQuery("#pageicon").fadeTo(750,1);
			
			// Show appropriate pagenav rollover for page.
			jQuery('#pagenav > div > a').each(function() {
				var nav_name = jQuery(this).attr('name');
				var this_img = this.firstChild;
				var this_div_id = this.parentNode.getAttribute('id');
				
				if (nav_name == this_link) {
					this_img.src = OUTER_MEDIA_PATH + "Colors/" + this_div_id + "_on.png";
				}
				else {
					this_img.src = OUTER_MEDIA_PATH + "Colors/" + this_div_id + "_off.png";
				}
			});
			
			// Activate page nav. 
			window.setTimeout(function() {
				document.getElementById("pagenav").style.display = "block";
				jQuery("#pagenav").css("z-index","2")
				jQuery("#pagenav").fadeTo(500,1);
			},move_duration);
			
			// Show the HOME graphic next to palette.
			window.setTimeout(function() {document.getElementById('home').style.display = 'block';},move_duration);
			
			// Pull over the content index div.
			moveIndex(this_link);
			
			current_link = this_link;
		}
	}
	// IF PALETTE IS SHRUNK(PAGE NAV OPEN) DO THESE THINGS:
	else {
		var this_link = link.getAttribute("name");
		
		// Only do stuff if it is a new link clicked on.
		if (current_link != this_link || this_link == "search") {
		
			if (this_link == 'search') {
				var target_page = getSearchURL(link);
			}
			else {
				var target_page = "/inner/" + this_link + "/";
			}
			var page_icon_src = OUTER_MEDIA_PATH + "page_icons/icon_" + link.getAttribute("name") + ".png";
			
			// Show appropriate pagenav rollover for page.
			jQuery('#pagenav > div > a').each(function() {
				var nav_name = jQuery(this).attr('name');
				var this_img = this.firstChild;
				var this_div_id = this.parentNode.getAttribute('id');
				
				if (nav_name == this_link) {
					this_img.src = OUTER_MEDIA_PATH + "Colors/" + this_div_id + "_on.png";
				}
				else {
					this_img.src = OUTER_MEDIA_PATH + "Colors/" + this_div_id + "_off.png";
				}
			});
			
			// Fade out/in page icon. 
			document.getElementById("pageicon").style.opacity = 0.0;
			jQuery("#pageicon").fadeTo(500,1.0);
			
			// Change page icon img src.
			document.images['pageicon'].src = page_icon_src;
			
			// IFRAME SECTION ----------------------->
			
			// Hide content div for aesthetic reasons.
			jQuery("#content").css("opacity","0");
			jQuery('#loading').css('display','block');
			
			// Swap iframe.
			window.frames['contentframe'].location = target_page;
			jQuery('#framesource a').first().attr('href',target_page);
			
			// END IFRAME SECTION ---------------------------<		
			
			// Pull over the content index div.
			moveIndex(this_link);
			
			// Set the current link to the new link.
			current_link = this_link;
		}
		else {
			window.frames['contentframe'].location = "/inner/" + this_link + "/";
			jQuery('#framesource a').first().attr('href',"/inner/" + this_link + "/");
		}
	}
}


// ChangePage function but for links within the content area.
function changePageInner(link) {
	var this_link = link.getAttribute("name");
		
	// Only do stuff if it is a new link clicked on.
	if (window.parent.current_link != this_link) {
		
		// Fade out/in page icon. 
		window.parent.changeIcon(this_link);
		
		// Pull over the content index div.
		window.parent.moveIndex(this_link);
		
		// Set the current link to the new link.
		window.parent.current_link = this_link;
	}
}


// Band-aid function to fix jQuery bug when trying to call fades from child frame. Probably more modular anyway.
function changeIcon(link) {
	var page_icon_src = OUTER_MEDIA_PATH + "page_icons/icon_" + link + ".png";

	jQuery("#pageicon").css('opacity','0');
	jQuery("#pageicon").fadeTo(500,1.0);
	
	// Change page icon img src, change iframe. 
	document.images['pageicon'].src = page_icon_src;
}

// Deals with showing/hiding
function moveIndex(link) {
	// This actually determines the show/hide of the index div.
	if (!(link == "ezine" || link == "gallery" || link == "home" || link == "glossary" || link == "search" || link == "quiz")) {
		jQuery("#contentindex").css('display','block');
		jQuery("#contentindex").animate({'left' : '680px'},800);
	}
	else {
		jQuery("#contentindex").animate({'left' : '2000px'},400);
		window.setTimeout(function() {
			jQuery("#contentindex").css('display','none');
		},400);
	}
}


// This fills in the index with the appropriate topics.
function fillIndex() {

	// Get index keys from page array, and init html string.
	var categories = page_array;
	var index_string = "<ul>";
	if (categories) {
		for (cat in categories) {
			// Build the html...
			index_string += "<li>" + categories[cat] + "</li>";
		}
	}
	else {
		index_string += "<li><a href='#'>Coming soon</a></li>";
	}
	// Cap off the html, then insert into the index text div.
	index_string += "</ul>";
	window.parent.document.getElementById('contentindextext').innerHTML = index_string;

}


// This is what happens when topics from the topic index are clicked.
function swapTopic(page,topic) {
	var href = '/inner/articles/' + page + '/topic/' + topic + '/';
	window.frames['contentframe'].location = href;
	jQuery('#framesource a').first().attr('href',href);
}


// This is what happens when months from the archive index are clicked.
function swapArchive(page,year,month) {
	var href = '/inner/' + page + '/' + year + '/' + month + '/';
	window.frames['contentframe'].location = href;
	jQuery('#framesource a').first().attr('href',href);
}

 
// This removes page nav and animates palette back to its big original state. 
function backToHome(move_duration,target_location) {

	// Turns off any special behaviors from OUTER links once the appropriate content is shown.
	outer_request_url = 0;
	
	// Hide the HOME graphic next to palette.
	jQuery("#home").css('display','none');
	
	// Hide index.
	moveIndex('home');

	jQuery("#pagenav").css("z-index","2");
	
	// Animate and reinit palette nav. 
	jQuery("#palette").animate({left:"+=328px",top:"+=0px"},move_duration);
	palette_shrinker.revControlledGrow(move_duration);
	window.setTimeout("initPalette();",1000);
	
	// IFRAME SECTION ---------------------------->
	
	// Hide content div for aesthetic reasons.
	jQuery("#content").css("opacity","0.0");
	jQuery('#loading').css('display','block');
	
	// Relocate iframe content.
	document.getElementById('contentcontainer').style.top = "305px";
	document.getElementById('contentcontainer').style.zIndex = "0";
	window.frames['contentframe'].location = "/inner/" + target_location + "/";
	jQuery('#framesource a').first().attr('href',"/inner/" + target_location + "/");
	
	// END ---------------------------------------<
	
	// Deactivate page nav. 
	jQuery("#pagenav").fadeTo(500,0);
	jQuery("#pagenav").css("z-index","0");
	window.setTimeout(function() {
		jQuery("#pagenav").css("display","none");
	},move_duration);
	
	// Deactivate page icon.
	document.getElementById("pageicon").style.display = "none";
	
	// Set current link to HOME.
	current_link = "home";
}


// Animated div height adjuster for IFRAME CONTENT. Could abstract this more by turning DIVS and MIN_HEIGHT into args...?
function changeContentHeight(is_home) {
	var content_container = window.parent.document.getElementById("content");
	var this_container_id = content_container.getAttribute("id");
	
	var height = jQuery('#text').height();
	// Min height emulation...
	if (height < 900) {
		height = 900;
	}
	
	// Config individual div heights based on new iframe content.
	if (is_home) { var bg_height_padding = 250; } else { var bg_height_padding = 380; }
	var content_height = height + 30;
	var bg_height = content_height + bg_height_padding;
	var bg_footer_height = bg_height + 542;
	var admin_height = bg_footer_height+ 63;
	var main_height = height + 900;
	
	/* alert(content_height); */
	
	// Adjust main div to accommodate height changes.
	jQuery("#main",window.parent.document).css('height', main_height);
	
	// Animate them!
	jQuery("#content",window.parent.document).animate({height: content_height},300);
	jQuery("#contentbg",window.parent.document).animate({height: bg_height},300);
	jQuery("#contentbgfooter",window.parent.document).animate({top: bg_footer_height},300);
	jQuery("#admin",window.parent.document).animate({top: admin_height},300);
	
	// Alter iframe height.
	jQuery("#contentframe",window.parent.document).css('height', content_height);
}


// Triage function for all changes that need to happen once iframe content loads.
function initOuter(is_home) {
	jQuery('#loading',window.parent.document).css('display','none');
	changeContentHeight(is_home);
	jQuery("#content",window.parent.document).fadeTo(300,1);
}


// Show/hide animation for login form.
function toggleAccountDiv(type) {
	var duration = 500;
	// Make sure reg form is visible and login is hidden if type is reg:
	if (type == 'register') {
		toggleAccountForms(type);
	}
	// Both forms are the same width right now, so using the same code.
	if (type == 'login' || type == 'register') {
		var account_div = jQuery('#account');
		if (account_div.attr('openstate') == 'none') {
			account_div.animate({'left':['-230px','swing']},duration);
			account_div.attr('openstate','half');
		}
		else {
			account_div.animate({'left':['-450px','swing']},duration);
			account_div.attr('openstate','none');
		}
	}
}


// Toggle between login and registration forms.
function toggleAccountForms(type) {
	var acc_div = jQuery('#account');
	var reg_div = jQuery('#account #register');
	var log_div = jQuery('#account #login');
	
	if (type == 'register') {
		log_div.fadeTo(500,0);
		acc_div.animate({'height':'400px'},500);
		reg_div.delay(500).css('display','block').fadeTo(500,1);
	}
	else {
		acc_div.animate({'height':'240px'},500);
		reg_div.fadeTo(500,0);
		log_div.delay(500).fadeTo(500,1);
		window.setTimeout(function() { reg_div.css('display','none') },500);
	}
}

//************************************************************************************************************//
//												FORM SECTION
//************************************************************************************************************//

// Takes a form SELECT element and makes the option that matches the string argument the selected option.
function matchOptionTo(select_name,match_string) {
	if (match_string != "") {
		this_select_elem = document.getElementsByName(select_name)[0];
		
		for (i=0; i<this_select_elem.length; i++) {
		
			var this_option = this_select_elem.options[i];
			var this_option_value = this_select_elem.options[i].value;
			if (this_option_value == match_string) {
				this_option.setAttribute('selected','selected');
			}
		}
	}
}

function getSearchURL(evt) {
	fields = evt.elements;
	var search_term = fields[0].value;
	var search_type = fields[1].value;
	var search_token = fields[2].value;
	
	loc = '/search/?searchterm=' + search_term + '&searchtype=' + search_type + '&csrfmiddlewaretoken=' + search_token;
		
	return loc.toString();
}


function startQuiz(elem) {
	var email = quizform_signup_email;
	// If the email is valid, triage to main changePage function:
	if (emailIsValid(email)) {
		parent.quizform_signup_email = email;
		parent.changePage(elem);
	}
	// Else yell at the user for a proper email addy:
	else {
		alert('We are all for removing the boundaries on creative expression, but in this case please do enter a valid email address!');
	}
}


function startQuizWithEnter(elem,event) {
    var charCode;
    
    if (event && event.which) {
        charCode = event.which;
    }
    else if (window.event) {
        e = window.event;
        charCode = e.keyCode;
    }
    if (charCode == 13) {
    	quizform_signup_email = elem.value;
    	button = document.getElementById('quizstartsubmitbutton');
    	startQuiz(button);
    }
}


//************************************************************************************************************//
//												GALLERY SECTION
//************************************************************************************************************//

// Sets up fancybox effect on any href with designated class.
function setupZoom() {
	jQuery("a.slideshow").fancybox();
}

// iPhoto-esque scrollover flipthru effect for photo galleries. Works presently w/ each photo in its own div.
function initScrollover() {
	if (browser != 'ie') {	
		// Loop thru each gallery on page and send to delegate function for initialization.
		jQuery('.gallery').each(function() {
			// Gather info about this gallery.
			gallery = jQuery(this);
			img_divs = gallery.find('.galleryphoto');
			count = img_divs.size();
			
			// Send data to function delegate for each gallery.
			galleryScrolloverDelegate(gallery,img_divs,count);
		})
	}
}

function galleryScrolloverDelegate(gallery,img_divs,count) {
	img_divs.each(function(index) {
		// Find width of mouse slice(in pixels) before incrementing images.
		img_div = jQuery(this);
		width = img_div.find('img').width()
		// Hide all but the first image div.
		if (index != 0) {
			img_div.css('visibility','hidden')
		}
		// When mouse moves over gallery, gather mouse X position.
		img_div.mousemove(function(evt) {
			photoScrolloverDelegate(evt,img_divs,width,count);
		})
		gallery.mouseout(function() {
			img_divs.eq(0).css('visibility','visible');
		})
	})
}

function photoScrolloverDelegate(evt,img_divs,width,count) {
	slice_width = width/count;
	
	position = evt.layerX;
	slice = Math.floor(position/slice_width);
	for (i=0; i<count; i++) {
		if (i == slice) {
			img_divs.eq(i).css('visibility','visible');
		}
		else {
			img_divs.eq(i).css('visibility','hidden');
		}
	}
}
