$(document).ready(function(){
	/* The following code is executed once the DOM is loaded */
	
	$('.sponsorFlip').bind("click",function(){
		
		// $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):
		
		var elem = $(this);


	
		

		// data('flipped') is a flag we set when we flip the element:
	
		if(elem.data('flipped'))
		{
			// If the element has already been flipped, use the revertFlip method
			// defined by the plug-in to revert to the default state automatically:
			
			elem.revertFlip();
			
			// Unsetting the flag:
			elem.data('flipped',false)
		}
		else
		{
			var ua=navigator.userAgent;
			//alert(ua);
			var img='t-1';
			
			if (ua.search(/MSIE/)>0){
				//alert("it is ie");
				//alert(elem.context.childNodes[0].nameProp);
				img=elem.context.childNodes[0].nameProp;
                		img=img.replace(/.png/,'');
			} else {
				//alert("got firefox");

				/*
				var str='';
				for(prop in elem.context.childNodes[1]) {
					if (elem.context.childNodes[1][prop]!=null && elem.context.childNodes[1][prop] !='') {
						str+=prop + " value :"+ elem.context.childNodes[1][prop]+"\n";
					}
				}
				alert(str);
				*/


				img=elem.context.childNodes[1].src;
				img=img.replace(/http:\/\/hbdservices.com\/img\/clients\//,'');
				img=img.replace(/http:\/\/www.hbdservices.com\/img\/clients\//,'');
                                img=img.replace(/.png/,'');
				//alert(img);	
			}
			//alert(img);
	
                	document.getElementById("t-1").style.display="none";
                	document.getElementById("t-2").style.display="none";
                	document.getElementById("t-3").style.display="none";
                	document.getElementById("t-4").style.display="none";
                	document.getElementById("t-5").style.display="none";
                	document.getElementById("t-6").style.display="none";
                	document.getElementById("t-7").style.display="none";
                	document.getElementById("t-8").style.display="none";

                	document.getElementById(img).style.display="";

			// Using the flip method defined by the plugin:
			
			elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden from view with display:none)
					// into the clicked .sponsorFlip div before the flipping animation starts:
					
					elem.html(elem.siblings('.sponsorData').html());
				}
			});
			
			// Setting the flag:
			elem.data('flipped',true);
		}
	});
	
});

