$(function() {
	var countrycode = $('#countrycode').text();	
	var contextpath = $('#contextPath').text();
	$(".contactpop").fancybox({
		href			:  countrycode + 'contactus.html',
		ajax : {
		    type	: "POST",			
		    data	: 'country=' + countrycode 
		},
		'scrolling'		: 'no',
		'callBackOnShow': function() { $('#fancybox-wrap').hide(); $.fancybox.showActivity();}
	});
	
	$(".enewssubscribe").fancybox({
		ajax : {
		    type	: "POST",
		    data	: 'country=' + countrycode 
		},
		'scrolling'		: 'no',
		'callBackOnShow': function() { $('#fancybox-wrap').hide(); $.fancybox.showActivity();}
	});
	
	$(".ordernow").fancybox({
		ajax : {
		    type	: "POST",
		    data	: 'country=' + countrycode 
		},
		'scrolling'		: 'no',
		'callBackOnShow': function() { $('#fancybox-wrap').hide(); $.fancybox.showActivity();}
	});
	
	$(".emailtofriend").fancybox({
		ajax : {
		    type	: "POST",
		    data	: 'country=' + countrycode 
		},
		'scrolling'		: 'no',
		'callBackOnShow': function() { $('#fancybox-wrap').hide(); $.fancybox.showActivity();}
	});
	
	$(".callibm").fancybox({
		ajax : {
		    type	: "POST",
		    data	: 'country=' + countrycode 
		},
		'scrolling'		: 'no',
		'callBackOnShow': function() { $('#fancybox-wrap').hide(); $.fancybox.showActivity();}
	});
});

function toggleCountryList(){
	var list = document.getElementById("countrylist");
			
	if( list.style.display == "none" ){
		document.getElementById("search-box").style.display = "none";
		document.getElementById("countrylist").style.display = "block";
		document.getElementById("btnCountryChange").innerHTML = "Hide";
	}
	else{
		document.getElementById("search-box").style.display = "block";
		document.getElementById("countrylist").style.display = "none";
		document.getElementById("btnCountryChange").innerHTML = "Change";
	}
}

$(function() {
	$('#search-box-text').live('keyup', function(e) {
		if (e.keyCode == '13') {			
			$('#searchform').submit();
		}
  });
  
	$('a.product_tab').live('click', function(e) {
		var id = $(this).attr('title');
		
		$('.specs-cell').each(function() {
			$(this).hide();
	    });
	    $('#' + id).show();
  });
  
	$('#productsearch-button').live('click', function(e) {
		var srv = $("#server_loc option:selected").val();
		var sto = $("#storage_loc option:selected").val();
		
		if (srv == '' && sto == '') {
			alert("Please select an option");
			return false;
		}
		
		if (srv != '') {
			$("#loc").val(srv);
			$("#op").val($("#server_loc option:selected").text());
		}
		
		if (sto != '') {
			$("#loc").val(sto);
			$("#op").val($("#storage_loc option:selected").text());
		}
		
		var price = $("#price option:selected").val();
		
		var substr = price.split('-');
		
		$("#pr").val($("#price option:selected").text());
		
		$("#min").val(substr[0]);
		$("#max").val(substr[1]);
		
		$("#productsearchform").submit();

	});
});


