	//Cufon  font replacement
	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('h3');
	Cufon.replace('h4');
	Cufon.replace('h5');
	Cufon.replace('#banner_left p');	
	Cufon.replace('#header_nav a',  {textShadow: '0px 1px #fff' , hover: true});
	
	
	
	
	
		
		function greyPage()
		{
			
			
		
			$("#grey_layer").css('height',$(document).height()+'px');
			$("#grey_layer").css('opacity','0.25');
			$("#grey_layer").fadeIn(1500)
			
			
			
			
			}


		function closeP()
			{
			
			  $("#full_detail").fadeOut("slow");
			  $("#grey_layer").hide();
			 window.document.getElementById("full_detail").innerHTML ='';
			
			}
		
		
		function showProduct(id)
		{
		 
		 greyPage();

		 //get the top and left positions we need to centre
					
						
							var top = $(window).scrollTop() + 150;
						
					
				
				
				
				
				
				window.document.getElementById("full_detail").style.top = top + 'px';//place the layer
				
				  $("#full_detail").fadeIn(2000);
				  
				 	 
				 
		  window.document.getElementById("full_detail").innerHTML = '<img src="http://www.flowebdesign.ie/library/ajax-loader2.gif" alt="Please wait" width="16" height="16" />&nbsp;&nbsp;&nbsp; Please wait while the detail is loading';
				 
				  //then call the detail
				  //call ajax when the function is called
				$.ajax({
				
						type: "GET",
						url: "../ssi/ajax_prod_detail.asp",
						data: {prodId: id},
						success: function(dataBack){
												
												window.document.getElementById("full_detail").innerHTML = '<div style="margin-left: 720px;"><a href="javascript:closeP()"><img src="https://www.costasystems.ie/library/button_close_green.png" alt="Close the window" border="0" /></a></div>' + dataBack + '<br /><a href="javascript:closeP()"><img src="https://www.costasystems.ie/library/button_close_green.png"  alt="Close the window" border="0" /></a>';
												//alert(dataBack)
												
												
												$('#slider-one').movingBoxes({
														startPanel  : 1,     // start with this panel
														width       : 800,   // overall width of movingBoxes
														panelWidth  : .5,    // current panel width adjusted to 50% of movingBoxes width
														reducedSize : .2,    // non-current panel size: 80% of current panel size
														imageRatio  : 4/3,   // Image ratio set to 4:3
														speed       : 500,   // animation time in milliseconds
														fixedHeight : true,  // if true, slider height set to max panel height; if false, slider height will auto adjust.
														hashTags    : true,  // if true, hash tags are enabled
														wrap        : false  // if true, the panel will "wrap" (it really rewinds/fast forwards) at the ends
												   });
												
												
												
											}
				
				
				
				
				});
				  
				  
			
		 
		 
		 
		 
		 //alert('product '+ id)
		 
		 
		 }//end function



$(document).ready(function() {
	$('.fadeThis').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(250, 1);
	  }, function () {
	    $span.stop().fadeTo(250, 0);
	  });
	});
	
	
	
	$('.moredetail').click(function() {
									
	var id = $(this).attr('id');
	id = id.substring(6,id.length)
  		
  showProduct(id);
  return false;
  
  
  			
});
	
	
});


/**********************  add cart  *************************/




