﻿tmpBody = "";

function showResults(){
	$('searchResults').innerHTML = tmpBody;
}

function tocPreClick(toc){
	records = document.getElementById("t"+toc+"_rec").value;
	
	if(records>0){
		document.getElementById("arrow"+toc).style.display = "";
	}
}

function tocOut(toc){
	records = document.getElementById("t"+toc+"_rec").value;
	
	if(records>0){
		if(document.getElementById("st"+toc).style.display != ""){
			document.getElementById("arrow"+toc).style.display = "none";
		}
	}
}

function tocClick(toc){
	records = document.getElementById("t"+toc+"_rec").value;
	if(records>0){
		if(document.getElementById("st"+toc).style.display == ""){
			document.getElementById("st"+toc).style.display = "none"
		}else{
			document.getElementById("st"+toc).style.display = ""
		}
		return false;
	}else{
		return true;
	}
}

function chkForm(){
	document.getElementById("err_contact_holder").style.display = "none";
	err="";
	if(document.getElementById("fname").value.length<2){
		err += "<li>נא להזין שם מלא</li>";
	}
	if(document.getElementById("phone").value.length<9){
		err += "<li>נא להזין מספר טלפון כולל קידומת</li>";
	}
	if(document.getElementById("email").value.length<5 || document.getElementById("email").value.indexOf("@")==-1 || document.getElementById("email").value.indexOf(".")==-1){
		err += "<li>נא להזין כתובת דואר אלקטרוני תקינה</li>";
	}
	if(err!=""){
		document.getElementById("err_contact").innerHTML = "<ul>"+err+"</ul>"
		document.getElementById("err_contact_holder").style.display = "";
		return false;
	}else{
		return true;
	}
}

function showImageGallery(){
	var mygallery=new fadeSlideShow({
		wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
		dimensions: [408, 243], //width/height of gallery in pixels. Should reflect dimensions of largest image
		imagearray: [
			["/images/mpic1.jpg", "", "", ""],
			["/images/mpic2.jpg", "", "", ""],
			["/images/mpic3.jpg", "", "", ""],
			["/images/mpic4.jpg", "", "", ""],
			["/images/mpic6.jpg", "", "", ""],
			["/images/mpic5.jpg", "", "", ""]//<--no trailing comma after very last image element!
		],
		displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
		persist: false, //remember last viewed slide and recall within same session?
		fadeduration: 700, //transition duration (milliseconds)
		descreveal: "ondemand",
		togglerid: ""
	})
}

function doOnFocus(event){
	switch(event){
		case "focus":
			$('txtSearch').style.color = "#1A1A1A";
			if($('txtSearch').value == "הקלידו טקסט לחיפוש"){
				$('txtSearch').value = "";
				$('txtSearch').style.color = "#1A1A1A";
			}
			break;
			
		case "blur":
			if($('txtSearch').value == ""){
				$('txtSearch').value = "הקלידו טקסט לחיפוש";
				$('txtSearch').style.color = "#afd2dd";
			}
			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";
	}
}

timerid = 0;

function sett(){
	timerid = setTimeout("$('search_box_on').style.display = 'none'",1000);
}

function cleart(){
	clearTimeout(timerid);
}

function chkSearch(){
	if($('txtSearch').value != "הקלידו טקסט לחיפוש" && $('txtSearch').value.length>1){
		return true;
	}else{
		return false;
	}
}
