
function bag_drop_down()
{
	var bag = document.getElementById('bag');
//	var bag_number = document.getElementById('bag_number');
//	var bag_txt = document.getElementById('bag_txt');
//	var your_bag = document.getElementById('your_bag');
	//var bag_arrow = document.getElementById('bag_arrow');
	bag.style.visibility = 'visible';
//	bag_number.style.color = '#fff';
//	bag_txt.style.color = '#fff';
//	your_bag.style.backgroundImage = 'url(http://secretsales.com//secretsales.com/_images/v1/v1/new/menu/bag/bag_on.gif)';
//	your_bag.style.color = '#FFFFFF';
	//bag_arrow.src = '//secretsales.com/_images/v1/new/menu/bag/user_menu_arrow4.gif';
}

function bag_hide()
{
	var bag = document.getElementById('bag');
//	var bag_number = document.getElementById('bag_number');
//	var bag_txt = document.getElementById('bag_txt');
//	var your_bag = document.getElementById('your_bag');
	//var bag_arrow = document.getElementById('bag_arrow');
	bag.style.visibility = 'hidden';
//	bag_number.style.color = '#666';
//	bag_txt.style.color = '#666';
//	your_bag.style.backgroundImage = 'url(http://secretsales.com//secretsales.com/_images/v1/v1/new/menu/bag/bag_off.gif)';
//	your_bag.style.color = '#000000';
	//bag_arrow.src = '//secretsales.com/_images/v1/new/menu/bag/user_menu_arrow2.gif';

}

function refreshMiniBasket2() 
{ 
	$.ajax({
		type: "GET",		
		url: 'http://'+location.host+'/basket/mini.php', data: "action=refresh&show=1", 
		success: function(returnData){
			$("#bag").html(returnData);
			//alert('refreshMiniBasket2 '+returnData);
			refreshTotalInBasket2();			
		}
	});
}

function refreshTotalInBasket2() 
{	
	$.ajax({
        type:"GET",
        url:'http://'+location.host+'/basket/mini.php',        
        data: "action=updateTotalInBasketMenu",
        success: function(returnData){
			TotalItemsInBasket = returnData;
			//alert('refreshTotalInBasket2 '+returnData);
			if (0<TotalItemsInBasket) {
				$('#number_items_in_basket').html(TotalItemsInBasket);						
			} else { 
				$('#number_items_in_basket').html(''); 
			}
			if (TotalItemsInBasket != 1)
			{ $('#items_in_bag').html('( '+TotalItemsInBasket+' items )'); }
			else
			{ $('#items_in_bag').html('( '+TotalItemsInBasket+' item )'); }
			
		}
	});
	
	
}

function updateBasket2(optionID,action,quantity) 
{ 
	if (!quantity) {quantity = 1;} 
	
	$.ajax({
        type:"GET",
        url:'http://'+location.host+'/basket/mini.php',        
        data: "action="+action+"&optionID="+optionID+"&quantity="+quantity,
        success: function(returnData){
			$('#bag').html(returnData);
			try { updateDropdownOptions(); refreshTotalInBasket2(); }
			catch(err) { } 
			}
	});
}


function basketExpireControl2() 
{
	$.ajax({
        type:"POST",
        url:'http://'+location.host+'/ajax-index.php',        
        data: "action=checkBasketExpirationTimes",
        success: function(returnData){
			var response = returnData || false;
			
			if (true == response){
				//means some item is about to expire
				//update the basket and show									
				try {
					refreshMiniBasket2();
					bag_drop_down();
				} catch (err) {}
				
				// Updates the checkout basket
				try {
					updateBasketCheckout();	
				} catch (err) {}
			}
			else {
				try {
					refreshMiniBasket2();
				} catch (err) {}
				try {
					updateBasketCheckout();	
				} catch (err) {}
				// all cool - no action needed				
			} 
		}
	});
}

function runtracking2(page){	
	loadtime=(new Date()-startTime); 
	if (page) {
		loadingpage=page;
	} else {
		loadingpage='hp';
	} 
	
	$.ajax({
        type:"GET",
        url: 'http://'+location.host+'/ajax-index.php',        
        data: "action=updatePageLoadingTime&loadtime="+loadtime+"&page="+loadingpage,
        success: function(returnData){}
	});
}


GlobalTimerCounter2 = 0;
GlobalTimerCounterSpeed2 = 20;

