// JavaScript Document
// Author: Mike T - Mindblossom Inc.

function LinkFichier(file) {
	window.open("http://old.canadianliving.com/upload/CanadianLiving/generateur/"+file);
}

function OpenGlossaireUrl(url) {
	window.open("http://old.canadianliving.com"+url);
}

//toggles the subscription content boxes in the right column
function toggleSubscription(elementId){
	if (document.getElementById){
		if(elementId == 'sub_gift'){
			document.getElementById('sub_today_content').style.display = 'none';
			document.getElementById('sub_my_content').style.display = 'none';
			document.getElementById('sub_gift_content').style.display = 'block';
			document.getElementById(elementId).className = elementId + '_on';
			document.getElementById('sub_today').className = 'sub_my_off';
			document.getElementById('sub_my').className = 'sub_my_off';
		}else if(elementId == 'sub_today'){
			document.getElementById('sub_gift_content').style.display = 'none';
			document.getElementById('sub_my_content').style.display = 'none';
			document.getElementById('sub_today_content').style.display = 'block';
			document.getElementById(elementId).className = elementId + '_on';
			document.getElementById('sub_my').className = 'sub_my_off';
			document.getElementById('sub_gift').className = 'sub_my_off';
		}else if(elementId == 'sub_my'){
			document.getElementById('sub_gift_content').style.display = 'none';
			document.getElementById('sub_my_content').style.display = 'block';
			document.getElementById('sub_today_content').style.display = 'none';
			document.getElementById(elementId).className = elementId + '_on';
			document.getElementById('sub_today').className = 'sub_my_off';
			document.getElementById('sub_gift').className = 'sub_my_off';
		}
	}
}//toggleSubscription

//this function will reset all recipe box headers to off state,
//and then set the user selected recipe box header to on state
function setRecipeHeader(elementId){
	var divs, i, j, k, resetId;
	k = 0;
	//create array with all divs in doc
	divs = document.getElementsByTagName('div');
	//loop through all divs in doc
	for (j=0; j<divs.length; j++){
		//check to see if div is a recipe box
		if (divs[j].id == 'recipe_box_' + k){
			//if the div is a recipe box, reset the header to off state
			document.getElementById('recipe_box_' + k).className = 'recipe_outside recipe_header_off';
			k++;
		}
	}
	//loop through all divs in doc
	for (i=0; i<divs.length; i++){
		//if the div id is the id passed to this function (user selected recipe box)		
		if (divs[i].id == elementId){
			//change the header to on state
			document.getElementById(elementId).className = 'recipe_outside recipe_header_on';
		}
	}
}//setRecipeHeader

//this function will hide all content browser containers and then display the selected container
//it will also hide set the content browser nav buttons to off and then change the slected to on
//the hyperlink id (nav button) and content container ids are passed as parameters
function contentBrowserNav(btn, num, content){
	var divs, j, k;
	k = 1;
	//create array with all divs in doc
	divs = document.getElementsByTagName('div');
	//loop through all divs in doc
	document.getElementById(btn).className = 'hide';
	for (j=0; j<divs.length; j++){
		//check to see if div is a content container
		if(divs[j].id == 'tab_content_' + k){
			//if the div is a content container, hide it
			document.getElementById('tab_content_' + k).className = 'hide';
			//if the div is a content broswer nav button, change to off state
			document.getElementById('hl_tab_' + k).className = 'cb_tab_' + k + '_off';
			//show the user selected content container, content var is passed to function
			document.getElementById(btn).className = 'cb_tab_' + k + '_on';		
			k++;
		}//if
		document.getElementById(btn).className = 'cb_tab_' + num + '_on';
		document.getElementById(content).className = 'cb_content';
	}//for
}//contentBrowserNav

//this function will display next content browser tab
var currentContentOpenedTab = 0;
function nextContentBrowserNav() {
	if ( currentContentOpenedTab < 5 ) currentContentOpenedTab++;
	else currentContentOpenedTab = 1;
	var tab_name = 'hl_tab_' + currentContentOpenedTab;
	var tab_num = currentContentOpenedTab;
	var tab_content = 'tab_content_' + currentContentOpenedTab;
	contentBrowserNav(tab_name,tab_num, tab_content);
}


