﻿tmpBody = "";

timerid = 0;

function GetWindowSize(w, what) {
        w = w ? w : window;
        var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
	if(what="w"){       
		return width;
	}else{
		return height;
	}
}

function sett(){
	timerid = setTimeout("$('search_box_on').style.display = 'none'",1000);
}

function cleart(){
	clearTimeout(timerid);
}

function showResults(){
	$('searchResults').innerHTML = tmpBody;
}

subs_timerid = 0;
function showSubs(sub){
	clearTimeout(subs_timerid);
	for(i=1;i<9;i++){
		if(i==sub){
			$('sub'+i).style.display = "";
		}else{
			$('sub'+i).style.display = "none";
		}
	}
}

function hideSubs(sub){
	subs_timerid = setTimeout("$('sub"+sub+"').style.display = 'none'",2000);
}

cur_pic = 0;
total_pics = 0;
pt = 0

side_pics = 1;


function doOnFocus(event){
	switch(event){
		case "focus":
			$('txtSearch').style.color = "#414042";
			if($('txtSearch').value == "הקלידו טקסט לחיפוש"){
				$('txtSearch').value = "";
				$('txtSearch').style.color = "#414042";
			}
			break;
			
		case "blur":
			if($('txtSearch').value == ""){
				$('txtSearch').value = "הקלידו טקסט לחיפוש";
				$('txtSearch').style.color = "#939598";
			}
			break;
	}
}

function doOnChange(){
	inp_txt = $('txtSearch').value+"";
	if(inp_txt.length>1){
		var url = "/include/searchAjax.php?sid="+Math.random();
		new Ajax.Request(url, {   
			method: 'get', 
			parameters:{ 
				s: inp_txt
			},  
			onSuccess: function(transport) {   
				result = transport.responseText;
				result = result.substr(1,result.length)
				if(result.length>1){
					$('search_results').innerHTML = result;
					$('search_box_on').style.display = "";
				}else{
					$('search_box_on').style.display = "none";
				}
			}
		});
	}else{
		$('search_box_on').style.display = "none";
	}
}

function chkForm(menu){
	
	$("Errors").style.display = "none";
	tmpErr = "";
	$('fname').style.border = "1px solid #BCBDC0";
	$('phone').style.border = "1px solid #BCBDC0";
	$('email').style.border = "1px solid #BCBDC0";
	$('area').style.border = "1px solid #BCBDC0";
	$('phone_ext').style.border = "1px solid #BCBDC0";
	$('dtype').style.border = "1px solid #BCBDC0";
	

	if($('fname').value.length<3){
		tmpErr += "<li>שם מלא</li>";
		$('fname').style.border = "1px solid #7b2528";
	}
	if($('phone').value.length<7 || $('phone_ext').value.length<2){
		tmpErr += "<li>מספר טלפון מלא כולל קידומת</li>";
		if($('phone').value.length<7){
			$('phone').style.border = "1px solid #7b2528";
		}
		if($('phone_ext').value.length<7){
			$('phone_ext').style.border = "1px solid #7b2528";
		}
	}
	if(check_email($('email').value)== false || $('email').value.length<7){
		tmpErr += "<li>כתובת אימייל חוקית</li>";
		$('email').style.border = "1px solid #7b2528";
	}
	if($('area').value.length<1){
		tmpErr += "<li>איזור</li>";
		$('area').style.border = "1px solid #7b2528";
	}
	if($('dtype').value.length<1){
		tmpErr += "<li>סוג המשלוח</li>";
		$('dtype').style.border = "1px solid #7b2528";
	}
	if(tmpErr!=""){
		$('ErrorsTxt').innerHTML = "<b>מספר פרטים חסרים:</b><ul>"+tmpErr+"</ul>";
		$("Errors").style.display = "";
		return false;
	}else{
		return true;
	}
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	}
	if(e.indexOf(".") == -1 || e.indexOf("@") == -1){
		return (false);
	}
}

function goSearch(){
	if($('txtSearch').value.length>1){
		location = "/p,4661,0.php?s="+$('txtSearch').value;
	}
}

function setFocus(w, elm, val){
	switch(w){
		case "focus":
			$(elm).style.color = "#414042";
			if($(elm).value == val){
				$(elm).value = "";
			}
			break;
		case "blur":
			if($(elm).value == ""){
				$(elm).style.color = "#afd2dd";
				$(elm).value = val;
			}
			break;
	}
}

mc_timerid = 0;
function mc_over(w){
	clearTimeout(mc_timerid);
	$("mc_link"+w).style.backgroundImage = "url('/images/red90.png')";
	$("mc_pic"+w).style.display = "";
	$("mc_txt"+w).style.display = "";
	if(w==1){
		$('mc_txt_bridge').style.top = "0";
	}else{
		$('mc_txt_bridge').style.top = ((w-1)*45)+"px";
	}
	for(x=1;x<5;x++){
		if(x!=w){
			$("mc_link"+x).style.backgroundImage = "url('/images/black90.png')";
			$("mc_pic"+x).style.display = "none";
			$("mc_txt"+x).style.display = "none";
		}
	}
	$("mc_txts").style.display = "";
}

function goNormal(x){
	$("mc_link"+x).style.backgroundImage = "url('/images/black90.png')";
	$("mc_txts").style.display = "none";
}

function mc_out(w){
	mc_timerid = setTimeout("goNormal("+w+")",500);
}

function mc_over_inner(w){
	$("mc_link"+w).style.backgroundImage = "url('/images/red90.png')";
}

function mc_out_inner(w){
	$("mc_link"+w).style.backgroundImage = "url('/images/black90.png')";
}
