﻿/*<![CDATA[*/

/*****************************************************************************
//-> START Window Load
*****************************************************************************/

$(document).ready(function(){

	// Submit the form

	$("input#firstReg").click(function () {
		if(checkFirstPassword("form.first-reg-form")){
			$("form.first-reg-form").submit();
		}else{
			return false;
		}
	});



	// Submit the form
	$("input#sKvoaa").click(function () {
		if(confirm_kvoaa()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sHakpaha").click(function () {
		if(confirm_hakpaha()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#eHakpaha").click(function () {
		if(confirm_hakpaha()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sShotef").click(function () {
		if(confirm_Shotef()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sChangePass").click(function () {
		if(confirm_ChangePass()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sGvia").click(function () {
		if(confirm_UpdateGvia()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sGvia1").click(function () {
		if(confirm_UpdateGvia()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});


	$("input#sPersonal").click(function () {
		if(confirm_UpdatePersonal()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sMessage").click(function () {
		if(confirm_UpdateMessage()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sMaslul").click(function () {
		if(confirm_UpdateMaslul()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sMaslul1").click(function () {
		if(confirm_UpdateMaslul()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#sMivza").click(function () {
		if(confirm_Mivza()){
			$("form.myAccount-frm").submit();
		}else{
			return false;
		}
	});

	$("input#dMivza").click(function () {
		if(confirm_deleteMivza()){
			$("form#myAccount-frm1").submit();
		}else{
			return false;
		}
	});


		// Submit the form via select elements
	$("select.selectbox").change(function () {
		$("form.myAccount-frm").submit();
	});

		// Submit the form via select elements
	$("select#selectcsv").change(function () {
		if (document.getElementById("selectcsv").value != "0")
		$("form.csv-frm").submit();
	});

// --> 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;
			}
		});
	});





// --> 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
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:800,
		pauseTime:6000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //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:true, //Use left & right arrows
		pauseOnHover:true, //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
	});

// --> 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
*****************************************************************************/

/*]]>*/


 	function OpenWin(link)
	{
		 window.open("show_product.asp?pid="+link,'myWindow', 'toolbar=no, menubar=no,scrollbars=no, resizable=yes, location=no, directories=no,width=800, height=500,top=150,left=150')
  	}


	function confirm_kvoaa(){
	input_box=confirm("? האם לעדכן את ההזמנה הקבועה");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
			$("form.myAccount-frm").submit();
	}else{
		// Output when Cancel is clicked
		alert ("! הזמנתך הקבועה לא עודכנה");
	}
}

function confirm_Shotef(){
	input_box=confirm("? האם לעדכן את ההזמנה השוטפת");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! הזמנתך השוטפת לא עודכנה");
	}
}

function confirm_ChangePass(){
	input_box=confirm("? האם לעדכן את פרטי ההתחברות לחשבון");
	if (input_box==true){

			if (document.getElementById("current_Password").value == "")
			{
				alert("! נא למלא שדה סיסמה נוכחית");
				document.getElementById("current_Password").focus();
				return false;
			}

			if (document.getElementById("lname").value == "")
			{
				alert("! נא למלא שדה שם משפחה");
				document.getElementById("lname").focus();
				return false;
			}

      if (document.getElementById("emailI").value == "")
			{
				alert("! נא למלא שדה דוא\"ל");
				document.getElementById("emailI").focus();
				return false;
			}
			var i=document.getElementById("emailI").value.indexOf("@");
			if (i == -1)
			{
				alert("! כתובת דוא\"ל לא חוקית");
				document.getElementById("emailI").focus();
				document.getElementById("emailI").select();

				return false;
			}
			if (document.getElementById("emailI").value.indexOf(".",i) == -1)
			{
				alert("! כתובת דוא\"ל לא חוקית");
				document.getElementById("emailI").focus();
				document.getElementById("emailI").select();
				return false;
			}

		//	if (document.getElementById("username").value.length < 2)
		//	{
		//		alert("!שם המשתמש חייב להיות באורך של לפחות 2 תוים");
		//		document.getElementById("username").focus();
		//		return false;
		//	}
			pass=document.getElementById("pass1").value;
			if (pass == "")
			{
				alert("! נא למלא שדה סיסמה חדשה");
				document.getElementById("pass1").focus();
				return false;
			}
			if (pass.length < 2)
			{
				alert("!הסיסמה חייבת להיות באורך של לפחות 6 תוים ויכולה להכיל אותיות באנגלית וספרות בלבד");
				document.getElementById("pass1").focus();
				document.getElementById("pass1").select();
				return false;
			}
			chrs="0123456789abcdefghijklmnopqrstuvwxyz";
			pass_ok=true;
			for (i=0; i<pass.length; i++)
			{
				if (chrs.indexOf(pass.charAt(i).toLowerCase()) == -1)
				{
					pass_ok=false;
					break;
				}
			}
			if (!pass_ok)
			{
				alert("! הסיסמה חייבת להיות באורך של לפחות 6 תוים ויכולה להכיל אותיות באנגלית וספרות בלבד");
				document.getElementById("pass1").focus();
				document.getElementById("pass1").select();
				return false;
			}
			pass2=document.getElementById("pass2").value;
			if (pass2 == "")
			{
				alert("! נא למלא שדה אימות סיסמה חדשה");
				document.getElementById("pass2").focus();
				return false;
			}
			if (pass != pass2)
			{
				alert("! שדה אימות סיסמה חדשה אינו תואם לשדה סיסמה חדשה");
				document.getElementById("pass1").value="";
				document.getElementById("pass2").value="";
				document.getElementById("pass1").focus();
				return false;
			}

			return true;
	}else{
		// Output when Cancel is clicked
		alert ("! פרטי החשבון לא עודכנו");
	}
}

function confirm_hakpaha(){
	input_box=confirm("? האם לעדכן את תקופת ההקפאה");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! ההקפאה לא עודכנה");
	}
}

function confirm_UpdateGvia(){
	input_box=confirm("? האם לעדכן את דוח הגבייה");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! דוח הגבייה לא עודכן");
	}
}

function confirm_UpdatePersonal(){
	input_box=confirm("? האם לעדכן את פרטי הלקוח");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! פרטי הלקוח לא עודכנו");
	}
}

function confirm_UpdateMessage(){
	input_box=confirm("? האם לעדכן את ההודעות לקו");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! הודעות לקו לא עודכנו");
	}
}

