function HOME_getNextClientBig(currentID){
	document.getElementById('project_loader').style.display = 'block';
	document.getElementById('project_text').innerHTML = '';
	document.getElementById('project_image').style.display = 'none';
	
	
	doAjaxRequest("/ajax.php", {'do':'nextClientBig','id':currentID},{
  					method:"GET",
  					onSuccess:function (oQ) { 
						document.getElementById('project_loader').style.display = 'none';
						txt = oQ.responseText;
						split = txt.split(";", 2);
						
						document.getElementById('project_image').src = "/pictures/bl_" + split[0] + ".jpg";
						document.getElementById('project_image').style.display = 'block';
						document.getElementById('project_image').alt = split[1];
						document.getElementById('project_link').href = "/customers.html?c=" + split[0];
						document.getElementById('project_link2').href = "/customers.html?c=" + split[0];
						
						nTxt = txt.substr (split[0].length + split[1].length + 2);
						
						document.getElementById('project_text').innerHTML = nTxt;
						clientID = split[0];
						
					}
					,
  					onFailure:function (oQ) { 
						location.href = 'customers.html';
					}
  				});

	return false;
}

function HOME_getNextClients(){
	var AlreadyUsed = cList; // semi-colon seperated list

	return false;
}

function CLIENTS_loadClient(id)
{
	return false;
}



// AJAX library

var getTransferObject = function(){	return null;	};
if(window.ActiveXObject){
	// Check if the browser has support for ActiveXObject (IE Usually)  
	try{ 
		// Check for the new version of XMLHttp compoment  
		var x=  new ActiveXObject("MSXML2.XMLHTTP"); 
		getTransferObject = function(){ return new ActiveXObject("MSXML2.XMLHTTP"); }
	}catch(_ex){ 
		try{ // Check for late version of XMLHTTP compoment  
			var x = new ActiveXObject("Microsoft.XMLHTTP"); 
			getTransferObject = function(){ return new ActiveXObject("Microsoft.XMLHTTP"); }
		}catch(ex){
			// Otherwise the version of IE is too old  
		} 
	} 
}else if(window.XMLHttpRequest){
	// XMLHttpRequest object supported by Opera, Firefox and Safari - may too in IE 7.  
	getTransferObject = function(){ return new XMLHttpRequest(); }
}

/*
	* make an "Ajax Request".
	* @params: 
		- url : contains the target of the request.
		- params: Hash Table that contains a data that send with the request.
		- aOptions: Associative array that contains an optional property: method of sendinge, 
			2 optional function: 
				- onSuccess(param: RequestObject): will dispatch when the request get a "true" response (status-code=200)
				- onFailure(param: RequestObject): will dispatch when the request get a "false" response (status=code isn't 200)
			and an Hash Table of http headers named: httpHeaders
*/
function doAjaxRequest(url, params, aOptions){
	// get transfer object
	var oReq = getTransferObject();
	if(!oReq){
		// Check for XMLHttpRequest
		throw "Download the newer Firefox or upgrade your browser please.";
		return false;
	}

	// Add HTTP headers to the message
	for(var header in aOptions.httpHeaders){
		oReq.setRequestHeader(header,aOptions.httpHeaders[header]);
	}

	oReq.onreadystatechange = function(){
		if(oReq.readyState==4){
			if(oReq.status==200){
				if(aOptions.onSuccess) aOptions.onSuccess(oReq);
			}else{
				if(aOptions.onFailure) aOptions.onFailure(oReq);
			}
		}
	}

	// make parameters string
	var _params = [];
	for(var p in params){
		_params.push(p+"="+encodeURIComponent(params[p]));
	}
	_params = _params.join("&");

	// Default send method: GET
	var method = aOptions.method?aOptions.method:"GET",
		bodyPost= null;


	if(method=="POST"){
		oReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oReq.open(method, url, true);
		bodyPost = _params; // POST data send into the request
	}else{
		oReq.open(method, url+"?"+_params, true); // GET data send as part of the url
	}
	//send request
	oReq.send(bodyPost);
}

function switchclients(dir)
{
	curClient = curClient + (dir*2);
	if(curClient<0)			curClient = maxClient-1;
	if(curClient>maxClient)	curClient = 0;
	
	b1 = clients[curClient];
	b2 = clients[curClient+1];
	
	if(!b1 && !b2) return switchclients(dir);
	
	document.getElementById('clientRight').innerHTML = b1;
	document.getElementById('clientLeft').innerHTML = b2;
}

function getNews(page){
	if(page > 0 && !isNaN(page) && page <= maxPagesNews){
		currentPage = page;
		lst = document.getElementById('news').getElementsByTagName('div');
		for(i = 0; i < lst.length; i++){
			j = i + 1;
			document.getElementById("news" + j).style.display = (j == page) ? '' : 'none';
		}		
	}else if(page == 0){
		return getNews(maxPagesNews);
	}else if(page > maxPagesNews){
		return getNews(1);
	}
}

