var clickcounter = 0;
//localStorage.torchclickcounter = 0;

$(document).ready(function() {
	$("#vserv_advt_slide, #vserv_advt_slide_popup").click(function(event) {
		localStorage.torchclickcounter = 0;
	});
});


$(document).ready(function() {
	var height = parseInt(($(document).innerHeight() * 2)/3);

	ad_height = parseInt($(document).innerHeight() * 0.6);
	
	$("#vserv_advt_slide li").each(function(){
		$(this).find("img").css("width","100%");
		$(this).find("img").css("height",height-50);
	});

	$("#vserv_advt_slide_popup li").each(function(){
		$(this).find("img").css("width","100%");
		$(this).find("img").css("height",height-50);
	});
	
	$("#clickbank_advt_popup li").each(function(){
		$(this).find("img").css("width","100%");
		$(this).find("img").css("height",ad_height);
	});
});

var advttimer = setInterval(function(){
	$.mobile.changePage('#popup_advt_page', {
		transition : 'pop',
			     role       : 'dialog'
	});
}, 120000);


function torch(pageid)
{
	clickcounter = Number(localStorage.torchclickcounter);


	if(isNaN(clickcounter))
		clickcounter = 0;

	if(clickcounter >= 5)
	{
		alert("Time to buy me a beer. \nKindly click and visit offers. \nYou will get 5 chances.\n(If advt. not shown...plz check your internet connection and reload apps.)");
		$.mobile.changePage("#advt_page", { transition: "slide", changeHash: true});
	}
	else
	{
		if(localStorage.torchclickcounter)
			localStorage.torchclickcounter = Number(localStorage.torchclickcounter) + 1;
		else
			localStorage.torchclickcounter = 1;
		
		$.mobile.changePage(pageid, { transition: "slide", changeHash: true});
	}
}

$(window).load(function(){
	$("#vserv_advt_slide").responsiveSlides({
		"auto": true,
		"pause": false,
		"pauseControls": false,
		"namespace": "rslides",
		"nav": true,
		"maxwidth": 300,
		"maxheight": 300,
		"prevText": "< ",   // String: Text for the "previous" button
		"nextText": " >",       // String: Text for the "next" button
	});	
});

$(window).load(function(){
	$("#vserv_advt_slide_popup").responsiveSlides({
		"auto": true,
		"pause": false,
		"pauseControls": false,
		"namespace": "rslides",
		"nav": true,
		"maxwidth": 300,
		"maxheight": 300,
		"prevText": "< ",   // String: Text for the "previous" button
		"nextText": " >",       // String: Text for the "next" button
	});	
});

$(window).load(function(){
	$("#clickbank_advt_popup").responsiveSlides({
		"auto": true,
		"pause": false,
		"pauseControls": false,
		"namespace": "rslides",
		"nav": true,
		"maxwidth": 300,
		"maxheight": 300,
		"prevText": "< ",   // String: Text for the "previous" button
		"nextText": " >",       // String: Text for the "next" button
	});	
});


$(window).load(function(){
	$("#clickbank_advt1").responsiveSlides({
		"auto": true,
		"pause": false,
		"pauseControls": false,
		"namespace": "rslides",
		"nav": true,
		"maxwidth": 300,
		"maxheight": 300,
		"prevText": "< ",   // String: Text for the "previous" button
		"nextText": " >",       // String: Text for the "next" button
		
	});
});

$(window).load(function(){
	$("#clickbank_advt2").responsiveSlides({
		"auto": true,
		"pause": false,
		"pauseControls": false,
		"namespace": "rslides",
		"nav": true,
		"maxwidth": 300,
		"maxheight": 300,
		"prevText": "< ",   // String: Text for the "previous" button
		"nextText": " >",       // String: Text for the "next" button

	});
});
///////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
