﻿var hpItemsInterval;
$(document).ready(function() {

    if ($('.project-details').is(':visible')) { }
    else {
        $('#full-details').css("display", "none")
    }



    $('#email, #first_name').focus(function() {
        this.value = ' '
    });


    $(".txtContactWebSource").hide();
    $(".txtProjectRegWebSource").hide();
    $('.project-details SPAN').css("font-size", "12px")
    $('.project-tags A:first').css({ 'padding-left': '0', 'margin-left': '0', 'border-left': '0px' });
    $('.project-tags A:last').css("border", "0px")


    if ($(".relatedSearches LI").length == 0) {
        //hidding the reu gam
        $(".relatedSearches").parent().hide();
    }

    $('.projects-banner ul').cycle({
        fx: 'wipe',
        speed: 500,
        timeout: 4000
    });

    $('.labeled').labelTextbox();
    $('#project-pictures').mezooOneBigGallery();
    
    //project reg form
    
     $('.FRM_big TEXTAREA.txtMedical').focus(function() {
         if ($(this).val()=="נא לציין בעיות רפואיות או דרישות תזונה מיוחדות")
	 {
		 $(this).val("");
	 	$(this).css("color", "#333");
	 }
	
    });
    
    
    $('.FRM_big TEXTAREA.txtMedical').blur(function() {
        x = $('.FRM_big TEXTAREA.txtMedical').val();
        if (x == "") {
            $('.FRM_big TEXTAREA.txtMedical').val("נא לציין בעיות רפואיות או דרישות תזונה מיוחדות");
	     $('.FRM_big TEXTAREA.txtMedical').css("color", "#777");
        }
    });
    
    //////
    
    $('.FRM_big TEXTAREA.txtWhy').focus(function() {
        
       	 if ($(this).val()=="למה את/ה רוצה להצטרף לתכנית?")
	 {
		 $(this).val("");
	 	$(this).css("color", "#333");
	 }
	
    });
    
   
   
    $('.FRM_big TEXTAREA.txtWhy').blur(function() {
        x = $('.FRM_big TEXTAREA.txtWhy').val();
        if (x == "") {
            $('.FRM_big TEXTAREA.txtWhy').val("למה את/ה רוצה להצטרף לתכנית?");
	     $('.FRM_big TEXTAREA.txtWhy').css("color", "#777");
        }
    });
 //project reg form


    //picture tabs inside project page
    $('.project-pictures-thumbs A').click(function(event) {
        event.preventDefault();
        $(".presented").removeClass();
        $(this).addClass("presented");
        imgSrc = $(this).attr('href');
        $('.big-picture IMG').attr("src", imgSrc);

    })

    $('.project-pictures-thumbs a').eq(0).trigger("click");


    $('.extending').focus(function() {
        $('#call-me-back-extended').slideDown();
    });

    $('ul.project-subprojects .heading').click(function() {
        $(this).parent().find('.details').slideToggle();
        if ($(this).hasClass('open'))
            $(this).removeClass('open')
        else
            $(this).addClass('open');
    });
    //end picture tabs inside project page


    //homepage rotating pictures 
    $('.hp-items-index LI').eq(0).addClass('active');

    $('.hp-items-index a').click(function(e) {
        e.preventDefault();
        clearInterval(hpItemsInterval);
        var listItem = $(this).parent();
        switchToHPItem($('.hp-items-index li').index(listItem));
    })

    HPPictureRotate();
    //homepage rotating pictures



   


    


});


//home page rotating pictures

function HPPictureRotate() {
        hpItemsInterval = setInterval("cycleHPItem()", 4000);
}

function cycleHPItem() {
    var next = $('.hp-items-index li').index($('.active')) + 1;
    
    var indexCount = ($('.hp-items-index li').size());
    if (next > indexCount-1) {
        next = 0;
    }
    switchToHPItem(next); 
}


function switchToHPItem(item) {
    var listItem = $('.active');
    var current = $('.hp-items-index li').index(listItem);
    $('.hp-items LI').eq(current).fadeOut('fast');
    $('.active').removeClass('active');
       
    $('.hp-items LI').eq(item).fadeIn('slow');
    $('.hp-items-index LI').eq(item).addClass('active');
     
}
//end home page rotating pictures  



//google search functions
function searchGoogle(str) {
    var newStr = str.replace("'", "");
    newStr = newStr.replace("(", "");
    newStr = newStr.replace(")", "");
    newStr = newStr.replace("SELECT", "");
    newStr = newStr.replace("INSERT", "");
    newStr = newStr.replace("UPDATE", "");
    newStr = newStr.replace("EXECUTE", "");
    newStr = newStr.replace("*", "")
    
   $('.gsc-input INPUT').val(newStr);
   $('.gsc-search-button INPUT').click();
   $('.gsc-search-box').css("visibility", "hidden");
   hpItemsInterval = setTimeout("changeIMG()", 500);
  
}

function changeIMG() {

    clearTimeout("changeIMG()");
    $('.gs-visibleUrl-long').each(function(e) {
        x = $(this).text();
        $(this).replaceWith("<a href='"+x+"' class='learn-more'>לפרטים נוספים</a>");
    })
    
}

//end google search functions

function popUp(page, title, w, h) {
    if (w == 0) {
        window.open(page, title, "width=1000px, height=800px, scrollbars=yes");
    }
    else {
        window.open(page, title, "status=0, width=" + w + "px, height=" + h + "px");
    }
}


$(document).ready(function() {
    $(".contactWebSource").change(function() {
        if ($(".contactWebSource").val() == "diffrent") {
                $(".txtContactWebSource").show();
            }
            else            {
                $(".txtContactWebSource").hide();
            }
        });
        
        
        
    $(".projectRegWebSource").change(function() {
        if ($(".projectRegWebSource").val() == "diffrent") {
            	$(".txtProjectRegWebSource").show();
            }
            else {
                $(".txtProjectRegWebSource").hide();
            }
        });
        
        

    $("#ctl00_content_ctl00_btnCallme").click(function(){
        if ($("#ctl00_content_ctl00_txtPhone").val() == "")        {
            alert("נא למלא מספר טלפון");
            return false;
        }
        else        {
    	    if ($("#ctl00_content_ctl00_txtEmail").val() == "")	    {
		        alert('נא למלא דוא,,ל');
		        return false;
	        }
        }
    });	
    
    
});


    
    
 