﻿var m_FadeOut = 0;
var m_FadeIn=0;
var m_Fade = 0;

var m_FadeWait = 2000;
var m_bFadeOut = true;

var m_iFadeInterval;
var maxBoxHeight = 0;
window.onload = Fadewl;

var arrFadeCursor = 0;


function Fadewl() {
	
	setupFadeLinks();
  	$(document).ready(function(){
		$('.box .content').each(function() {
			elmHeight = $(this).height();
			elmHeight = elmHeight;
			if(elmHeight > maxBoxHeight)
				maxBoxHeight = elmHeight;
	  });
		$('.box .content').each(function() {
			$(this).height(maxBoxHeight);
	  });
		$('#changeCustomers').each(function() {
			$(this).height(maxBoxHeight-5);
	  })
	});	
	
	setFadeLink();
	setTimeout(step,3000);
}

function step(){
		$("#changeCustomers").fadeOut("slow");
			setTimeout(setFadeLink,700);
		$("#changeCustomers").fadeIn("slow");
	setTimeout(step,3000);
}

function setFadeLink() {
  var ilink = document.getElementById("changeCustomers");
		ilink.innerHTML = arrFadeTitles[arrFadeCursor];
	if (arrFadeCursor == m_FadeStep){
		arrFadeCursor = 0;
	}else{
		arrFadeCursor++;
	}
}


function Fadewl2() {
  setupFadeLinks();
  setFadeLink();
  m_iFadeInterval = setTimeout(fade_ontimer, 2000);
  
  	$(document).ready(function(){
		$('.box .content').each(function() {
			elmHeight = $(this).height();
			elmHeight = elmHeight;
			if(elmHeight > maxBoxHeight)
				maxBoxHeight = elmHeight;
	  });
		$('.box .content').each(function() {
			$(this).height(maxBoxHeight);
	  });
		$('#changeCustomers').each(function() {
			$(this).height(maxBoxHeight-5);
	  })
	});
  
}

function fade_ontimer() {
			
  if (m_bFadeOut) {
    m_Fade+=m_FadeStep;
    if (m_Fade>m_FadeOut) {
      arrFadeCursor++;
      if (arrFadeCursor>arrFadeMax)
        arrFadeCursor=0;
		$("#changeCustomers").fadeOut("slow");
			setTimeout(setFadeLink,700);
		$("#changeCustomers").fadeIn("slow");
      m_bFadeOut = false;
    }
  } else {
    m_Fade-=m_FadeStep;
    if (m_Fade<m_FadeIn) {
      clearInterval(m_iFadeInterval);
      setTimeout(Faderesume, m_FadeWait);
      m_bFadeOut=true;
    }
  }
  var ilink = document.getElementById("changeCustomers");
  if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn))
    ilink.style.color = "#" + ToHex(m_Fade);
}

function Faderesume() {
  m_iFadeInterval = setTimeout(fade_ontimer, 10);
}

function ToHex(strValue) {
  try {
    var result= (parseInt(strValue).toString(16));

    while (result.length !=2)
            result= ("0" +result);
    result = result + result + result;
    return result.toUpperCase();
  }
  catch(e)
  {
  }
}



Image1= new Image(733,225)
Image1.src = TempSrc+"/images/ads/kidum.jpg";

Image2= new Image(733,225)
Image2.src = TempSrc+"/images/ads/yazmut.jpg";

Image3= new Image(733,225)
Image3.src = TempSrc+"/images/ads/build.jpg";

Image4= new Image(733,225)
Image4.src = TempSrc+"/images/ads/clients.jpg";


function set_headerImg(classname){
	switch(classname)
	{
	case 'title_build':
		src = TempSrc+"/images/ads/build.jpg";
		title = "בניית אתרים";
	  break;
	case 'title_kidum':
		src = TempSrc+"/images/ads/kidum.jpg";
		title = "קידום אתרים";
	  break;
	case 'title_yazmut':
		src = TempSrc+"/images/ads/yazmut.jpg";
		title = "יזמות אינטרנטית";
	  break;
	case 'title_clients':
		src = TempSrc+"/images/ads/clients.jpg";
		title = "לקוחות";
	  break;
	default:
		//src = TempSrc+"/images/ads/build.jpg";
	}
	
	src2 = document.getElementById("adTopImg");
	if (src2.src != src){
		$('#adTopImg').fadeOut(300, function(){
            $(this).attr('src',src).bind('onreadystatechange load', function(){
                  if (this.complete) $(this).fadeIn(300);
				  $(this).attr('alt',title);
				  $(this).attr('title',title);
            });
       }); 	
	}
}
