var isNS4 = (navigator.appName=="Netscape")?1:0;
var last_click = "a1";
var gal_pic_index = 0;
var total_pics;


function check_valid_email(str_email)
{
	var  ret_val = true;
	func_email = str_email;
	if(func_email.indexOf("@") < 2)
	{
	 ret_val=false
	}
	if(func_email.indexOf(".") == 1 || func_email.indexOf(".") == func_email.length)
	{
	 ret_val=false
	}
	return ret_val;
}

function open_big_pic(pic_str)
{
 a_win =  window.open ("big_pic_gen.asp?pic="+pic_str,"asd","toolbar=no,scrollbars=no,width=10,height=10");	
}

function resetpic(x)
{

picv=document.getElementById (x);
picv2=document.getElementById ("dis"+x);		
picv.value="0";
picv2.value="";
}


function open_popup(x,ty)
{
	
		  pic=document.getElementById(x);	

			 
		 if (pic.value=="" || pic.value=="0")
			{
				open('../includes/popuppic.asp?id='+x+'&type='+ty,'pics','width=760,height=500,left=100,top=50,scrollbars=yes,toolbar=no');
			}
			else
			{
			   alert("עלייך להסיר את הקוב הקיים");
			}
 }
		 

		 
		 
	function open_popup_flash(x_str)
	{
	 window.open('../includes/popupflash.asp?id='+x_str+'&w=130&h=150','pics','width=250,height=160,top=150,left=180');
	}	 

	function show_hide_func(str_obj)
	{
		 all_to_hide = document.getElementsByTagName("DIV");
		 for(i=0;i<all_to_hide.length;i++)
			all_to_hide[i].style.display = "none";
		 if(document.getElementById(str_obj).style.display=="none")
		{
			  document.getElementById(str_obj).style.display = "";
		}
		else
		{
			 document.getElementById(str_obj).style.display = "none";
		}
	}

	function hide_func(str_obj)
	{
		 document.getElementById(str_obj).style.display = "none";
	}

function display_pic(str_pic)
{
 pics = document.getElementById("dis"+str_pic) ;
 if(pics.value!="")
 {
 window.open ("../../pic/"+pics.value,"big_pic","width=400,height=400,toolbar=no,scrollbars=yes,resizable=yes,status=no");
 }
 else
 {
  alert("לא קיים קובץ להצגה")
 }
}

function rev_stat()
{
 if(document.getElementById("Add_New").style.display=="none")
 {
  document.getElementById("Add_New").style.display='';
 }
 else
 {
  document.getElementById("Add_New").style.display='none';
 }
}

function ClearField(F_id)
{
 In_id = document.getElementById(F_id) ;
 In_id.value="";
}

function display_file(str_inp_name)
{
 var obj_file = document.getElementById(str_inp_name);
 window.open("../../files/"+obj_file.value,"file","status=false")  
}

function get_color(color_id)
{
	In_color = document.getElementById(color_id) 
	In_color.value =  showModalDialog('../includes/colors2.asp', 'as', 'dialogLeft:150px;dialogTop:300px;dialogWidth:380px;dialogHeight:260px;help:no;status:no;scrollbars:no;')
}

function alertandred(url,msg)
{
var ans;
ans = confirm(msg);
if(ans==true) location.href = url;
}

function open_win(str_url,str_name,str_para)
{
 res_win = window.open(str_url,str_name,str_para);
}



function clear_form(s_form) 
{
	document.getElementById(s_form).reset();
}


function reveal_hide_func(str_obj)
	{
		 if(document.getElementById(str_obj).style.display == "none")
			 document.getElementById(str_obj).style.display = "";
		 else
			 document.getElementById(str_obj).style.display = "none";

	}

function valid_form_comment(str_obj)
{
	var fname = document.getElementById("fname").value;
	//var email = 
	document.getElementById("check_val").value = "gotyou";
	var comm = document.getElementById("comm").value;
	var kot = document.getElementById("kot").value;
	if(fname == "" || kot == "")
	{
		alert("יש למלא שם /כינוי ונושא");
	}
	else
	{
			document.getElementById(str_obj).submit();
	}
}

function hide_div(q_id)
{
 document.getElementById(q_id).style.display  = "none";
}

function show_div(q_id)
{
 document.getElementById(q_id).style.display  = "";

}

function set_timer_right()
{
right_time = window.setInterval("scroll_right()",10);
}

function set_timer_left()
{
left_time = window.setInterval("scroll_left()",10);
}

function kill_time_out_right()
{
 window.clearInterval(right_time);
}

function kill_time_out_left()
{
 window.clearInterval(left_time);
}

function scroll_left()
{
 document.getElementById("scroller_pics").scrollLeft = document.getElementById("scroller_pics").scrollLeft - 1;
}

function scroll_right()
{
 document.getElementById("scroller_pics").scrollLeft = document.getElementById("scroller_pics").scrollLeft + 1;
}


function set_gal_next_pic()
{
	 if(gal_pic_index == total_pics) gal_pic_index = 0;
	 gal_pic_index = gal_pic_index + 1;
	 click_pic(gal_pic_index,0);
	 
}

function set_gal_prev_pic()
{
	 if(gal_pic_index==0) gal_pic_index = total_pics;
	 gal_pic_index = gal_pic_index - 1;
	 click_pic(gal_pic_index,0);
	 
}
function click_pic(ind,ai)
{
document.getElementById("p_pic").innerHTML = arr_pics[ind];
//document.getElementById(ai).style.color = "#000000";

//if (last_click != "a1")
//	{
//		document.getElementById(last_click).style.color = "#40920f";
//	}
last_click = ai;
}

function valid_form_form(str_form)
{
 fname = document.getElementById("fname").value;
 email = document.getElementById("email").value;
 phone = document.getElementById("phone").value;
 //email_stat = check_valid_email(email);
 if(fname == "" || phone == "")
 {
  alert("יש למלא את כל הפרטים");
 }
	
 else
 {
	//if(email_stat == false)
	//	alert("יש למלא כתובת מייל תקינה ושם");
	//else
		document.getElementById(str_form).submit();		
 }
	
	
}

function vote(str_form)
{
	 document.getElementById(str_form).submit();
}

function open_print()
{
	 pr_win = window.open("/print.asp","print","width=600,height=600,top=50,left=150,toolbar=no,scrollbars=yes"); 
}

function go_search_site(str_form,str_txt)
{
if(document.getElementById(str_txt).value=="")
	{
		alert("יש להקליד טקסט לחיפוש");
	}
	else
	{
		 document.getElementById(str_form).submit();
	}
}

function add_book()
{
	window.external.AddFavorite('http://www.g-news.co.il/', 'חדש בגליל');
}
