// JavaScript Document
//google anlitics
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19860792-1']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


function loadPage(msg,cpval){
	if(msg!=""){
	$(".comment").html(msg);
	}
	
	if(cpval!=""){
	 $(".comment").prepend('<span style="color:red">'+cpval+'</span>');
	}
	
}

function shopen(e){
                                   //Get the id of this clicked item                    
        page = e.id;

        Shadowbox.open({
        content:    'detailcasehystory.php?titlecase='+page,
        player:     "iframe",
        title:      "CaseHistory"
    });
								
}

$(document).ready(function(){

$('#refdivcenter').jScrollPane();

$logodiv = $('#showcase2');
var tblPar="";
var tblRef="";
var tblRow='<ul id="nav"></ul><div id="slideshow">';
var imagesRemaining=0;

$.getJSON(
			"jsondata.php",
			function(data){
				$.each(data.items, function(i,file){
					 tblRow = tblRow+'<div id="eldiv"><img src="'+file.src+'" alt="'+file.alt+'" /></div>';
					 imagesRemaining++;
				});
				tblRow=tblRow+'</div>'
				$logodiv.append(tblRow);
				startCycle()
			}
		);

$.getJSON(
			"includepartner.php",
			function(data){
				$.each(data.items, function(i,file){
				dv='<div class="itempartner"><div class="commentref"><p><img src="'+file.src+'"/></p></div></div>';
					 tblPar = tblPar+dv;
				});
				$("#partnerdiv").append(tblPar);
				startPartner();
			}
		);

$.getJSON(
			"includereference.php",
			function(data){
				$.each(data.items, function(i,file){
				/*dv='<div class="itemreference"><div class="commentref"><p><a href="detailcasehystory.php?titlecase='+escape(file.nam)+'" target="_blank"><img src="'+file.src+'"/></a><h2>'+file.nam+'</a></h2></p></div></div>';*/
				if(file.lnk=="true"){
				dv='<div class="itemreference"><div class="commentref"><img  src="'+file.src+'"/><br/><a href="#" onclick="shopen(this);return false" onfocus="this.blur()" id="'+escape(file.nam)+'">View Case History</a></div></div>'
				}else{
				dv='<div class="itemreference"><div class="commentref"><p><img  src="'+file.src+'"/></p></div></div>'
				}
				
				
					 tblRef = tblRef+dv;
				});
				$("#referencediv").append(tblRef);
				startReference();
			}
		);

function startCycle(){
		$('#slideshow').cycle({
			fx: "fade",
			timeout: 10000,
			delay:  -4000,
			pager:  '#nav'
		});
		
		$('#slidenews').cycle({
			cleartypeNoBg:true,
			fx: "scrollUp",
			timeout: 10000,
			delay:  -4000,
			pager: '#navnews'
		});
		
}

function startPartner(){
 $('#partnerdiv').cycle({
			cleartypeNoBg:true,
			fx: "scrollDown",
			timeout: 4000,
			delay:  -1000
		});
}

function startReference(){
	$('#referencediv').cycle({
			cleartypeNoBg:true,
			fx: "scrollUp",
			timeout: 4000,
			delay:  -1000
		});
	
}

$("#hmenu li").click(function(){
                                   //Get the id of this clicked item
                           
              page = this.id;
              $('#contentpage').load(page);
 });

//shadowbox


//


});