//this function will display a message and then remove it after 3 seconds
function displayMessage(el){
	if (document.getElementById){
		//use scriptaculous to fade in message
		new Effect.Appear(el);
		//use scriptaculous to fade out message after 3 seconds
		if (navigator.platform.indexOf("Mac") > -1){
			window.setTimeout("document.getElementById('" + el + "').style.visibility = 'hidden';", 3000);
		}else{
		window.setTimeout("new Effect.Fade('" + el + "');", 3000);
		} 
	}//if	
}//displayMessage

//the following functions are used to scroll images left and right within the image scroller
function moveToPrevious(){
  
  if(currentImage > 0)  {
   document.getElementById('lnkQENext').style.visibility = 'visible';
	 new Effect.Move('photo_scroll_inside', { x: 113, y: 0, transition: Effect.Transitions.sinoidal });
	 currentImage--;
  }// if
  
  if(currentImage == 0) {
    document.getElementById('lnkQEPrevious').style.visibility = 'hidden';
  } 


}//function
function moveToNext(){
  
  if (currentImage < totalImages-viewSize)  {
   document.getElementById('lnkQEPrevious').style.visibility = 'visible';
	 new Effect.Move('photo_scroll_inside', { x: -113, y: 0, transition: Effect.Transitions.sinoidal });
	 currentImage++;
  }//if  
  
  if(currentImage == totalImages-viewSize) {
    document.getElementById('lnkQENext').style.visibility = 'hidden';
  } 


  
}//function

//the following functions are used to scroll images left and right within the image scroller
function moveToPreviousSmall(){
  if(currentImage > 0)  {
	new Effect.Move('photo_scroll_inside', { x: 90, y: 0, transition: Effect.Transitions.sinoidal });
	currentImage--;
  }//if
}//function
function moveToNextSmall(){
  if(currentImage < totalImages-viewSize)  {
	new Effect.Move('photo_scroll_inside', { x: -90, y: 0, transition: Effect.Transitions.sinoidal });
	currentImage++;
  }//if
}//function

//this function will display a confirmation box
function displayConfirmation(el){
	if (document.getElementById){
		new Effect.Appear(el);
	}//if	
}//displayConfirmation

//this function will hide the confirmation box and display the "recipe deleted" success box
function deleteRecipe(toHide, toShow){
	//if toShow is null, which means there's no success box to display, hide the confirmation box
	if (toShow == '' || toShow == null){
		new Effect.Fade(toHide);
	}else{
		new Effect.Fade(toHide);
		window.setTimeout("new Effect.Appear('" + toShow + "');", 1000);
		window.setTimeout("new Effect.Fade('" + toShow + "');", 3000);
	}//if
}//deleteRecipe

//this function will display the email recipe to a friend box and hide the my recipe box table
function displayEmailRecipe(toHide, toShow){
	if (document.getElementById){
		window.setTimeout("document.getElementById('" + toHide + "').className = 'hide';", 100);
		new Effect.Appear(toShow);
		//new Effect.Move(toShow, {x:-296, y:0, mode: 'relative'});
	}//if
}

//this fucntion will do the oposite of the above function
function closeEmailRecipe(toHide, toShow){
	
	if (document.getElementById){
		//new Effect.Move(toHide, {x:296, y:0, mode: 'relative'});
		new Effect.Fade(toHide);
		//new Effect.Fade(toHide);
		window.setTimeout("document.getElementById('" + toShow + "').className = 'show'; new Effect.Appear('" + toShow + "');", 800);
	}//if
}

var headerFlag;
//this function will display the recipe login
function displayLogin(toShow, isHeader){
	if (document.getElementById){
		//if it's the header login, set the my cl state
		if (isHeader){
			if (!headerFlag){
				document.getElementById('header_top_right').className = 'header_top_right_on';
				headerFlag = true;
				new Effect.Appear(toShow);
				//new Effect.Move(toShow, {x:-475, y:0, mode: 'relative'});
			}
		}else {
			new Effect.Appear(toShow);
			//new Effect.Move(toShow, {x:-475, y:0, mode: 'relative'});
		}//if

	}//if
}

