﻿//======================================================//
	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  func();
		}
	  }
	}
//======================================================//
	function AddLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  func();
		}
	  }
	}
	
//======================================================//
function $(e){if(typeof e=='string')e=document.getElementById(e);return e};
function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n};
//======================================================//
ajax={};
ajax.x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}};
ajax.serialize=function(f){var g=function(n){return f.getElementsByTagName(n)};var nv=function(e){if(e.name)return encodeURIComponent(e.name)+'='+encodeURIComponent(e.value);else return ''};var i=collect(g('input'),function(i){if((i.type!='radio'&&i.type!='checkbox')||i.checked)return nv(i)});var s=collect(g('select'),nv);var t=collect(g('textarea'),nv);return i.concat(s).concat(t).join('&');};
ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};
ajax.get=function(url,func){ajax.send(url,func,'GET')};
ajax.gets=function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x};
ajax.post=function(url,func,args){ajax.send(url,func,'POST',args)};
ajax.update=function(url,elm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.get(url,f)};
ajax.submit=function(url,fun,frm){ajax.post(url,fun,ajax.serialize(frm))};
//======================================================//
var myimages = new Array();
function PreloadingImg(){
	for (x=0; x<PreloadingImg.arguments.length; x++){
		myimages[x] = new Image();
		myimages[x].src = PreloadingImg.arguments[x];
	}
}
//======================================================//
	function setHomePage()
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.optisource.co.il');
	}
    
	function Win(URL, name, width, height)
	{
		var x = screen.width;
		var y = screen.height;
		x=(x/2)-(width/2);
		y=(y/2)-(height/2);
		var wini = window.open(URL, name, "top="+y+",left="+x+",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width="+width+",height="+height+",resizable=no");
		wini.window.focus();
	}
	
       

    
    var bookmarkurl="http://www.optisource.co.il"
    var bookmarktitle="אופטיסורס - כל משרות האופטיקה בישראל"

    function addbookmark(){
    if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)
    }
    
   
    function isEmailAddr(email)
    {
    var result = false
    var theStr = new String(email)
    var index = theStr.indexOf("@");
    if (index > 0)
    {
	    var pindex = theStr.indexOf(".",index);
	    if ((pindex > index+1) && (theStr.length > pindex+1))
	    result = true;
    }
    return result;
    }


    
	


function Limit()
{
	if(document.all && event.type == "paste")
		this.blur();
	
	if(this.value.length > this.getAttribute("maxi"))
		this.value = this.value.substring(0,this.getAttribute("maxi"));
	$G(this.getAttribute("spani")).innerHTML = this.getAttribute("maxi") - this.value.length;
}
function Maxi()
{
	var ar = document.getElementsByTagName("textarea");
	
	for(var i=0; i < ar.length; i++)
		if(ar[i].getAttribute("maxi") != null)
		{
			ar[i].onpaste = Limit;
			ar[i].onkeyup = Limit;
			ar[i].onblur = Limit;
		}
}
AddLoadEvent(Maxi);

//======================================================//
function EmailValid(val)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(val);
}
//======================================================//
function WaterMark(id, opt, txt, flipDir)
{
	if(document.getElementsByTagName(id).value == ""){document.getElementsByTagName(id).style.color=opt._onblur;document.getElementsByTagName(id).value=txt;}
	document.getElementsByTagName(id).onblur = function(){
		if(document.getElementsByTagName(id).value==""){document.getElementsByTagName(id).value=txt}
		if(document.getElementsByTagName(id).value==txt){document.getElementsByTagName(id).style.color=opt._onblur;if(flipDir){FlipDir(id,opt);}}
	};
	document.getElementsByTagName(id).onfocus = function(){
		if(document.getElementsByTagName(id).value==txt){document.getElementsByTagName(id).value=""}
		document.getElementsByTagName(id).style.color=opt._onfocus;
		if(document.getElementsByTagName(id).value==""){if(flipDir){FlipDir(id,opt);}}
	};
}
function FlipDir(id,opt)
{
	if(document.getElementsByTagName(id).style.direction == "")
		document.getElementsByTagName(id).style.direction = opt.dir;
	if(document.getElementsByTagName(id).style.direction == "rtl")
		document.getElementsByTagName(id).style.direction = "ltr";
	else
		document.getElementsByTagName(id).style.direction = "rtl";
}
//======================================================//
function ClearDiv(divID)
{
	if($(divID))
		$(divID).innerHTML = "";
}
//======================================================//
function HideDiv(divID)
{
	if($(divID))
		$(divID).className = "hidden";
}
//======================================================//
function RefreshUpdatePanel(hiddenFieldID)
{
	var hiddenField = $(hiddenFieldID);
	if (hiddenField) {
		hiddenField.value = (new Date()).getTime();
		__doPostBack(hiddenFieldID,'');
	}
}
function FileName(obj, divID)
{
	if(obj.value != "")
	{
		document.getElementById(divID).innerHTML = obj.value.substring(obj.value.lastIndexOf('\\')+1);

	}
}
    
    
	function show_update(id_no)
	{
	if (document.all('update_' + id_no).style.display=='none') 
	{
	document.all('update_' + id_no).style.display='';
	}
	else 
	{
	document.all('update_' + id_no).style.display='none';
	}
	}
		