function GlobalScroll2() { GlobalTimerCounter2 += GlobalTimerCounterSpeed2; 
	if (1000000 < GlobalTimerCounter2) { GlobalTimerCounter2 = 0; }
	if ( GlobalTimerCounter2%200000 == 0 ) { basketExpireControl2(); }
}

function onPageLoad2() { 
	setInterval('GlobalScroll2()',GlobalTimerCounterSpeed2);	
	try {
		refreshTotalInBasket2();
	} catch (err) {}
}

function countdown(year, month, day, hour, minute, format)
{
	Today = new Date();
	TodaysYear = Today.getFullYear();
	TodaysMonth = Today.getMonth();                  
	
	//Convert both today's date and the target date into miliseconds.                           
	TodaysDate = (new Date(TodaysYear, TodaysMonth, Today.getDate(), 
	                        Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
	TargetDate = (new Date(year, month, day, hour, minute, 00)).getTime();                  
	
	//Find their difference, and convert that into seconds.                  
	TimeLeft = Math.round((TargetDate - TodaysDate) / 1000);
	
	if(TimeLeft < 0)
	   TimeLeft = 0;
	
	
	//More datailed.
	days = Math.floor(TimeLeft / (60 * 60 * 24));
	TimeLeft %= (60 * 60 * 24);
	hours = Math.floor(TimeLeft / (60 * 60));
	TimeLeft %= (60 * 60);
	minutes = Math.floor(TimeLeft / 60);
	TimeLeft %= 60;
	seconds = TimeLeft;
	
	//dps = 's'; hps = 's'; mps = 's'; sps = 's';
	//dps = 's'; hps = ''; mps = ''; sps = '';
	//ps is short for plural suffix.
	if(days<10) days ='0'+days;
	if(hours<10) hours ='0'+hours;
	if(minutes<10) minutes ='0'+minutes;
	if(seconds<10) seconds ='0'+seconds;
	
	document.getElementById('day').innerHTML = days;
	document.getElementById('hour').innerHTML = hours;
	document.getElementById('min').innerHTML = minutes;
	document.getElementById('sec').innerHTML = seconds;
	
	      
	//Recursive call, keeps the clock ticking.
	setTimeout('countdown("' + year + '",' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}

function countdown2(year, month, day, hour, minute, format)
{
	Today = new Date();
	TodaysYear = Today.getFullYear();
	TodaysMonth = Today.getMonth();                  
	
	//Convert both today's date and the target date into miliseconds.                           
	TodaysDate = (new Date(TodaysYear, TodaysMonth, Today.getDate(), 
	                        Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
	TargetDate = (new Date(year, month, day, hour, minute, 00)).getTime();                  
	
	//Find their difference, and convert that into seconds.                  
	TimeLeft = Math.round((TargetDate - TodaysDate) / 1000);
	
	if(TimeLeft < 0)
	   TimeLeft = 0;
	
	
	//More datailed.
	days = Math.floor(TimeLeft / (60 * 60 * 24));
	TimeLeft %= (60 * 60 * 24);
	hours = Math.floor(TimeLeft / (60 * 60));
	TimeLeft %= (60 * 60);
	minutes = Math.floor(TimeLeft / 60);
	TimeLeft %= 60;
	seconds = TimeLeft;
	
	//dps = 's'; hps = 's'; mps = 's'; sps = 's';
	//dps = 's'; hps = ''; mps = ''; sps = '';
	//ps is short for plural suffix.
	
	if (days>0)
	{
		if(days<10) days ='0'+days;
	}
	if(hours<10) hours ='0'+hours;
	if(minutes<10) minutes ='0'+minutes;
	if(seconds<10) seconds ='0'+seconds;
	
	var str = '';
	if(days>1) str = 's';
	//document.getElementById('day').innerHTML = '<span class="white">Ends:</span> '+days+' Day'+str;
	if (days>0)
	{
		document.getElementById('day').innerHTML  = days+' Day'+str;
	}
	else
	{
		document.getElementById('day').innerHTML  = '';
	}
		
	document.getElementById('hour').innerHTML = hours+"<span style='font-size:14px; margin:2px 3px 0 1px;'>h</span>";
	document.getElementById('min').innerHTML  = minutes+"<span style='font-size:14px; margin:2px 3px 0 1px;'>m</span>";
	document.getElementById('sec').innerHTML  = seconds+"<span style='font-size:14px; margin:2px 3px 0 1px;'>s</span>";
	
	      
	//Recursive call, keeps the clock ticking.
	setTimeout('countdown2("' + year + '",' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}