//this fucntion will do the oposite of the above function
function closeLogin(toHide, isHeader){
	if (document.getElementById){
		if (isHeader == 'true'){
			document.getElementById('header_top_right').className = 'header_top_right_off';
		}
		headerFlag = false;
		//new Effect.Move(toHide, {x:475, y:0, mode: 'relative'});
		new Effect.Fade(toHide);
	}//if
}

//my recipe box in right col
function accordion(el) {
    if ($('visible') == el) {
        return;
    }
    if ($('visible')) {
        var eldown = el.parentNode.id+'-body';
        var elup = $('visible').parentNode.id+'-body';
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.5
        });
        $('visible').id = '';
    }
    el.id = 'visible';
}

function init() {

//	//create array with all divs in doc
//	divs = document.getElementsByTagName('div');
//	//loop through all divs in doc
//	for (j=0; j<divs.length; j++){
//		//check to see if div is a recipe box
//		if (divs[j].id == 'recipe_box_' + k){
//			//if the div is a recipe box, reset the header to off state
//			document.getElementById('recipe_box_' + k).className = 'recipe_outside recipe_header_off';
//			k++;
//		}
//	}


/*

    // hide all elements apart from the one with id visible
    var acc = document.getElementById('recipe_box');

	if(acc == null){
		return false;
	}else{
		var apanels = acc.getElementsByTagName('div');
		for (i = 0; i < apanels.length; i++) {
			if (apanels[i].className == 'recipe_inside') {
				apanels[i].style.display = 'none';
			}
		}
		var avis = document.getElementById('visible').parentNode.id+'-body';
		document.getElementById(avis).style.display = 'block';
	}*/
}
function addEvent(elm, evType, fn, useCapture) {
    elm["on"+evType]=fn;return;
}

addEvent(window, "load", init);

//this function will hide all content browser containers and then display the selected container
//it will also hide set the content browser nav buttons to off and then change the slected to on
//the hyperlink id (nav button) and content container ids are passed as parameters
function contentBrowserMidNav(btn, num, content){
	var divs, j, k;
	k = 1;
	for (j=1; j<=5; j++){
		document.getElementById('hl_tab_' + j).className = 'cb_tab_' + j + '_off';
		document.getElementById('tab_content_' + j).className = 'hide';
	}
	document.getElementById(btn).className = 'cb_tab_' + num + '_on';
	document.getElementById(content).className = 'cbm_content';
//	}//for
}//contentBrowserNav

//************************************************** Article Pages **************************************************/

