﻿function toggleFoldable(id)
{
	$j(id).parent().toggleClass("active");
	
	if($j.browser.msie)
		$j(id).css("visibility","hidden");
		
	$j(id).toggle('slow',function(){
		if($j.browser.msie)
		{
			//this.style.removeAttribute('filter');
			$j(this).get(0).style.removeAttribute('filter');
			$j(id).css("visibility","visible");
		}
			
			//this.style.removeAttribute('filter');
	});
}


function init_search() 
{
	$j(".SearchBox input").focus(function(){
			$j(this).val("");
	});
	$j(".SearchBox input").blur(function(){
		if ($j(this).val()=="")
			$j(this).val("αναζήτηση");
	});
	


	var textResult = "";
	$j(".SearchBoxResult").focus(function(){
			textResult = $j(this).val();
			$j(this).val("");
	});
	$j(".SearchBoxResult").blur(function(){
		if ($j(this).val()=="")
			$j(this).val(textResult);
	});


} 

function init_corner()
{
	var corn1 = "5px";
	var corn2 = "4px";
	
	if (!($j.browser.msie && $j.browser.version < 9)){
		
	/*
	{
		$j(".SidebarBlock.withHeader").css({"background":"#d7d7d7","padding":"1px"});	
		$j(".SidebarBlock.withHeader .content").css({"background":"#ffffff"});
		
		var html = $j(".LatestBlogArticle").html();
		$j(".LatestBlogArticle").html('<div class="wrapper">'+html+"</div>").css({"background":"#b0b0b0","padding":"1px","height":"301px"});
		$j(".LatestBlogArticle .wrapper").css({"background":"#fff","padding":"8px"});
		
		var html = $j(".homeLatestNews .LatestNews").html();
		$j(".homeLatestNews .LatestNews").html('<div class="wrapper">'+html+"</div>").css({"background":"#b0b0b0","padding":"1px","width":"270px","height":"301px"});
		$j(".homeLatestNews .LatestNews .wrapper").css({"background":"#fff","padding":"8px 8px 3px"});
		
		
		
		 corn1 = "3px";
		 corn2 = "2px";
	}
	*/
	
	if (!($j.browser.msie && $j.browser.version < 8))
		$j(".CarouselList .center .Productlinks li a").corner("5px");

	
		
	$j(".SidebarBlock.withHeader,.SearchResultPanel,.ContactForm,.LatestBlogArticle, .homeLatestNews .LatestNews").corner(corn1);
	$j(".SidebarBlock.withHeader .title").corner(corn2);
	
	$j(".SidebarBlock.withRedHeader").corner(corn1);
	$j(".SidebarBlock.withRedHeader .title").corner(corn2);

	$j(".CategorySelector,.LeftColumn h1.categoryTitle,.subPageBlock,.subPageBlock2Col").corner("5px");
	$j(".BlogArchive,.BlogArticleAll .image,.BlogArticle .image, .StepIndicator ul li").corner("5px");	

	$j(".NewsletterSignup,.newsLetter .submit, .SidebarBlock .scPollMain .scButtons a").corner("5px");
	 
	$j(".round, .StepPanelMotor .StepButtonNext, .StepPanelMotor .StepButtonPrevious").corner("5px");	
	
	
	}

}

function init_height()
{
	
	$j(".SubpageContainer2Col .container").each(function(index){
		var blue = $j(this).find(".subPageBlock2Col.blue");
		var red = $j(this).find(".subPageBlock2Col.red");		

		var maxheight = Math.max(blue.height(),red.height());
		
		$j(this).find(".subPageBlock2Col").css({"height":maxheight+"px"});

	});


	$j(".SubpageContainer .container").each(function(index){
		var blue = $j(this).find(".subPageBlock.blue h2");
		var red = $j(this).find(".subPageBlock.red h2");
		var grey = $j(this).find(".subPageBlock.grey h2");		
		
		var maxheight = Math.max(blue.height(),red.height(),grey.height());
		
		$j(this).find(".subPageBlock h2").css({"height":maxheight+"px"});

	});

	$j(".SubpageContainer .container").each(function(index){
		var blue = $j(this).find(".subPageBlock.blue");
		var red = $j(this).find(".subPageBlock.red");
		var grey = $j(this).find(".subPageBlock.grey");		
		
		var maxheight = Math.max(blue.height(),red.height(),grey.height());
		
		$j(this).find(".subPageBlock").css({"height":maxheight+"px"});

	});
	
	
	/*setion1*/
	$j(".CarouselList").each(function(i1){
									  
		$j(this).find(".center .Productlinks li:nth-child(2n)").each(function(i2){
			
			var maxheight = 0;
			var elem1 = $j(this).parent().find("li:eq("+(2*i2)+") a");
			var elem2 = $j(this).parent().find("li:eq("+(2*i2+1)+") a");
			
			maxheight = Math.max(elem1.height(),elem2.height());
			
			elem1.height(maxheight);
			elem2.height(maxheight);

		});

	});
	
	$j(".CarouselList .FoldablePanel").each(function(index){
		if(index == 0)
		{
			$j(this).css({"display":"block"});
			$j(this).parent().toggleClass("active");
		}
		else
			$j(this).css({"display":"none"});
	});
	/*end setion1*/	
	
	/*blog, news*/
/*	var h1 = $j(".homeLatestBlog .LatestBlogArticle").height();
	var h2 = $j(".homeLatestNews").height();
	var h = (h1>h2)?h1:h2;
	$j(".homeLatestBlog .LatestBlogArticle .content,.homeLatestNews .LatestNews .content").height(h-30);
/*	$j(".homeLatestNews .LatestNews").height(h-20);
	$j(".homeLatestNews .LatestNews .content").height(h-70);
	*/
	
	
}

function init_margins()
{
	var height = $j(".findJQHeight").outerHeight();
	height -= 35;
	
	if (height>0)
	{
		$j(".RelatedPanel").animate({
			marginTop:height
		},1000)
				
		//$j(".RelatedPanel").css({"margin-top":height+"px"});
	}
	//$j(".RelatedPanel").css({"visibility":"visible"});
	
}

$j(document).ready(function(){
	init_margins();
	init_search();
	init_height();
	init_corner();


	
	$j(".FooterCol3 select").change(function(){
		window.open($j(this).val());
	});
	
	if ($j.browser.msie && $j.browser.version < 9)
	{

		$j(".FooterCol3 select").mouseover(function(){
				if ($j(this).width()<180)													
					$j(this).animate({width:195},"slow");
			})
	}

   
	//for texts hide/show element e.g.http://sc62/el/Products/Business/Epixeirhsh/Business%20Care
	$j("a.hiddenTriger").click(function(){
		var classes = $j(this).attr("class").split(" "); //dBnone list list1
		
		if ($j("ul."+classes[1]).is(":visible")==true)
			$j("ul."+classes[1]).hide();
		else
			$j("ul."+classes[1]).show();			
	});

	
	$j("a img").parent().css("display","block");
	

});
