$(document).ready(function() {

	if ($('.initialfocus').length) {
		$('.initialfocus').focus();
	}
	
	if ($('#prefooter').length) {
		var t=setTimeout(doPreFooterFade,4000);
	}

});

function doPreFooterFade() {
	count = 0;
	totalnumb = 18;
	$.each(['cl01','cl02','cl03'], function(key, value) {
		count = count + 50;
		$('#'+value).delay(count).fadeTo(250,0,function() {
			currurl = $('#'+value).attr("src");
			curr = currurl.replace("/res/images/clientLogos/homepage/new/","");
			curr = curr.replace(".png","");
			next = curr * 1 + 3;
			if (next>totalnumb) {
				next = next - totalnumb;
			}
			nexturl = "/res/images/clientLogos/homepage/new/" + next + ".png";
			$('#'+value).attr("src",nexturl);
		});
		$('#'+value).delay(500).fadeTo(250,1);
	});
	
	$('#testimonial a img').delay(500).fadeTo(500,1);
	var t=setTimeout(doPreFooterFade,4000);
}

function addVideo(w,h,url) {
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = (agent.indexOf('iphone')!='-1');
	var is_ipad = (agent.indexOf('ipad')!='-1');
	if (is_iphone) {
		document.write("<video src='http://www.vimeo.com/play_redirect?clip_id="+url+"&quality=mobile' controls='controls' width='"+w+"' height='"+h+"'></video>");
	}
	else if (is_ipad) {
		document.write("<video src='http://www.vimeo.com/play_redirect?clip_id="+url+"' controls='controls' width='"+w+"' height='"+h+"'></video>");
	}
	else {
		document.write("<object width='"+w+"' height='"+h+"'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id="+url+"&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=00adef&fullscreen=1&autoplay=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id="+url+"&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=00adef&fullscreen=1&autoplay=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='"+w+"' height='"+h+"'></embed></object>");
	}
}
