﻿$(document).ready(initCoreValues);
var xmCorevalues=null;
function initCoreValues() {	

    //bind action 
    $('.txtBlue').click(showDetail);

    $.ajax({
		type: "GET",
		url: xml_path+"/corevalues.xml",
		dataType: "xml",
		success: function(xml) {
		    xmCorevalues = xml;	
		    var corevalues = $("image", xmCorevalues);
			$(".OfficeLoop").setTemplateElement("templateCoreValues");
            $(".OfficeLoop").processTemplate(corevalues);
            $(".OfficeLoop > img:first").hide().fadeIn(2000);
            startSlideshow();
		}
		,error:function(req,statsu,error){
		    alert(req.statusText);
		}
	});
}

function startSlideshow(){ 
    $(".OfficeLoop > img:visible").fadeOut(2000,function(){
        var obj = $("#"+$(this).attr('id')+" + img:first");
        if(obj.length>0){
            obj.fadeIn(2000,startSlideshow);
        }else{
            $(".OfficeLoop > img:first").fadeIn(2000,startSlideshow);
        }
    })
}

function showDetail(){
    $(".ContentPrinciple > div > div > ul").slideUp('fast');
    if($(this).parents('div').find('> ul').is(":hidden"))
        $(this).parents('div').find('> ul').slideToggle('fast');
} 




