﻿//======================================================//
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))};
//======================================================//
//======================================================//
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function ChangePic2( pic)
{
//alert(pic)
	opacity('BPic', 40, 100, 400)
	setTimeout("DoChange2('" + pic + "')", 20);
}

function DoChange2(pic)
{
	document.getElementById("BPic").src =  pic
}
function Details_Handler(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='Resume.asp?id=" + id + "&PID=" + pid + "' width='484' height='145' ></iframe>";				
	}
	else
	{
	
		tdDetailsopen.innerHTML = "";	
		trDetailsopen.style.display = "none";
	}	
}


	//====================================================\\
	function Clear(num)
	{
			
		if(document.getElementById("FreeText").value == "הקלד/י טקסט חופשי לחיפוש" && num==1)
			document.getElementById("FreeText").value = ""

	}
	//====================================================\\
	function Fill(num)
	{
			
		if(document.getElementById("FreeText").value == "" && num==1)
			document.getElementById("FreeText").value = "הקלד/י טקסט חופשי לחיפוש"
			
	}

	function CheckLogin()
	{
		un = document.getElementById("mUsername");
		pw = document.getElementById("mPassword");
		
		if(un.value == "" || un.value == "כתובת אימייל"){alert("אנא מלא כתובת אימייל"); return false; un.focus();}
		if(pw.value == ""){alert("אנא מלא סיסמה"); return false; pw.focus();}
		
		return true;
	}
	
	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=yes,width="+width+",height="+height+",resizable=yes");
		wini.window.focus();
	}
	
    var bookmarkurl="http://www.globtech.co.il"
    var bookmarktitle="Globtech"

    function addbookmark(){
    if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)
    }
