var isNS4 = (navigator.appName=="Netscape")?1:0;

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=650,height=450,left=100,top=100');
			}
			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 (str_pic,"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();
}


var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "-/ ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 9;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(strobj){
	var Phone=document.getElementById(strobj)
	
	if ((Phone.value==null)||(Phone.value=="")){
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		return false
	}
	return true
 }


function open_win(str_url,str_name,str_para)
{
 res_win = window.open(str_url,str_name,str_para);
}

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 clear_form(s_form) 
{
	document.getElementById(s_form).reset();
}

function open_print()
{
 print_win = window.open("blank_print.asp","prinvV","top=100,left=100,width=650,height=500,toolbar=no,scrollbars=yes");
}