function CheckComments()
{
	var regx = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	
	frm = document.comment;
	if(frm.author_name.value == ""){alert("�אנא מלא שם מלא");frm.author_name.focus();return false;}
	if(frm.name.value == ""){alert("אנא מלא כותרת התגובה");frm.name.focus();return false;}
	document.getElementById("Secret").value = "lizzy";
	return true;
}

	
function Details_Handler2(id,pid) {

	trDetailsopen = document.getElementById("trDetailsopen" + id);
	tdDetailsopen = document.getElementById("tdDetailsopen" + id);
	//alert(trDetailsclose)
	if(trDetailsopen.style.display == "none")
	{					
		trDetailsopen.style.display = "";
		tdDetailsopen.innerHTML = "<iframe align='left' id='ifr" + id + "' name='ifr" + id + "' frameborder='no' scrolling='no' src='Resume2.asp?id=" + id + "&PID=" + pid + "' width='643' height='280' ></iframe>";				
	}
	else
	{
	
		tdDetailsopen.innerHTML = "";	
		trDetailsopen.style.display = "none";
	}	
}

function Details_Handler3(id,pid) {
    

    if ($("#trDetailsopen"+ id).css("display") != "none") 
	{					
		$("#trDetailsopen"+ id).slideDown("slow");
		$("#tdDetailsopen"+ id).html("<iframe align='left' id='ifr" + id + "' name='ifr" + id + "' frameborder='no' scrolling='no' src='Resume.asp?id=" + id + "&PID=" + pid + "' width='643' height='280' ></iframe>");
		$("#Table"+ id).css("background-color","#EBEBEB");
		$("#open"+ id).attr("images/close.jpg");
	}
	else
	{
		$("#Table"+ id).css("background-color","#ffffff");
		$("#tdDetailsopen"+ id).html('');	
		$("#trDetailsopen"+ id).css("display","none");
		$("#open"+ id).attr("images/open.jpg");
	}	
}


function Details_Handler(id,pid,bg) {

    //if(document.getElementById("trDetailsopen" + id).setAttribute( "style", "display:none" ))
	if(document.getElementById("tr" + id).style.display == "none")
	{					
		document.getElementById("tr" + id).style.display = "";
		document.getElementById("td" + id).innerHTML = "<iframe align='left' id='ifr" + id + "' name='ifr" + id + "' frameborder='no' scrolling='no' src='Resume.asp?id=" + id + "&PID=" + pid + "&bg1="+ bg +"' width='643' height='280' ></iframe>";				
		document.getElementById("Table" + id).bgColor = bg;
		document.getElementById("open" + id).src = "images/close.jpg";
	}
	else
	{
		document.getElementById("Table" + id).bgColor = bg;
		document.getElementById("td" + id).innerHTML = "";	
		document.getElementById("tr" + id).style.display = "none";
		document.getElementById("open" + id).src = "images/open.jpg";
	}	
}

function Details_Handler4(id,pid) {

    //if(document.getElementById("trDetailsopen" + id).setAttribute( "style", "display:none" ))
	if(document.getElementById("tr" + id).style.display == "none")
	{					
		document.getElementById("tr" + id).style.display = "";
		document.getElementById("td" + id).innerHTML = "<iframe align='left' id='ifr" + id + "' name='ifr" + id + "' frameborder='no' scrolling='no' src='Resume2.asp?id=" + id + "&PID=" + pid + "' width='643' height='280' ></iframe>";				
		document.getElementById("Table" + id).bgColor = "#EBEBEB";
		document.getElementById("open" + id).src = "images/close.jpg";
	}
	else
	{
		document.getElementById("Table" + id).bgColor = "#ffffff";
		document.getElementById("td" + id).innerHTML = "";	
		document.getElementById("tr" + id).style.display = "none";
		document.getElementById("open" + id).src = "images/open.jpg";
	}	
}


//======================================================//
function CreateCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function ReadCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function EraseCookie(name) {
	CreateCookie(name,"",-1);
}
//======================================================//
function P(id, checked)
{
    chxb=true;
    var pCoo=new Array();

    if(ReadCookie("msg_print")!=null)
		pCoo = ReadCookie("msg_print").split(",");
                    
    if(checked)
		pCoo[pCoo.length] = id;
    else
    {
		for(var i=0; i < pCoo.length; i++)
			if(pCoo[i] == id)
				pCoo.splice(i, 1);
    }
    CreateCookie("msg_print",pCoo,false);
}

function CheckComments()
{
	var regx = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	frm = document.comment;
	if(frm.author_name.value == ""){alert("אנא מלא שם מלא");frm.author_name.focus();return false;}
	if (!regx.test(frm.email.value)){alert("כתובת האי-מייל שלך לא חוקית");frm.email.focus();return false;}
	document.getElementById("Secret").value = "lizzy";
	return true;
}

function CheckReComments()
{
	var regx = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	
	frm = document.ReComment;
	if(frm.author_name.value == ""){alert("אנא מלא שם מלא");frm.author_name.focus();return false;}
	if (!regx.test(frm.email.value)){alert("כתובת האי-מייל שלך לא חוקית");frm.email.focus();return false;}
	document.getElementById("Secret").value = "lizzy";
	return true;
}

   function OverResponseDIV(x,y,z)
    {
        var str = "<iframe scrolling='no' frameborder='0' width='616' height='280' src='Comments.asp?item_id="+x+"&FID="+y+"&typeID="+z+"' name='Comments' id='Comments'></iframe>"
        document.getElementById('sCommentsDIV' + x).innerHTML = str;
    }

    function CloseResponseDIV(x)
    {
        document.getElementById('sCommentsDIV' + x).innerHTML = '';
    }