function confirm_UpdateMaslul(){
	input_box=confirm("? האם לעדכן את פרטי הרחוב במסלול");

	u = document.forms['myAccount-frm'].u.value;
	//alert(u);

	if (document.getElementById("orderNum_" + u).value == "")
	{
		alert("! נא למלא שדה מיקום בתיבת הטקסט אותה את/ה מעדכן");
		document.getElementById("orderNum_" + u).focus();
		return false;
	}


	pass=document.getElementById("orderNum_" + u).value;
	chrs="0123456789";
	pass_ok=true;
	for (i=0; i<pass.length; i++)
	{
		if (chrs.indexOf(pass.charAt(i).toLowerCase()) == -1)
		{
			pass_ok=false;
			break;
		}
	}
	if (!pass_ok)
	{
		alert("! פרטי מיקום הרחוב במסלול הם בספרות בלבד");
		document.getElementById("orderNum_" + u).focus();
		document.getElementById("orderNum_" + u).select();
		return false;
	}



	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! פרטי הרחוב במסלול לא עודכנו");
	}
}


function ChangeStatus(recordNum,maxRec){
//document.forms['myAccount-frm'].myinput.disabled = true;
	//alert(NumStr)

	for (i=0; i<=maxRec; i++)
	{
		NumStr = "orderNum_" + i
		selectStr = "selectOrder_" + i

		if (i == recordNum)
		{
			document.getElementById(NumStr).disabled=false;
			document.getElementById(selectStr).disabled=false;
			document.forms['myAccount-frm'].u.value=recordNum;
		}
		else
		{
			document.getElementById(NumStr).disabled=true;
			document.getElementById(selectStr).disabled=true;
		}

	}


}



