// JavaScript Document ął

$(document).ready(function(){
/*	$('#simLockContainer .textContainer .pickUpOperator form select').change(function(){		
																				
		var model_id = $(this).val();
		
		$('#simLockContainer .sticksContainer').animate({
			left: '-=440'
		}, 1000, function() {
			
		});	
	
		$('#simLockContainer .textContainer').animate({
			left: '-=440'
		}, 1000, function() {
			$('#simLockContainer .sticksContainer').css('display', 'none');
			$(this).css('position', 'static');
			
			$(this).animate({
				width: '+=440'
			}, 1000, function(){
				simlockOrderGetOperators(model_id);
			});
			
			$('#simLockContainer .pickUpPhoneModel').animate({
				opacity: '+=1'
			}, 1000);									
			
		});	
		
		$(this).unbind('change');
		$(this).change(function(){
			simlockOrderGetOperators($(this).val());
		});
	});
*/
	
	
	$('#simLockContainer .textContainer').css("left","440");
	$('#simLockContainer .sticksContainer').css('display', 'none');
	$('#simLockContainer .textContainer').css('position', 'static');
	$('#simLockContainer .textContainer').css('width', '640');
	simlockOrderGetOperators(280);
	$('#simLockContainer .pickUpPhoneModel').animate({opacity: '+=1'}, 1);
	
	
/*	$('#simLockContainer .sticksContainer').animate({left: '-=440'}, 1, function() {});
	$('#simLockContainer .textContainer').animate({left: '-=440'}, 1, function() {
			$('#simLockContainer .sticksContainer').css('display', 'none');
			$(this).css('position', 'static');
			$(this).animate({
				width: '+=440'
			}, 1, function(){
				simlockOrderGetOperators(280);
			});
			$('#simLockContainer .pickUpPhoneModel').animate({opacity: '+=1'
			}, 1);
		});*/
	$('#simLockContainer .textContainer .pickUpOperator form select').change(function(){
		simlockOrderGetOperators($(this).val());
	});

});

function simlockOrderGetOperators(model_id){
	var container = $('#simLockContainer .textContainer .pickUpPhoneModel div');
	
	if(container.length > 0){
		container.children('table').slideUp('slow', function(){
  			$(this).detach();
	  });		
	}
		
	var rowsSep = '<||>';
	var colsSep = '<|>';
	//load staff
	$.post('simlock_order_get_operators.php', {'model_id': model_id}, function(data) {
		
		data = data.split(rowsSep);
		
		var items = [];
		
		$.each(data, function(i, val) {
			var row = val.split(colsSep);									 
			items.push(
			  '<tr>' + 
					'<td class="name"><a href="simlock_order.php?step=1&model_id=' + row[0] + '">' + row[1] + '</a></td>' +
					'<td class="price">'+ row[3] +'</td>' +
					'<td class="time">'+ row[4] +'</td>' +
				'</tr>'
			);
			
			var classStr = '';
			if(i == data.length-1){
				classStr = ' lastChild';
			}
			
			items.push(
			  '<tr class="line' + classStr + '">' + 
					'<td  class="description" colspan="3">' + row[2] + '</td>' +
				'</tr>'
			);			 
			
		});
	
		$('<table/>', {
			'style': 'display:none',
			html: items.join('')
		}).appendTo('#simLockContainer .textContainer .pickUpPhoneModel div').fadeIn('slow');

	});
}


$(function() {            
	$('a[rel*=lightbox]').lightBox();
});
	

var presentationCookieOptions = 	{ path: '/', expires: 30 };
function showPresentation(){
	$.cookie('isPresentationHidden', false, presentationCookieOptions);
	window.location.href = '/';
	//$('#showPresentationLink').css('display', 'none');
}

function hidePresentation(){
	$('#presentationContainer').css('display', 'none');		
	$.cookie('isPresentationHidden', true, presentationCookieOptions);		
}			

function removeHappyHour(){
	$('#happyHourBox').remove(); 
}


function magnifyMe(elem){
	$(elem).fadeIn("fast", function(){			
		if($(elem).width() > 300){
			$(elem).css('max-width', 'none');
			$(elem).magnify();							
		}
	});
}


//sifr
var mpr = { src:'templates-polphone/flash/sifrMPR.swf' };
sIFR.activate(mpr);

$(document).ready(function(){
	if($('#categoryContaiener').length){
		
		var color = 'ff7000';
		var name = $('#content').attr('class');
		
		if(name == 'spy'){
			color = 'ff7000';
		} else if(name == 'gsm'){
			color = '2a83e8';
		}else if(name == 'gps'){
			color = 'b23467';
		}else if(name == 'gsm'){
			color = '2a83e8';
		}else if(name == 'biometrics'){
			color = '75b53e';
		}else if(name == 'boosters'){
			color = 'a69842';
		}else if(name == 'jammers'){
			color = 'e62f33';
		}else if(name == 'SAT'){
			color = '603913';
		}
		
		sIFR.replace(mpr, {
		  selector: '#categoryContaiener .header h2',
		  css: '.sIFR-root {color: #'+color+';}',
		  wmode: 'transparent'
		});
		
	}
	
});


$(document).ready(function(){									
	$('#ggChatContainer').toggle(
		function() {
			$(this).stop().animate({right: '0'}, 'slow');
			$(this).css('z-index', '11');
		},
		function() {
			$(this).stop().animate({right: '-250px'}, 'slow', function(){
				$(this).css('z-index', '10');
			});
		}
	);
	
	$('#fbLikeBoxContainer').toggle(
		function() {
			$(this).stop().animate({right: '0'}, 'slow');
		},
		function() {
			$(this).stop().animate({right: '-237px'}, 'slow');
		}
	);	
});

//zakladki produkt
$(document).ready(function(){
	$('#productContainer div.pane').hide();
	$("#productContainer ul.tabs").tabs("div.panes div.pane");
});


