/*<![CDATA[*/
		   
/*****************************************************************************
//-> START Window Load
*****************************************************************************/

$(document).ready(function(){
	
// --> Start Menu
	$("ul.topnav ul").css({display: "none"}); // Opera Fix
	
	$("ul.topnav li.open").each(function(){
										 
		var linkWidth = $(this).find('a').width();
		var ulWidth = linkWidth+80;
		var aWidth = linkWidth+72;
		//var flag = $("a.title.selected");
		$(this).find('ul').css({"width":ulWidth});
		$(this).find('ul li a').css({"width":aWidth});
		
		$(this).hover(function(){
				//$(this).find('a.title, bdo').css({"background":"#d7edce"}).parent().parent().filter(".open").prepend('<div class="white"></span>');
				//$(this).filter(".open").css({"padding": "0px 0px 14px 0px"});
				//$(this).find('a.title').css({"line-height": "14px"});
				$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown("fast");
			},function(){
				if(!$(this).find('a.title.selected').is("a.title.selected")){
					//$(this).find('a.title, bdo').css({"background":"#ffffff"});
				}
				//$(this).find('a.title, bdo').parent().parent().find(".white").remove();
				//$(this).filter(".open").css({"padding": "0px"});
				//$(this).find('a.title').css({"line-height": "14px"});
				$(this).find('ul:first').css({visibility: "hidden"});
		});
	});
	
// --> Start Filter-Form
	$("fieldset.filter-form div").each(function(){
		var flag = true;
		$(this).find("input[type=checkbox]:first").click(function () {
			if(flag){											 
				$(this).parent().nextAll().find(":checkbox").attr('checked', true);
				flag = false;
			}else{
				$(this).parent().nextAll().find(":checkbox").attr('checked', false);
				flag = true;
			}
		});
	});
	// Submit the form
	$("a.sbutton").click(function () {
		$("form.parent-form").submit();
	});

	// Submit the form via select elements
	$("form#language").change(function () {
		$("form#language").submit();
	});
	
// --> Remove top border from first item
	$("div.content div.section:first").css({"border-top":"0px none"});

	//var conHeight = $("div.box.vid").children("img.cont").height();
	
// --> White Patch on item.asp
    var totalHeight = 0;
	$("div.box.vid img.cont").each(function(){
		totalHeight += $(this).height() + 5;
		//console.log(totalHeight);
		$("div.box.vid img.patch").css({"height":(totalHeight+5)});
	});	
	

// --> Print Page
	$('a.printMe').click(function() {  
		window.print();  
	}); 

/*
// --> Start Sub Menu
	$('#sub-menu ul').hide();
	$('#sub-menu ul:first').show();
	$('#sub-menu li a.lnk').click(
		function() {
			
			var checkElement = $(this).next();
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#sub-menu ul:visible').slideUp('normal',function() {
					$(this).prev().removeClass("selected");
				});
				checkElement.slideDown('normal',function() {
					$(this).prev().addClass("selected");
				});
				return false;
			}
		}
	);
*/
// --> Start Sub Menu
	$('#sub-menu ul').hide();
	$('#sub-menu ul.on').show();
	$('#sub-menu li a.lnk').click(
		function() {
			
			var checkElement = $(this).next();
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#sub-menu ul:visible').slideUp('normal').prev().removeClass("selected");
				checkElement.slideDown('normal').prev().addClass("selected");
				return false;
			}
		}
	);

// --> Start Cycle
	
	// Init hp sale scroll
	$('#col_a #col_a_left div.slider').cycle({ 
	    fx: 'scrollVert',
		speed: 850,
		rev: true,
		timeout: 6000,
		cleartypeNoBg: true
	});
	// Init hp recommendations scroll
	$('div.hp-recommendations div.slider').cycle({ 
	    fx: 'scrollVert',
		speed: 850,
		rev: true,
		timeout: 6000,
		cleartypeNoBg: true
	});

// --> Init hp sale Image cycle
	$("#col_a #col_a_left div.slider-img").cycle({ 
		fx:     'fade', 
		speed:  850, 
		timeout: 6000, 
		sync:1,
		cleartypeNoBg: true
	});	
	
// --> Init Image cycle
	$("#top-content-right").cycle({ 
		fx:     'fade', 
		speed:  2500, 
		timeout: 5000, 
		sync:1,
		 cleartypeNoBg: true
	});	
	
	// --> Disable filter property because of IE opacity bug
	if($.browser.name == "msie"){
		$("div.slider-img img").css({"filter":"none"});
	}
	// --> END Disable
	
// --> Init LightBoxes
	// --> Init FancyBox
	$("a[rel*='pop']").fancybox({
		titleShow		:false,
		transitionIn	:'elastic',
		transitionOut	:'elastic',
		easingIn		:'easeOutBack',
		easingOut		:'easeInBack',
		overlayOpacity	:0.0
	});
	// --> Init FancyBox
	$("a[rel*='swf']").fancybox({
		titleShow		:false,
		transitionIn	:'elastic',
		transitionOut	:'elastic',
		easingIn		:'easeOutBack',
		easingOut		:'easeInBack',
		overlayOpacity	:0.0,
		type: 'swf',
		//href: this.getAttribute('longdesc'),
		width: 480,
		height: 326,
		swf: {
			loop: true,
			menu: false,
			scale: 'exactfit',
			quality: 'best',
			allowScriptAccess: 'sameDomain',
			wmode: 'transparent',
			allowFullScreen: true
		}
	});
	// --> Init FancyBox
	$("a[rel*='inline']").fancybox({
		titleShow		:false,
		transitionIn	:'elastic',
		transitionOut	:'elastic',
		easingIn		:'easeOutBack',
		easingOut		:'easeInBack',
		overlayOpacity	:0.0,
		type: 'inline'
	});
	// --> Init FancyBox
	$("a[rel*='ajax']").fancybox({
		titleShow		:false,
		transitionIn	:'elastic',
		transitionOut	:'elastic',
		easingIn		:'easeOutBack',
		easingOut		:'easeInBack',
		overlayOpacity	:0.0,
		type: 'ajax'
	});
	// --> Init FancyBox
	$("a[rel*='youtube']").each(function(){
		$(this).fancybox({
			titleShow		:false,
			transitionIn	:'elastic',
			transitionOut	:'elastic',
			easingIn		:'easeOutBack',
			easingOut		:'easeInBack',
			overlayOpacity	:0.0,
			type: 'swf',
			href : $(this).attr("href").replace(new RegExp("watch\\?v=", "i"), 'v/'),
			type      : 'swf',
			swf       : {'wmode':'transparent','allowfullscreen':'true'}

		});
	});

// --> START FAQ's
	$("dl.faq").find('dd').hide().end().find('dt').append('<span class="expand">+ הראה</span>')
		.toggle(function(){
			$(this).find('span').attr('class','collapse').html('- הסתר').end()
			.next('dd').slideDown()
			.prev('dt').attr('class','selected').end();
		},function(){
			$(this).find('span').attr('class','expand').html('+ הראה').end()
			.next('dd').slideUp()
			.prev('dt').removeAttr('class').end();
		});
	
// --> Start Project slider
	$('#left-image').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:800,
		pauseTime:6000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:false, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	
// --> Init Facebook Plugin
	$("div#facebook").append('<fb:like-box href="http://www.facebook.com/Camp.Kimama.Israel" width="268" show_faces="true" stream="false" header="false"></fb:like-box>');
	
	
// --> Start Disable '#' links from being clicked
	$("a[href^='#']").click(function() {
		return false;
	});

// --> Init External Links
	$("a[rel*='external']").attr("target","_blank");
	
// --> Stripping a tags with: class="remove"
	$("a[class*='strip']").each(function(){
		$(this).replaceWith($(this).html()); 
	});
	
// --> Init SPAM Email links
	$("a[href^='mailto:']").each(function(){
		var mail = $(this).attr("href").replace("mailto:","");
		var replaced = mail.replace("/at/","@");
		$(this).attr("href","mailto:"+replaced);
		if($(this).text() == mail){ 
			$(this).text(replaced);
		}
	});

});

/*****************************************************************************
//-> END Window Load
*****************************************************************************/

/*]]>*/
