$(document).ready(function() {	
	
	/*kentico BizForm apply this class to the image submit button*/
	$(".FormButton").hover(
	  function () {
		$(this).attr("src",$(this).attr("src").replace("_off", "_on"));
	  }, 
	  function () {
		$(this).attr("src",$(this).attr("src").replace("_on", "_off"));
	  }
	);
	/*you can apply this class to image buttons so they will have rollover effections*/
	$(".ImageButton").hover(
	  function () {
		$(this).attr("src",$(this).attr("src").replace("_off", "_on"));
	  }, 
	  function () {
		$(this).attr("src",$(this).attr("src").replace("_on", "_off"));		
	  }
	);
		
	/* About js beginds*/
	if (0 < document.location.href.lastIndexOf('about.aspx')) {
		//alert($("#snavAbout"));
		$("#snavAbout").attr("src",$("#snavAbout").attr("src").replace("_off", "_on"));
		
		$("#snavAbout").hover(
		  function () {
			$(this).attr("src",$(this).attr("src").replace("_off", "_on"));
		  }, 
		  function () {
			$(this).attr("src",$(this).attr("src").replace("_on", "_on"));	
			$(this).attr("src",$(this).attr("src").replace("_off", "_on"));
		  }
		);
	}
	/*About js ends*/
		
	/*Featured stories page js begins*/		
	// Accordion
	$("#accordion").accordion({
		header: "h3",
		collapsible: true,
		active:false,
		alwaysOpen: false
	});			
				
	/*Featured stories page js ends*/
	
	/* Veteran Profile images rotation */
	/* More info about the cycle plugin, see here - http://malsup.com/jquery/cycle/lite/*/
	//$('#profileImageSlideshow').cycle()
	$('#profileImageSlideshow').cycle({ 
		delay:  -500, 
		speed:  500,
		pause: true
	}); 
	/* Veteran Profile images rotation ends */
	
	/* Homepage Veteran Profile rotation */
	$('#veteranProfileSlideshow').cycle({ 
		delay:  -500, 
		speed:  500,
		pause: true
	});
	/* Homepage Veteran Profile rotation ends */


/**
 * Toggle the URL and handle
 * any existing querystring parameters
 */

$("#btnLanguageToggle").click(function(e){
    e.preventDefault();

    var url = window.location.href;
    var langParam;
	
    if(url.indexOf("thememoryproject.com") != -1){
        langParam = "Lang=fr-CA";
    }
    else if(url.indexOf("leprojetmemoire.com") != -1){
        langParam = "Lang=en-CA";
    }

    
    
    if(window.location.href.indexOf("Lang=en") != -1){
        url = url.replace(/Lang=en-ca/i, langParam);   
    }
    else if(window.location.href.indexOf("Lang=fr") != -1){
        url = url.replace(/Lang=fr-ca/i, langParam);
    }
    else{   
        if(url.indexOf("?") != -1){
            url = url + "&" + langParam;
        }
        else{
            url = url + "?" + langParam;
        }    
    }

    //Switch domain
    if((url.indexOf("thememoryproject.com") != -1)&&(langParam == "Lang=fr-CA")){
        url = url.replace(/thememoryproject.com/i, "leprojetmemoire.com"); 
    }
    else if((url.indexOf("leprojetmemoire.com") != -1)&&(langParam == "Lang=en-CA")){
        url = url.replace(/leprojetmemoire.com/i, "thememoryproject.com"); 
    }
    
    document.location.href = url;

});


});

/**
 * Toggle the URL and handle
 * any existing querystring parameters
 */
function LanguageJump(langParam){            
    var url = window.location.href;
    
    if(window.location.href.indexOf("Lang=en") != -1){
        url = url.replace(/Lang=en-ca/i, langParam);   
    }
    else if(window.location.href.indexOf("Lang=fr") != -1){
        url = url.replace(/Lang=fr-ca/i, langParam);
    }
    else{   
        if(url.indexOf("?") != -1){
            url = url + "&" + langParam;
        }
        else{
            url = url + "?" + langParam;
        }    
    }

    //Switch domain
    if((url.indexOf("thememoryproject.com") != -1)&&(langParam == "Lang=fr-CA")){
        url = url.replace(/thememoryproject.com/i, "leprojetmemoire.com"); 
    }
    else if((url.indexOf("leprojetmemoire.com") != -1)&&(langParam == "Lang=en-CA")){
        url = url.replace(/leprojetmemoire.com/i, "thememoryproject.com"); 
    }
    
    document.location.href = url;
}

