timerID = 0;
currentItem = 0;

function replacetxt(str,rt,repwith){
	str=str+"";
	if(str.indexOf(rt)!=-1){
		i=0;
		temp="";
		while(str.split(rt)[i]+""!="undefined"){
			if(str.split(rt)[i+1]+""!="undefined"){
				temp=temp+str.split(rt)[i]+repwith;
			}else{
				temp=temp+str.split(rt)[i]+""
			}
			i++;
		}
		return temp;
	}else{
		return str;
	}
}

function setLoadingPosition(){
	//$("cart_loading").style.left = (getWindowSize("width")-364)/2 +"px";
	//$("cart_loading").style.top = (getWindowSize("height")-118)/2 +"px";
}

function getWindowSize(what){
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	if(what=="width"){
		return x;
	}else{
		return y;
	}
}

function afterLoading(q, ci){
	$("cart_info_ifrm").style.height = (40+(q*23))+"px";
	if($("cart_loading")){
		timerID=setTimeout('$("cart_loading").style.display="none"',1000);
	}
	cart_info = ci;
}

function stop(e) {
	if (!e) e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function showSubMenu(id){
	for(x=1;x<totalSubCats;x++){
		//alert(x+"="+id);
		if(x==id){
			Effect.BlindDown("sc"+x);
			//$("sc"+x).style.display= "";
		}else{
			$("sc"+x).style.display="none";
		}
	}
}

function closeSubMenu(id){
	Effect.BlindUp("sc"+id);
	//$("sc"+id).style.display="none";
}

function chkSearch(){
	$("error_search").style.display = "none";
	if($("q").value.length<3){
		//alert("טקסט לחיפוש קצר מידי, מינימום 3 תווים");
		$("error_search").innerHTML = "טקסט לחיפוש קצר מידי<br>לפחות 3 תווים"
		Effect.BlindDown("error_search");
		return false;
	}
}

function chkSearch2(){
	$("error_search").style.display = "none";
	if($("s_item").value.length<2 && $("s_tags").value=="0" && $("s_price").value=="0"){
		$("error_search").innerHTML = "אנא הזינו לפחות קריטריון אחד לחיפוש"
		Effect.BlindDown("error_search");
		return false;
	}
}

function chkContact(){
	$("error_contact").style.display = "none";
	if($("c_name").value.length<2 && $("c_phone").value.length<9){
		$("error_contact").innerHTML = "<b>אנא הזינו שם מלא וטלפון כולל קידומת</b>"
		Effect.BlindDown("error_contact");
		return false;
	}
}
function cuttxt(str, dl){
	str=str+"";
	if(str.length > dl){
		str = str.substring(0,dl) 
		while(str.charAt(str.length-1)!=" "){
			dl--;
			str = str.substring(0,dl) 
		}
		str+= "...";
	}
	return (str);
}

function showBigPic(did, ac, pic, aid, cid, pid, title){
	if(ac=="show"){
		for(x=1;x<totalItems;x++){
			if(did==x){
				//alert("hi");
				$('item'+x).style.zIndex = 100;
			}else{
				$('item'+x).style.zIndex = 1;
				//$('item_bigpic'+x).style.display = "none";
			}
		}
		$('header').style.zIndex = 9;
		$('main').style.zIndex = 10;
		$('item_bigpic'+did).style.display = '';
		if (did!=currentItem){
			var url = "shrink_ajax.asp?path="+pic+"&width=400&height=300"; 
			new Ajax.Request(url, {   
				method: 'get',   
				onSuccess: function(transport) {     
					$('item_bigpic_place'+did).innerHTML = transport.responseText;
				}
			}); 
		}	
		currentItem = did;
	}else{
		for(x=1;x<totalItems;x++){
			$('item'+x).style.zIndex = 1;
			$('item_bigpic'+x).style.display = 'none';
		}
		$('main').style.zIndex = 9;
		$('header').style.zIndex = 10;
		$('item_bigpic'+did).style.display = 'none';
	}
}

function showPic(ac, pic, did){
	if(ac=="show"){
		$('header').style.zIndex = 8;
		$('main').style.zIndex = 9;
		$('item_pic').style.display = '';
		if (did!=currentItem){
			var url = "shrink_ajax.asp?path="+pic+"&width=400&height=300"; 
			new Ajax.Request(url, {   
				method: 'get',   
				onSuccess: function(transport) {     
					$('item_bigpic_place').innerHTML = transport.responseText;
				}
			}); 
		}	
	}else{
		$('main').style.zIndex = 8;
		$('header').style.zIndex = 9;
		$('item_pic').style.display = 'none';
	}
}

function showPicB(pic){
	window.open("pics/"+pic);
}

function setTags(tags){
	i=0;
	while(tags.split(", ")[i]+"" != "undefined"){
		if(tags.split(", ")[i].indexOf(",")==-1){
			//alert(tags.split(", ")[i])
			document.write("<li><a href=\"cat_search.asp?s=3&q="+tags.split(", ")[i]+"\">"+tags.split(", ")[i]+"</a></li>");
		}else{
			x=0;
			while(tags.split(", ")[i].split(",")[x]+"" != "undefined"){
				document.write("<li><a href=\"cat_search.asp?s=3&q="+tags.split(", ")[i]+"\">"+tags.split(", ")[i].split(",")[x]+"</a></li>");
				x++;
			}
		}
		i++;
	}
}
tmpPayment = ""
tmpDelivery = ""
tmpCard = ""
tmpFreeText = ""

same_destination = 1;
after_submit_check=0;
current_step = 1;
cart_info = "";
cart_info_big = "";
delivery = new Array(39,39,0);
delivery_name = new Array("באמצעות שליח","דואר רשום","איסוף עצמי");

delivery_type = "";
delivery_cost = "";

function setDelivery(d_type){
	delivery_type = delivery_name[d_type];
	delivery_cost = delivery[d_type];
	
	tp = parseInt($('total_price').value)+ parseInt(delivery[d_type]);
	
	tmpPaymentSRC = ""
	if($('payments')){
		p_selected = $('payments').value;
	} 
	tmpPaymentSRC += "<select name=\"payments\" id=\"payments\" onfocus=\"setBorders(this.id,'focus');\" onblur=\"setBorders(this.id,'blur');\"><option value=\"1\" selected>1 תשלומים</option><option value=\"2\">2 תשלומים</option></select>"
								
	$('payment_src').innerHTML = tmpPaymentSRC;
	if(typeof p_selected != "undefined"){
		$('payments').value = p_selected;
	}
}

function setDest(act){
	if(act==1){
		if(same_destination==1){
			$("d_fname").value = $("p_fname").value
			$("d_lname").value = $("p_lname").value
			$("d_phone").value = $("p2_phone").value
			$("d_address").value = $("p_address").value
		}
	}else{
		if($("dest_cb").checked == true){
			same_destination = 1;
			$("d_fname").disabled = true;
			$("d_lname").disabled = true;
			$("d_phone").disabled = true;
			$("d_address").disabled = true;
			$("d_fname").value = $("p_fname").value
			$("d_lname").value = $("p_lname").value
			$("d_phone").value = $("p2_phone").value
			$("d_address").value = $("p_address").value
		}else{
			same_destination = 0;
			$("d_fname").disabled = false;
			$("d_lname").disabled = false;
			$("d_phone").disabled = false;
			$("d_address").disabled = false;
			$("d_fname").value = "";
			$("d_lname").value = "";
			$("d_phone").value = "";
			$("d_address").value = "";
		}
	}
	colorErrors();
}

function setCard(){
	if($("card_cb").checked == true){
		$("p_card").disabled = false;
	}else{
		$("p_card").disabled = true;
		$("p_card").value = "";
	}
	colorErrors();
}

function colorErrors(){
	if(after_submit_check==1){
		switch(current_step){
			case 1:
				$('p_fname').style.backgroundColor = "#fff";
				$('p_lname').style.backgroundColor = "#fff";
				$('p2_phone').style.backgroundColor = "#fff";
				$('p_email').style.backgroundColor = "#fff";
				$('p_address').style.backgroundColor = "#fff";
				$('p_id').style.backgroundColor = "#fff";
				$('issuer').style.backgroundColor = "#fff";
				$('ccno').style.backgroundColor = "#fff";
				$('p_sec').style.backgroundColor = "#fff";
				$('d_fname').style.backgroundColor = "#fff";
				$('d_lname').style.backgroundColor = "#fff";
				$('d_phone').style.backgroundColor = "#fff";
				$('d_address').style.backgroundColor = "#fff";
				break;
				
			case 2:
				$('p_card').style.backgroundColor = "#fff";
				break;
		}
		after_submit_check=0;
	}
}

function setBorders(item, act){
	colorErrors()
	if(act=="focus"){
		$(item).style.border = "2px solid #821933";
	}else{
		$(item).style.border = "1px solid #ffa97f";
	}
}

function JustSetBorders(item, act){
	if(act=="focus"){
		$(item).style.border = "2px solid #b5bf00";
	}else{
		$(item).style.border = "1px solid #ffa97f";
	}
}

function cartPrev(step, item_focus){
	setTabs(step)
	if(item_focus){
		$(item_focus).focus();
	}
}

function cartNext(step, cartid){
	switch (step){
		case 1:
			colorErrors()
			tmpERR = "";
			if($('p_fname').value.length<2){
				tmpERR += "<li>שם פרטי קצר מידי</li>";
				$('p_fname').style.backgroundColor = "red";
				
			}
			if($('p_lname').value.length<2){
				tmpERR += "<li>שם משפחה קצר מידי</li>";
				$('p_lname').style.backgroundColor = "red";
			}
			if($('p2_phone').value.length<9){
				tmpERR += "<li>מספר טלפון קצר מידי - לפחות 9 תווים</li>";
				$('p2_phone').style.backgroundColor = "red";
			}
			if(!emailCheck($('p_email').value)){
				tmpERR += "<li>כתובת דואר אלקטרוני לא חוקית</li>";
				$('p_email').style.backgroundColor = "red";
			}
			if($('p_address').value.length<9){
				tmpERR += "<li>כתובת למשלוח חשבונית קצרה מידי</li>";
				$('p_address').style.backgroundColor = "red";
			}
			if($('p_id').value.length<9){
				tmpERR += "<li>ת&quot;ז קצרה מידי - לפחות 9 תווים</li>";
				$('p_id').style.backgroundColor = "red";
			}
			if($('issuer').value=="0"){
				tmpERR += "<li>אנא בחרו סוג כרטיס אשראי</li>";
				$('issuer').style.backgroundColor = "red";
			}
			if($('ccno').value.length<15){
				tmpERR += "<li>מספר כרטיס אשראי קצר מידי - לפחות 15 תווים</li>";
				$('ccno').style.backgroundColor = "red";
			}
			if($('p_sec_cb').checked==false && $('p_sec').value.length<1){
				tmpERR += "<li>אנא הזינו 3 ספרות בגב כרטיס האשראי</li>";
				$('p_sec').style.backgroundColor = "red";
			}
			if($('d_fname').value.length<2){
				tmpERR += "<li><b>פרטי משלוח</b> &raquo; שם פרטי קצר מידי</li>";
				$('d_fname').style.backgroundColor = "red";
				
			}
			if($('d_lname').value.length<2){
				tmpERR += "<li><b>פרטי משלוח</b> &raquo; שם משפחה קצר מידי</li>";
				$('d_lname').style.backgroundColor = "red";
			}
			if($('d_phone').value.length<9){
				tmpERR += "<li><b>פרטי משלוח</b> &raquo; מספר טלפון קצר מידי - לפחות 9 תווים</li>";
				$('d_phone').style.backgroundColor = "red";
			}
			if($('d_address').value.length<9){
				tmpERR += "<li><b>פרטי משלוח</b> &raquo; כתובת למשלוח קצרה מידי</li>";
				$('d_address').style.backgroundColor = "red";
			}
			if(tmpERR==""){
				setTabs(2)
			}else{
				$('d_err_text').innerHTML = "<p><h1>פרטים חסרים...</h1><b>חסרים לנו מספר פרטים על מנת להשלים את תהליך ההזמנה.</b><br>אנא מלאו את הפרטים החסרים ולחצו <b>'המשך'</b></p><p>להלן הפרטים החסרים בטופס:<ol>"+tmpERR+"</ol></p><p style='font-size: 16px; color: #ff5400;'>לחצו <span style='font-weight: bold; text-decoration: underline; cursor:pointer; cursor:hand;'>כאן</span> להמשך</p>";
				$('d_err').style.display="";
			}
			after_submit_check = 1;
			break;
			
		case 2:
			colorErrors()
			tmpERR = "";
			if($('card_cb').checked == true && $('p_card').value==""){
				tmpERR += "<li>סימנתם כי ברצונכם לצרף ברכה, אך לא הקלדתם אחת.<br>אם אינכם רוצים שתצורף ברכה למשלוח, הסירו את הסימון מתיבת הבחירה</li>";
				$('p_card').style.backgroundColor = "red";
			}
			if(tmpERR==""){
				buildCartInfo();
				$('approve_cb').checked=false;
				setTabs(3)
			}else{
				$('d_err_text').innerHTML = "<p><h1>פרטים חסרים...</h1><b>חסרים לנו מספר פרטים על מנת להשלים את תהליך ההזמנה.</b><br>אנא מלאו את הפרטים החסרים ולחצו <b>'המשך'</b></p><p>להלן הפרטים החסרים בטופס:<ol>"+tmpERR+"</ol></p><p style='font-size: 16px; color: #ff5400;'>לחצו <span style='font-weight: bold; text-decoration: underline; cursor:pointer; cursor:hand;'>כאן</span> להמשך</p>";
				$('d_err').style.display="";
			}
			after_submit_check = 1;
			break;
		
		case 3:
			tmpERR = "";
			if($('approve_cb').checked == false){
				tmpERR += "<li>אתם חייבים לאשר כי עברתם על כל הפרטים בעמוד זה, <b>ואישרתם לבצע הזמנה</b> על פי פרטים אלו.</li>";
				$('p_card').style.backgroundColor = "red";
			}
			if(tmpERR==""){
				//GO!
				tmpCC = $('ccno_holder').innerHTML+"";
				tmpCCHeader = ""
				for(x=1;x<tmpCC.length-3;x++){
					tmpCCHeader += "*";
				}
				//$('ccno_holder').innerHTML = tmpCC.length
				$('ccno_holder').innerHTML = tmpCCHeader + "-" + tmpCC.substr(tmpCC.length-4,tmpCC.length-1);
				
				$('cartid').value = cartid;
				$('i_cart').value = cart_info_big ;
				$('i_payment').value = $('payment_details').innerHTML ;
				$('i_delivery').value = $('delivery_details').innerHTML ;
				if($("card_cb").checked == true && $('p_card').value!=""){
					$('i_card').value = $('card_details').innerHTML ;
				}else{
					$('i_card').value = "";
				}
				if($('p_freetext').value!=""){
					$('i_freetext').value = $('freetext_details').innerHTML ;
				}else{
					$('i_freetext').value = "" ;
				}
				
				$('d_err').onclick = "";
				$('d_err_text').innerHTML = "<p><h1>אנא המתן...</h1><b>פרטי התשלום נבדקים מול חברת האשראי</b></p><p>התהליך אמור לקחת מספר שניות ובסיומו תקבלו הודעה.</p><p><b>אנא המתינו...</b></p>";
				$('d_err').style.display="";
				
				$('frmOrder').action = "processOrder.asp?step=1";
				$('frmOrder').target = "cart_info_ifrm"
				$('frmOrder').submit();
				
			}else{
				$('d_err_text').innerHTML = "<p><h1>פרטים חסרים...</h1><b>חסרים לנו מספר פרטים על מנת להשלים את תהליך ההזמנה.</b><br>אנא מלאו את הפרטים החסרים ולחצו <b>'אישור הזמנה'</b></p><p>להלן הפרטים החסרים בטופס:<ol>"+tmpERR+"</ol></p><p style='font-size: 16px; color: #ff5400;'>לחצו <span style='font-weight: bold; text-decoration: underline; cursor:pointer; cursor:hand;'>כאן</span> להמשך</p>";
				$('d_err').style.display="";
			}
			after_submit_check = 1;
			break;
	}
}

function setTabs(step){
	current_step = step;
	switch(step){
		case 1:
			$('tab1').style.display = '';
			$('tab1_hd').src = 'images/cart_co1_on.png';
			$('tab3').style.display = 'none';
			$('tab3_hd').src = 'images/cart_co3.png';
			$('tab2').style.display = 'none';
			$('tab2_hd').src = 'images/cart_co2.png';
			break;
			
		case 2:
			$('tab1').style.display = 'none';
			$('tab1_hd').src = 'images/cart_co1.png';
			$('tab3').style.display = 'none';
			$('tab3_hd').src = 'images/cart_co3.png';
			$('tab2').style.display = '';
			$('tab2_hd').src = 'images/cart_co2_on.png';
			break;
			
		case 3:
			$('tab1').style.display = 'none';
			$('tab1_hd').src = 'images/cart_co1.png';
			$('tab3').style.display = '';
			$('tab3_hd').src = 'images/cart_co3_on.png';
			$('tab2').style.display = 'none';
			$('tab2_hd').src = 'images/cart_co2.png';
			break;
	}
}

function buildCartInfo(){
	$('p_cart_approve').innerHTML = cart_info;
	tmpPayment = "<div class=\"edit_details\"><a href=\"javascript:cartPrev(1);\" class=\"boxed\">עדכן פרטים &raquo;</a></div><div id=\"payment_details\"><table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">";
		tmpPayment += "<tr>";
			tmpPayment += "<td class=\"tbl_p_right\"><b><u>פרטי תשלום</u></b></td>"
			tmpPayment += "</tr>";
		tmpPayment += "</table>";
		tmpPayment += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">";
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">שם פרטי: </td><td class=\"tbl_p_left\"><b>"+$('p_fname').value+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">שם משפחה: </td><td class=\"tbl_p_left\"><b>"+$('p_lname').value+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">טלפון: </td><td class=\"tbl_p_left\"><b>"+$('p2_phone').value+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">דואר אלקטרוני: </td><td class=\"tbl_p_left\"><b>"+$('p_email').value+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">כתובת למשלוח חשבונית: </td><td class=\"tbl_p_left\"><b>"+replacetxt($('p_address').value,"\n","<br>")+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">מספר ת&quot;ז: </td><td class=\"tbl_p_left\"><b>"+$('p_id').value+"</b></td>"
		tmpPayment += "</tr><tr>";
		
		if($('payments').value == "1"){
			if(delivery_cost !=0){
				tmpPayment += "<td class=\"tbl_p_right\">מספר תשלומים</td><td class=\"tbl_p_left\"><b>"+(parseInt($('total_price').value)+delivery_cost)+" ש&quot;ח בתשלום אחד <font color=#ff0000>*</font><br><small><font color=#ff0000>*</font> הסכום כולל משלוח בעלות "+delivery_cost+" ש&quot;ח</small></b></td>"
			}else{
				tmpPayment += "<td class=\"tbl_p_right\">מספר תשלומים</td><td class=\"tbl_p_left\"><b>"+(parseInt($('total_price').value)+delivery_cost)+" ש&quot;ח בתשלום אחד"
			}
		}else{
			if(delivery_cost != 0){
				tmpPayment += "<td class=\"tbl_p_right\">מספר תשלומים</td><td class=\"tbl_p_left\"><b>"+(parseInt($('total_price').value)+delivery_cost)+" ש&quot;ח ב-2 תשלומים &raquo;<br><small>תשלום 1 <font color=#ff0000>*</font> &raquo; "+((parseInt($('total_price').value)/2)+delivery_cost)+" ש&quot;ח<br><small>תשלום 2 &raquo; "+((parseInt($('total_price').value)/2))+" ש&quot;ח<br><small><font color=#ff0000>*</font> הסכום כולל משלוח בעלות "+delivery_cost+" ש&quot;ח</small></b></td>"
			}else{
				tmpPayment += "<td class=\"tbl_p_right\">מספר תשלומים</td><td class=\"tbl_p_left\"><b>"+(parseInt($('total_price').value)+delivery_cost)+" ש&quot;ח ב-2 תשלומים &raquo;<br><small>תשלום 1 &raquo; "+((parseInt($('total_price').value)/2)+delivery_cost)+" ש&quot;ח<br><small>תשלום 2 &raquo; "+((parseInt($('total_price').value)/2))+" ש&quot;ח<br></td>"
			}	
		} 
		tmpPayment += "</tr><tr>";
			switch($('issuer').value){
				case "1":
					tmpIssuer = "ישראכרד / מסטרקארד";
					break;
				case "2":
					tmpIssuer = "ויזה";
					break;
				case "3":
					tmpIssuer = "דיינרס";
					break;
				case "4":
					tmpIssuer = "אמריקן אקספרס";
					break;
				case "6":
					tmpIssuer = "לאומי כרד";
					break;
			}
			tmpPayment += "<td class=\"tbl_p_right\">סוג כרטיס אשראי: </td><td class=\"tbl_p_left\"><b>"+tmpIssuer+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">מספר כרטיס אשראי: </td><td class=\"tbl_p_left\"><b><span id=\"ccno_holder\" dir=\"ltr\">"+$('ccno').value+"</span></b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\">תאריך תפוגה: </td><td class=\"tbl_p_left\"><b>"+$('expmonth').value+"/"+$('expyear').value+"</b></td>"
		tmpPayment += "</tr><tr>";
			tmpPayment += "<td class=\"tbl_p_right\" nowrap>3 ספרות בגב הכרטיס: </td><td class=\"tbl_p_left\"><b>"+$('p_sec').value+"</b></td>"
		tmpPayment += "</tr>";
	tmpPayment += "</table></div>"
	$('p_payment_approve').innerHTML = tmpPayment;
	
	tmpDelivery = "<div class=\"edit_details\"><a href=\"javascript:cartPrev(1);\" class=\"boxed\">עדכן פרטים &raquo;</a></div><div id=\"delivery_details\"><table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">";
		tmpDelivery += "<tr>";
			tmpDelivery += "<td class=\"tbl_p_right\"><b><u>פרטי משלוח</u></b></td>"
		tmpDelivery += "</table>"
		tmpDelivery += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">";
		tmpDelivery += "</tr><tr>";
			tmpDelivery += "<td class=\"tbl_p_right\">שם פרטי: </td><td class=\"tbl_p_left\"><b>"+$('d_fname').value+"</b></td>"
		tmpDelivery += "</tr><tr>";
			tmpDelivery += "<td class=\"tbl_p_right\">שם משפחה: </td><td class=\"tbl_p_left\"><b>"+$('d_lname').value+"</b></td>"
		tmpDelivery += "</tr><tr>";
			tmpDelivery += "<td class=\"tbl_p_right\">טלפון: </td><td class=\"tbl_p_left\"><b>"+$('d_phone').value+"</b></td>"
		tmpDelivery += "</tr><tr>";
			tmpDelivery += "<td class=\"tbl_p_right\" nowrap>כתובת למשלוח: </td><td class=\"tbl_p_left\"><b>"+replacetxt($('d_address').value,"\n","<br>")+"</b></td>"
		tmpDelivery += "</tr><tr>";
			if(delivery_cost != 0){
				tmpDelivery += "<td class=\"tbl_p_right\" nowrap>סוג משלוח: </td><td class=\"tbl_p_left\"><b>"+delivery_type+" - בעלות של " + delivery_cost +" ש&quot;ח</b></td>"
			}else{
				tmpDelivery += "<td class=\"tbl_p_right\" nowrap>סוג משלוח: </td><td class=\"tbl_p_left\"><b>"+delivery_type+"</b></td>"
			}
		tmpDelivery += "</tr>";
	tmpDelivery += "</table></div>"
	$('p_delivery_approve').innerHTML = tmpDelivery;
	
	tmpCard = "<div class=\"edit_details\"><a href=\"javascript:cartPrev(2,'p_card');\" class=\"boxed\">עדכן ברכה &raquo;</a></div><div id=\"card_details\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><b><u>ברכה מצורפת</u></b></td></tr></table>";
	$('p_card').value
	if($("card_cb").checked ==true && $('p_card').value!=""){
		$('p_card_approve').innerHTML=replacetxt(tmpCard+$('p_card').value+"</div>","\n","<br>");
		$('ta_2').style.display = '';
	}else{
		$('ta_2').style.display = 'none';
	}
	
	tmpFreeText = "<div class=\"edit_details\"><a href=\"javascript:cartPrev(2,'p_freetext');\" class=\"boxed\">עדכן הערות &raquo;</a></div><div id=\"freetext_details\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><b><u>הערות</u></b></td></tr></table>";
	if($('p_freetext').value!=""){
		$('p_freetext_approve').innerHTML=replacetxt(tmpFreeText+$('p_freetext').value+"</div>","\n","<br>");
		$('ta_3').style.display = '';
	}else{
		$('ta_3').style.display = 'none';
	}
	
	$('delivery_cost').value = delivery_cost;
}

function setTabApprove(tab){
	switch(tab){
		case "ta_1":
			$('p_cart_approve').style.display = ''
			$('ta_1').style.backgroundColor = "#b5bf00"
			$('p_card_approve').style.display = 'none'
			$('ta_2').style.backgroundColor = "#ff5400"
			$('p_freetext_approve').style.display = 'none'
			$('ta_3').style.backgroundColor = "#ff5400"
			break;
		case "ta_2":
			$('p_cart_approve').style.display = 'none'
			$('ta_1').style.backgroundColor = "#ff5400"
			$('p_card_approve').style.display = ''
			$('ta_2').style.backgroundColor = "#b5bf00"
			$('p_freetext_approve').style.display = 'none'
			$('ta_3').style.backgroundColor = "#ff5400"
			break;
		case "ta_3":
			$('p_cart_approve').style.display = 'none'
			$('ta_1').style.backgroundColor = "#ff5400"
			$('p_card_approve').style.display = 'none'
			$('ta_2').style.backgroundColor = "#ff5400"
			$('p_freetext_approve').style.display = ''
			$('ta_3').style.backgroundColor = "#b5bf00"
			break;
	}
}

function after_tranzila(app){
	if(app==1){
		//Approved!
		$('d_err').onclick = "";
		$('d_err_text').innerHTML = "<p><h1>ההזמנה בוצעה בהצלחה</h1><b>אנו מודים לך על הזמנתך בחנות קורקט.</b></p><p>ברגע זה ממש נשלחת הודעת אישור לדואר האלקטרוני שלך</p><p>נשמח לעמוד לשרותך בכל שאלה בטלפון: 09-7417299</p><p>בברכה,<br><b>צוות קורקט</b></p><style='font-size: 16px; color: #ff5400;'><b><a href=http://www.correct-gifts.com>לחצו כאן</a></b> להמשך</p>";
		$('d_err').style.display="";
	}else{
		$('d_err_text').innerHTML = "<p><h1>ההזמנה לא אושרה</h1><b>לא התקבל אישור עבור העסקה מחברת האשראי</b></p><p>אנא בדקו את פרטי כרטיס האשראי וודאו כי הזנתם פרטים נכונים, <b>ונסו שוב</b></p><p><b><a href='javascript: close_err()'>לחצו כאן</a></b> להמשך</p>";
		cartPrev(1);
		$('d_err').style.display="";
		
	}
	
}

function close_err(){
	$('d_err').style.display="none";
}

function setSearchEvent(val, d_id){
	if(val==1){
		$(d_id).style.backgroundColor = "#eeffbc"
	}else{
		$(d_id).style.backgroundColor = "#ffffff"
	}
}

function searchEvent(val){
	$('s_tags').value = val;
	$('frm_s2').submit();
}