function showPage(page){
	var pages = "";
	if(page > 0 && page <= maxPagesWorks){
		element = document.getElementById('p'+page.toString());
		for(i=1;i<=maxPagesWorks;i++){
			document.getElementById('p'+i.toString()).style.display = 'none';
			if(i != page){
				pages += " <a href='javascript:showPage("+i+");'>"+i.toString()+"</a> ";
			}else
				pages += i;
		}
		document.getElementById('page_nums').innerHTML = pages;
		element.style.display = 'block';
	}
}
function showPageS(page){
	var pages = "";
	if(page > 0 && page <= maxPagesSup){
		element = document.getElementById('s'+page.toString());
		for(i=1;i<=maxPagesSup;i++){
			document.getElementById('s'+i.toString()).style.display = 'none';
			if(i != page){
				pages += " <a href='javascript:showPageS("+i+");'>"+i.toString()+"</a> ";
			}else
				pages += i;
		}
		document.getElementById('page_nums').innerHTML = pages;
		element.style.display = 'block';
	}
}

function getWork(id){
	if(id > 0){
		element = document.getElementById('profile'+id.toString());
		if(element != null && element.style.display == "none" && !isNaN(id)){
			document.getElementById('profile'+currentWork.toString()).style.display = "none";
			element.style.display = "block";
			currentWork = id;
			currentPic = 1;
			maxPics = document.getElementById('pics'+currentWork.toString()).value;
		}
	}
}

function showPic(id){
	if(id > 0 && !isNaN(id)){		
		pic = document.getElementById('img'+currentWork.toString()+'-'+id.toString());
		bigPic = document.getElementById('cImg'+currentWork.toString());
		a = document.getElementById(currentWork.toString()+'-'+id.toString());

		if(pic != null && pic.style.display != "none" && bigPic != null && a != null){
			temp = bigPic.src;
			bigPic.src = pic.src;
			pic.src = temp;
		}
	}
}

function getPics(id){
	if(id > 0 && !isNaN(id) && id+2 < maxPics){
		currentPic = id;
		lst = document.getElementById('th'+currentWork).getElementsByTagName('a');
		for(i = 0; i < lst.length; i++){
			j = i + 1;
			document.getElementById(currentWork + "-" + j).style.display = (j >= id && j <= (id+2)) ? '' : 'none';
		}		
	}else if(id == 0){
		return getPics(maxPics-3);
	}else if(id+3 > maxPics){
		return getPics(1);
	}
}

function getClients(client){
	if(client > 0 && client+3 <= maxClients && !isNaN(client)){
		currentClient = client;
		lst = document.getElementById('clientsContain').getElementsByTagName('a');
		for(i = 0; i < lst.length; i++){
			j = i + 1;
			document.getElementById('client' + j).style.display = (j >= client && j <= (client+3)) ? '' : 'none';
		}
		
	}else if(client == 0){
		return getClients(maxClients-3);
	}else if(client +3 > maxClients){
		return getClients(1);
	}
}

function getCase(c){
	if(c > 0 && c <= maxCases && !isNaN(c)){
		currentCase = c;
		for(i = 1; i <= maxCases; i++){
			j = i - 1;
			document.getElementById('case' + i).style.display = (c == i) ? '' : 'none';
		}
	}else if(c == 0){
		return getCase(maxCases);
	}else if(c > maxCases){
		return getCase(1);
	}
}
function checkPhone(phone){
	var good = true;
	for(i=0;i<phone.length && good;i++){
		if(isNaN(phone.charAt(i)))
			good = false;
	}
	if(phone.length < 9)
		good = false;
	if(phone.length > 10)
		good = false;
	if(phone.charAt(0) != '0')
		good = false;
	if(phone.substr(0,2) == "05" || phone.substr(0,2) == "07"){
		if((phone.substr(2,phone.length)).length < 8)
			good = false;
	}
	if(!good){
		alert("אנא הכנס מספר תקין!");
	}else{
		document.forms["freecall"].action+="?number="+phone;
	}
	return good;
}
$(document).ready(function() {
$('span.term').cluetip({height:'auto', width: '180px', showTitle: false, attribute : 'rel',dropShadow:       false,positionBy:       'mouse'});
});
$(document).ready(function() {
$('span.term2').cluetip({height:'auto', width: '180px', showTitle: false, attribute : 'rel',dropShadow:       false,positionBy:       'mouse',leftOffset:-220});
});
$(document).ready(function() {
$('span.news').cluetip({height:'auto', width: '180px', showTitle: false, attribute : 'rel',dropShadow:       false,positionBy:       'mouse'});
});