function updateMiniB()
{
	
	//call ajax when the function is called
				$.ajax({
				
						type: "GET",
						url: "https://www.costasystems.ie/ssi/ajax_mini_cart.asp",
						data: {mmId: 'value1'},
						success: function(dataBack){
												
												//alert("The data sent back is: " + dataBack)
												
												var content = '<img src="https://www.costasystems.ie/library/basket_top.jpg" alt="Your Basket" /><h3>Your Basket</h3>' + dataBack + '<p id="basket_links"><a href="https://www.costasystems.ie/view_cart.asp">Update Basket</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="https://www.costasystems.ie/checkout">Checkout</a></p><img src="https://www.costasystems.ie/library/basket_bottom.jpg" alt="Your Basket" />'
												
												$('#mini_cart_content').html(content)
											},
											error: function(x,e){
																if(x.status==0){
																alert('You are offline!!\n Please Check Your Network.');
																}else if(x.status==404){
																alert('Requested URL not found.');
																}else if(x.status==500){
																alert('Internel Server Error.');
																}else if(e=='parsererror'){
																alert('Error.\nParsing JSON Request failed.');
																}else if(e=='timeout'){
																alert('Request Time out.');
																}else {
																alert('Unknow Error.\n'+x.responseText);
																}
															}
																	
					});

	
}


















		function addCart(form_name)
		{
			
			//alert(document[form_name].qty.value);
			
			$.ajax({
				
						type: "POST",
						url: "https://www.costasystems.ie/ecom_scripts/add_cart_ajax.asp",
						data: {cur_session: document[form_name].cur_session.value, prodId: document[form_name].prodId.value, qty: document[form_name].qty.value, prod_name: document[form_name].prod_name.value},
						success: function(dataBack){
												
												//alert("The data sent back is: " + dataBack)
												
												//check for errors
												if (dataBack.substring(0,1)=='0')
												{
														if (dataBack.substring(0,11)=='0mini_order')
														{
														 alert('Error, the minimum order for this product is ' + dataBack.substring(11,dataBack.length))
														 	//alert("Error, the minimum order for this product is "dataBack.substring(11,dataBack.length))
														}
														else
														{
															alert('An error occured, please review your selection and submit again')
															
														}
												}//end of error
												else
												{
													//alert('success')
													//output confirmation
													var comment = '<br /><p>Confirmation</p><p><strong>'+document[form_name].qty.value+'</strong> X <strong>'+document[form_name].prod_name.value+'</strong>';
													
													if (document[form_name].qty.value==1){comment = comment + ' has been added to your Basket.</p>'}
													else {comment = comment + ' have been added to your Basket.</p>'}
													
													comment = comment + '<br /><br /><p>you can checkout at any time or modify your basket by using the links to the left of the page.</p><br />';
													
													
													var top = $(window).scrollTop() + 350;
						
				
														window.document.getElementById("added_cart_confirm").style.top = top + 'px';//place the layer
													
													
													$('#added_cart_confirm').html(comment)
													
													$('#added_cart_confirm').fadeIn('slow').delay(2000).fadeOut(1000);
													
													$('#full_detail').delay(3000).fadeOut(2000);
													$('#grey_layer').delay(3000).fadeOut(3000);
													
													//$('#full_detail').delay(5000).html('');
													
													updateMiniB();
													
													
												}//end of no error
												
												
												
												
												
												
												
												
											},
											error: function(x,e){
																if(x.status==0){
																alert('You are offline!!\n Please Check Your Network.');
																}else if(x.status==404){
																alert('Error: Requested URL not found.');
																}else if(x.status==500){
																alert('Internel Server Error.');
																}else if(e=='parsererror'){
																alert('Error.\nParsing JSON Request failed.');
																}else if(e=='timeout'){
																alert('Request Time out.');
																}else {
																alert('Unknow Error.\n'+x.responseText);
																}
															}
																	
				
				
				
				});

			
			
			
			
			
		}



function ValidationCheck(form_name,attrib) {
var error=0;


if (document[form_name].qty.value=="" || document[form_name].qty.value==0){
                alert("Please enter a valid quantity");
                return false;
				error = 1;
        }	
		
		

		
		//see if there is attributes used
		if (attrib!='')
		{
		
				//we spllit and loop
				attrib = attrib.split(",");
				
						for (i=0;i<attrib.length;i++)
						{
								//then we validate each item
								
								//eval('document.form1.'+from+'.value')
								if (eval('document.'+form_name+'.'+attrib[i]+'.value')==""){
								
								var thisN = attrib[i].substring(0,attrib[i].lastIndexOf("_"))
								
								alert("Please enter a "+repSpace(thisN)+"");
								return false;
								error = 1;
								
								
									}	
						
						}//closes the for loop
		
		}//end of if there is attributes

	if (error==0)
	{
		addCart(form_name);
		
	}
	
	
return false;//return false as we go to ajax
}



//top slider

	//starting the image slider
						
						
					
$(document).ready(function() {
						   
   $('#newsticker').cycle({
	delay:  500,
		fx:  'scrollUp' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});	
});