// Cross Browser DOM
// copyright Stephen Chapman, 4th Jan 2005
// you may copy this code but please keep the copyright notice as well
var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {
var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
&& (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}
function xDOM(objectId, wS) {
if (stdDOM) return wS ? document.getElementById(objectId).style:
document.getElementById(objectId);
if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
if (nsDOM) return document.layers[objectId];
}                  

// Object Functions
// copyright Stephen Chapman, 4th Jan 2005
//  you may copy these functions but please keep the copyright notice as well
function objWidth(objectID) {var obj = xDOM(objectID,0); if(obj.offsetWidth) return  obj.offsetWidth; if (obj.clip) return obj.clip.width; return 0;}        function objHeight(objectID) {var obj = xDOM(objectID,0); if(obj.offsetHeight) return  obj.offsetHeight; if (obj.clip) return obj.clip.height; return 0;}    function objLeft(objectID) {var obj = xDOM(objectID,0);var objs = xDOM(objectID,1); if(objs.left) return objs.left; if (objs.pixelLeft) return objs.pixelLeft; if (obj.offsetLeft) return obj.offsetLeft; return 0;} function objTop(objectID) {var obj = xDOM(objectID,0);var objs = xDOM(objectID,1); if(objs.top) return objs.top; if (objs.pixelTop) return objs.pixelTop; if (obj.offsetTop) return obj.offsetTop; return 0;} function objRight(objectID) {return objLeft(objectID)+objWidth(objectID);} function objBottom(objectID) {return objTop(objectID)+objHeight(objectID);} function objLayer(objectID) {var objs = xDOM(objectID,1); if(objs.zIndex) return objs.zIndex; return 0;} function objVisible(objectID) {var objs = xDOM(objectID,1); if(objs.visibility == 'hide' || objs.visibility == 'hidden') return 'hidden'; return 'visible';}
                    


// this function will increase the article font size
var currentFontSize = '1em' ;
function increaseFontSize(){
/*
	if(document.getElementById){
		if(currentFontSize == '1em'){
			document.getElementById('article').style.fontSize = '1.1em';
			document.getElementById('sub_title').style.fontSize = '1.2em';
			document.getElementById('title').style.fontSize = '1.4em';
			currentFontSize = '1.1em';
		}else if(currentFontSize == '1.1em'){
			document.getElementById('article').style.fontSize = '1.2em';
			document.getElementById('sub_title').style.fontSize = '1.3em';
			document.getElementById('title').style.fontSize = '1.5em';			
			currentFontSize = '1.2em';
		}else if(currentFontSize == '1.2em'){
			document.getElementById('article').style.fontSize = '1.3em';
			document.getElementById('sub_title').style.fontSize = '1.4em';
			document.getElementById('title').style.fontSize = '1.6em';			
			currentFontSize = '1.3em';
		}else if(currentFontSize == '1.3em'){
			document.getElementById('article').style.fontSize = '1.4em';
			document.getElementById('sub_title').style.fontSize = '1.5em';
			document.getElementById('title').style.fontSize = '1.7em';			
			currentFontSize = '1.4em';
		}else{
			return false;
		}
		//alert(document.getElementById('article').style.fontSize);
	}//if
*/
document.getElementById("main_inner_content").style.fontSize = +document.defaultView.getComputedStyle(document.getElementById("main_inner_content"), null).getPropertyValue("font-size").slice(0,-2) + 3 + "px";

}//increaseFontSize

function decreaseFontSize(){
/*
	if(document.getElementById){
		if(currentFontSize == '1.4em'){
			document.getElementById('article').style.fontSize = '1.3em';
			document.getElementById('sub_title').style.fontSize = '1.4em';
			document.getElementById('title').style.fontSize = '1.6em';			
			currentFontSize = '1.3em';
		}else if(currentFontSize == '1.3em'){
			document.getElementById('article').style.fontSize = '1.2em';
			document.getElementById('sub_title').style.fontSize = '1.3em';
			document.getElementById('title').style.fontSize = '1.5em';			
			currentFontSize = '1.2em';
		}else if(currentFontSize == '1.2em'){
			document.getElementById('article').style.fontSize = '1.1em';
			document.getElementById('sub_title').style.fontSize = '1.2em';
			document.getElementById('title').style.fontSize = '1.4em';			
			currentFontSize = '1.1em';
		}else if(currentFontSize == '1.1em'){
			document.getElementById('article').style.fontSize = '1em';
			document.getElementById('sub_title').style.fontSize = '1.1em';
			document.getElementById('title').style.fontSize = '1.3em';			
			currentFontSize= '1em';
		}else{
			return false;
		}//if
		
	}//if
*/	
document.getElementById("main_inner_content").style.fontSize = +document.defaultView.getComputedStyle(document.getElementById("main_inner_content"), null).getPropertyValue("font-size").slice(0,-2) - 3 + "px";	
}//function




t=0;

function toggleRelatedContent(){
	if(t==0){
		Effect.Squish('rel_content');
		document.getElementById('btn_related').className = 'open';
		//240px or greater are good
		//if the first paragraph height is greater than 240px, do nothing but increment counter
		if (objHeight('para_1') >= 240){
			t++;
		//else subtract 240px by the height of the first paragraph and add the difference to the top margen of the Comments header
		}else{
			//document.getElementById('comments_header').style.marginTop = 160 - objHeight('para_1') + 'px';
			t++;
		}
	}else{
		Effect.Grow('rel_content');	
		document.getElementById('btn_related').className = 'close';
		//document.getElementById('comments_header').style.marginTop = '0';
		t--;
	}

}

//this function for the relatedContent in recipe_b only
tt=0;

function toggleRelatedContent_recipe_b(){
	if(tt==0){
		Effect.Squish('rel_content');
		document.getElementById('btn_related').className = 'open_b';
		//240px or greater are good
		//if the first paragraph height is greater than 240px, do nothing but increment counter
		if (objHeight('para_1') >= 240){
			tt++;
		//else subtract 240px by the height of the first paragraph and add the difference to the top margen of the Comments header
		}else{
			//document.getElementById('comments_header').style.marginTop = 160 - objHeight('para_1') + 'px';
			tt++;
		}
	}else{
		Effect.Grow('rel_content');	
		document.getElementById('btn_related').className = 'close_b';
		//document.getElementById('comments_header').style.marginTop = '0';
		tt--;
	}

}//recipe_b

//this function for the relatedContent in menu_a only
ttt=0;

function toggleRelatedContent_menu_a(){
	if(ttt==0){
		Effect.Squish('rel_content');
		document.getElementById('btn_related').className = 'open_menu_a';
		//240px or greater are good
		//if the first paragraph height is greater than 240px, do nothing but increment counter
		if (objHeight('para_1') >= 240){
			ttt++;
		//else subtract 240px by the height of the first paragraph and add the difference to the top margen of the Comments header
		}else{
			//document.getElementById('comments_header').style.marginTop = 160 - objHeight('para_1') + 'px';
			ttt++;
		}
	}else{
		Effect.Grow('rel_content');	
		document.getElementById('btn_related').className = 'close_menu_a';
		//document.getElementById('comments_header').style.marginTop = '0';
		ttt--;
	}

}//menu_a

//this function for the relatedContent in menu_b only
tttt=0;

function toggleRelatedContent_menu_b(){
	if(tttt==0){
		Effect.Squish('rel_content');
		document.getElementById('btn_related').className = 'open_menu_b';
		//240px or greater are good
		//if the first paragraph height is greater than 240px, do nothing but increment counter
		if (objHeight('para_1') >= 240){
			tttt++;
		//else subtract 240px by the height of the first paragraph and add the difference to the top margen of the Comments header
		}else{
			//document.getElementById('comments_header').style.marginTop = 160 - objHeight('para_1') + 'px';
			tttt++;
		}
	}else{
		Effect.Grow('rel_content');	
		document.getElementById('btn_related').className = 'close_menu_b';
		//document.getElementById('comments_header').style.marginTop = '0';
		tttt--;
	}

}//menu_b


//this function will display the email recipe to a friend box and hide the my recipe box table
function displayEmailArticle(toShow){
	if (document.getElementById){
		//window.setTimeout("document.getElementById('" + toHide + "').className = 'hide';", 100);
		new Effect.Appear(toShow);
		//new Effect.Move(toShow, {x:-296, y:0, mode: 'relative'});
	}//if
}

//this fucntion will show one element and hide another, element ids are passed as parameters
function showHide(toShow, toHide){
	
	if(document.getElementById){
		if (document.getElementById(toShow)!==null) {
			document.getElementById(toShow).style.display = 'block';
		}
		//document.getElementById('comments_form_box').style.display = 'block';
		if (document.getElementById(toHide)!==null) {
			document.getElementById(toHide).style.display = 'none';
		}
	}//if
}

function showOnly(toShow) {
	if(document.getElementById){
		document.getElementById(toShow).style.display = 'block';
		//document.getElementById('comments_form_box').style.display = 'block';
	}//if

}




//************************************************ Channels Page ************************************************/
//	//create array with all divs in doc
//	divs = document.getElementsByTagName('div');
//	//loop through all divs in doc
//	for (j=0; j<divs.length; j++){
//		//check to see if div is a recipe box
//		if (divs[j].id == 'recipe_box_' + k){
//			//if the div is a recipe box, reset the header to off state
//			document.getElementById('recipe_box_' + k).className = 'recipe_outside recipe_header_off';
//			k++;
//		}
//	}

function closeAllPopUps(){
	q = 1;
	if(document.getElementById){
		
		divs = document.getElementsByTagName('div');	
		
		for(p=1; p<divs.length; p++){
			
			if(divs[p].id == 'more_chan_' + q){
				//alert('found = ' + divs[p].id);
				document.getElementById('more_chan_' + q).style.display = 'none';
				q++;
				
				
			}//if
			
		}//for
		
		
		
		
		
//		for(r=1; r<=6; r++){
//			document.getElementById('more_chan_' + r).style.display = 'none';	
//			
//		}
		
		
		
	}
	
}




//************************************************ SEARCH RESULTS Page ************************************************/
function showResults(){
	document.getElementById('results_tab').className = 'tab_on';
	document.getElementById('recipes_tab').className = 'tab_off';
	document.getElementById('results_shell').style.display = 'block';
	document.getElementById('recipes_shell').style.display = 'none';
}

function showRecipes(){
	document.getElementById('results_tab').className = 'tab_off'; 
	document.getElementById('recipes_tab').className = 'tab_on';
	document.getElementById('results_shell').style.display = 'none';
	document.getElementById('recipes_shell').style.display = 'block';
}

//show or hide an element
function evt_search_option(divid, switchid, options_sate, hidestr, showstr) {

	option = document.getElementById(divid);
	link_show_hide = document.getElementById(switchid);
	if(options_sate == 'show') 
	{
		option.style.display = 'block';
		options_sate = 'block';
		link_show_hide.innerHTML = hidestr;
		link_show_hide.href = 'javascript:evt_search_option(\''+divid+'\', \''+switchid+'\', \'hide\', \''+hidestr+'\', \''+showstr+'\')';	
	} else {
		option.style.display = 'none';
		options_sate = 'none';
		link_show_hide.innerHTML = showstr;
		link_show_hide.href = 'javascript:evt_search_option(\''+divid+'\', \''+switchid+'\', \'show\', \''+hidestr+'\', \''+showstr+'\')';	
	}
}


/* Sarven Capadisli 2007 */
var CL = {
	Init: {
		Increment: 0,
		Direction: 0,
		MainInnerContent: 'main_inner_content'
	},

	Config: {
			Increment : 0.1,
			Skin: {
				SelectBox: {
					OpenedClassName: "opened",
					ClosedClassName: "closed",
					SelectedClassName: "selected",
					HoverClassName: "hover",
					TypographyDecreaseClassName: "typography_decrease",
					TypographyIncreaseClassName: "typography_increase",
					RequiredFieldName: "required_field",
					ValidateRequiredFieldsName: "validate_required_fields",
					FieldValidatePostalCodeName: "field_validate_postal_code",
					FieldValidateEmailName: "field_validate_email",
					FieldValidateEmailIdenticalName: "field_validate_email_identical",
					FieldValidateEmailMultipleName: "field_validate_email_multiple",
					WarningName: "warning",
					ErrorName: "error"
				}
			}			
	},
	Utils: {
		ClassName: {
			hasClass: function(obj, str) {
				return obj && new RegExp('(?:^|\\s)' + str + '(?:\\s|$)').test(obj.className);
			},
			Add: function (obj, str) {
				if (!this.hasClass(obj, str)) { obj.className += (obj.className ? ' ' : '') + str; }
			},
			Remove: function (obj, str) {
				if (this.hasClass(obj, str)) { obj.className = obj.className.replace(new RegExp('^(?:' + str + '(?:\\s+|$))+|\\s+' + str + '\\s*(?=\\s|$)', 'g'), ''); }
			},
			setClass: function (obj, str, add) {
				return add ? this.Add(obj, str) : this.Remove(obj, str);
			}
		},
		
		ShowHide: function(action_element_id, show_hide_container_id, return_value) {
			var modifyClass = CL.Utils.ClassName;
			var settings = CL.Config.Skin.SelectBox;

			show_hide_container_id = document.getElementById(show_hide_container_id);

			if(document.getElementById(action_element_id)) {
				document.getElementById(action_element_id).onclick = function () {
					if (modifyClass.hasClass(show_hide_container_id, settings.OpenedClassName)) {
						modifyClass.Remove(show_hide_container_id, settings.OpenedClassName);
						modifyClass.setClass(show_hide_container_id, settings.ClosedClassName, 'add');
					}
					else {
						modifyClass.Remove(show_hide_container_id, settings.ClosedClassName);
						modifyClass.setClass(show_hide_container_id, settings.OpenedClassName, 'add');
					}
					return return_value || false;
				};
			}
		},
		
		GetElementsByClassName: function (name, nodes) {
			var ret = [];
			var re = new RegExp('(?:^|\\s)' + name + '(?:\\s|$)');
			if (!nodes) { nodes = document.getElementsByTagName('*'); }
			for (var i = 0, l = nodes.length; i < l; i++) {
				if (re.test(nodes[i].className)) { ret.push(nodes[i]); }
			}
			return ret;
		}
	},
	FontResize: function (direction, increment, id) {
		if (direction == 0) {
			document.getElementById(id).style.fontSize = "1em";
		}	
		document.getElementById(id).style.fontSize = +document.getElementById(id).style.fontSize.slice(0,-2) + increment*direction + "em";

	}
};

function Go() {
	if (document.getElementById('main_col').className === 'hfeed' || document.getElementById('main_col').className === 'recipe') {
		CL.FontResize(CL.Init.Direction, CL.Init.Increment, CL.Init.MainInnerContent);
	}

	if (document.getElementById('send_to_friend')) {
		CL.Utils.ClassName.Add(document.getElementById('send_to_friend'), CL.Config.Skin.SelectBox.ClosedClassName);
		CL.Utils.ShowHide('email_send_to_friend', 'send_to_friend');
		CL.Utils.ShowHide('send_to_friend_container_action', 'send_to_friend');
	}
	
	if (document.getElementById('disclaimer')) {
		CL.Utils.ClassName.Add(document.getElementById('disclaimer'), CL.Config.Skin.SelectBox.ClosedClassName);
		if($('link_disclaimer'))
		{
		  CL.Utils.ShowHide('link_disclaimer', 'disclaimer');
		}
		if($('disclaimer_container_action'))
		{
		  CL.Utils.ShowHide('disclaimer_container_action', 'disclaimer');
		}
	}

	if (document.getElementById('comments_form_box')) {
		CL.Utils.ClassName.Add(document.getElementById('comments_form_box'), CL.Config.Skin.SelectBox.ClosedClassName);
		CL.Utils.ShowHide('comments_form_box_display', 'comments_form_box');
		CL.Utils.ShowHide('comments_form_box_hide', 'comments_form_box');
	}

}

function validateWordsLenght(field,length,silent)
{
    var value = $F(field);
     
    valueLength = value.strip().length;
    
    var valid = (valueLength >= length || valueLength == 0);
    
    
    /* Check where made words by words but have been change for complete string
    var valid = true;
    value.split(" ").each(function(str,index){
        // Test if the string is blank 
        if(! /^\s*$/.test(str) ){

            if(str.length < length)
            {
                valid = false;
            }
        }
    });
    */
    if(!valid && !silent)
    {
        alert('Search terms must have at least ' + length + ' characters. Please try again with a longer word.');
        $(field).focus();
    }

    return valid;
}

MyCL = new Object();

MyCL.forms = new Object();

MyCL.forms.UpdatePicture = new Object();

MyCL.forms.UpdatePicture.validate = function()
{
    if($F('picture') == '')
    {
        alert('You need to select a picture');
        return false;
    }
    
    return true;
}

function mergeFormAndSubmit()
{
    $('search_context_keywords').value = $F('search_fulltext2');
    if(validateWordsLenght('search_context_keywords',3,false))
    {
        $('search_recipe').submit();
    }
}

function validateContactUsForm()
{
    if($F('contact_name') == 'empty')
    {
        alert('Please select a Contact');
        $('contact_name').focus();
        return false;
    }
    return true;
}

/**/