function confirm_Mivza(){
	input_box=confirm("? האם להוסיף את מוצר המבצע להזמנה השוטפת");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! הזמנתך השוטפת לא עודכנה במוצר המבצע");
	}
}


function confirm_deleteMivza(){
	input_box=confirm("? האם למחוק את מוצר המבצע מהזמנך השוטפת");
	if (input_box==true){
		// Output when OK is clicked
		//alert ("ההזמנה");
		return true;
	}else{
		// Output when Cancel is clicked
		alert ("! מוצר המבצע לא נמחק מהזמנתך השוטפת");
	}
}


		function checkFirstPassword()
		{
			if (document.getElementById("contact_first_pass").value == "")
			{
				alert("!נא למלא שדה סיסמה ראשונית");
				document.getElementById("contact_first_pass").focus();
				return false;
			}

			if (document.getElementById("contact_name").value == "")
			{
				alert("!נא למלא שם משפחה");
				document.getElementById("contact_name").focus();
				return false;
			}

      if (document.getElementById("contact_email").value == "")
			{
				alert("!נא למלא דוא\"ל");
				document.getElementById("contact_email").focus();
				return false;
			}
			var i=document.getElementById("contact_email").value.indexOf("@");
			if (i == -1)
			{
				alert("!כתובת דוא\"ל לא חוקית");
				document.getElementById("contact_email").focus();
				document.getElementById("contact_email").select();
				return false;
			}
			if (document.getElementById("contact_email").value.indexOf(".",i) == -1)
			{
				alert("!כתובת דוא\"ל לא חוקית");
				document.getElementById("contact_email").focus();
				document.getElementById("contact_email").select();
				return false;
			}

		//	if (document.getElementById("username").value.length < 2)
		//	{
		//		alert("!שם המשתמש חייב להיות באורך של לפחות 2 תוים");
		//		document.getElementById("username").focus();
		//		return false;
		//	}
			pass=document.getElementById("contact_pass").value;
			if (pass == "")
			{
				alert("!נא למלא סיסמה");
				document.getElementById("contact_pass").focus();
				return false;
			}
			if (pass.length < 5)
			{
				alert("!הסיסמה חייבת להיות באורך של לפחות 5 תוים ויכולה להכיל אותיות באנגלית וספרות בלבד");
				document.getElementById("pass").focus();
				return false;
			}
			chrs="0123456789abcdefghijklmnopqrstuvwxyz";
			pass_ok=true;
			for (i=0; i<pass.length; i++)
			{
				if (chrs.indexOf(pass.charAt(i).toLowerCase()) == -1)
				{
					pass_ok=false;
					break;
				}
			}
			if (!pass_ok)
			{
				alert("!הסיסמה חייבת להיות באורך של לפחות 5 תוים ויכולה להכיל אותיות באנגלית וספרות בלבד");
				document.getElementById("contact_pass").focus();
				return false;
			}
			pass2=document.getElementById("contact_pass2").value;
			if (pass2 == "")
			{
				alert("!נא למלא סיסמה שנית");
				document.getElementById("contact_pass2").focus();
				return false;
			}
			if (pass != pass2)
			{
				alert("!אימות הסיסמה אינו תואם את הסיסמה");
				document.getElementById("contact_pass").value="";
				document.getElementById("contact_pass2").value="";
				document.getElementById("contact_pass").focus();
				return false;
			}
		if (document.getElementById("first-reg-form").accept.checked == false)
			{
				alert("!נא לאשר את תנאי השימוש");
				document.getElementById("first-reg-form").accept.checked = true;
				return false;
			}

			return true;
		}

