// JavaScript Document

/*
* DESCRIPTION: standard interface functions
* AUTHOR: One Eleven Software
* DATE: 6/25/2010
*/


$(function() {

	banner1 = {
				headerText : "<h1>Reach more physicians<br/>on more channels while<br/> controlling sample allocation.</h1>",
				images : "<img src='/wp-content/themes/oneelevensoftware/images/epocs-iso.png' align='right' width='420' height='386' style='float:right'/>"								
				};
				
	banner2 = {
				headerText : "<h1>A sampling engine without restrictions.</h1>",
				images : "<img src='/wp-content/themes/oneelevensoftware/images/portal-iso.png' align='right' width='528' height='386' style='float:right'/>"
				};
				
	slides = new Array(banner1,banner2);
	
	startIndex = randomize(slides);
	//backgroundCSS = 'url(../images/' + slides[startIndex].image + ') top center no-repeat transparent';

	//randomize text and images
		x = startIndex;
		var rotationText = "";
		var rotationImage = "";
		
		for(i=0;i< slides.length ;i++){
			if(x == slides.length) { //past index, reset to zero
				x = 0;
			}
			
			rotationText += slides[x].headerText;
			rotationImage += slides[x].images;
			x++;
		}
		
	$("#rotation-text").html(rotationText);
	$("#rotation-images").html(rotationImage);
	
	startRotation();
	
	
	
	//Other bindings
	
	$("#scheduleDemo, #hide").click(function(){
		$("#schedule-details").slideToggle("slow");
	});
	
		/* CONTACT US */				
	_height = "500px";
	_width = "440px";

    _opacity = .75;
	$(".contactUs, #submit-a-comment").colorbox({height:_height,
							width:_width,
							initialHeight:"520px",
							initialWidth:"500px",
							href:"/contact",
                            opacity:_opacity
                        });
                      
    // TWITTER 

    	$("#twitter-feed").getTwitter({
					userName: "one11software",
					numTweets: 1,
					loaderText: "Loading tweets...",
					slideIn: false,
					slideDuration: 750,
					showHeading: false,
					headingText: "Latest Tweets",
					showProfileLink: false,
					showTimestamp: false
          });

    
	//Privacy Policy Link
		$(".privacy, .privacyClose").click(function(e){
			togglePrivacy();
			e.preventDefault();
		});
	
});

function togglePrivacy(){
	$("#signupSampling").slideToggle();
	$("#privacyPolicy").slideToggle();
}



function randomize(array_String) {
	var count = array_String.length;
	return Math.floor(Math.random() * count);
}

function startRotation(){
	$("#rotation-images").cycle({
		fx: 'fade',
        	timeout: 6000,
		speed: 1000		
	});
	

	$("#rotation-text").cycle({
		fx: 'fade',
		timeout: 6000,
		speed: 1000
	});
	
}



