

// jQuery ------------------------------------------------------------------------------//
$(document).ready(function(){
	activeURL = window.location.protocol + "//" + window.location.host;						   
	
	$('#voter').starRating({
                        sucess:thanks,
                        failure:voted,
			basicImage : 'http://www.wikilime.net/images/star_grey.png',
			ratedImage : 'http://www.wikilime.net/images/star_gold.png',
			hoverImage : 'http://www.wikilime.net/images/star_gold.png',
			ratingUrl : activeURL+'/code/starrate.cfm'

                });
                return false;
						   
// End -------------------------------------------------------------------------------- //
});

function checkOutShipping(gateway, shipping) {
	document.location.href=activeURL+'/code/mastercode.cfm?action=checkOutPaypal&shippingCountry='+shipping;	
}

function checkOut(gateway) {
	document.location.href=activeURL+'/code/mastercode.cfm?action=checkOutPaypal';	
}

function updateCart(){
	var options = {
	url:	activeURL+'/code/mastercode.cfm', 
	success: function() {
		$("#checkoutOverview").load(activeURL+"/includes/tpl_checkoutOverview.cfm");
		$("#leftPanelStatus").load(activeURL+"/includes/tpl_leftPanelStatus.cfm");
		//setTimeout("hideLoader()",2000);
		} };
		
	$('#form_checkout').ajaxSubmit(options); 	
}

function addCart(){
		
	var options = {
	url:	activeURL+'/code/mastercode.cfm', 
	success: function() {
		document.location.href=activeURL+'/basket';
		//setTimeout("hideLoader()",2000);
		} };
		
	$('#form_addcart').ajaxSubmit(options); 	
}


function showCart() {
	$("#cart").slideDown(600);
	$("#viewCart").html("<a href=\"javascript:hideCart();\">Hide cart</a>");
	$.cookie('cartStatus', 'down',  { path: "/" });


}

function hideCart() {
	$("#cart").slideUp(600);
	$("#viewCart").html("<a href=\"javascript:showCart();\">View cart</a>");
	$.cookie('cartStatus', 'up', { path: "/" } );

}

function item_flash(id, permalink) {	
		$("#item_hover"+id).fadeIn(50, function(){
													$("#item_hover"+id).fadeOut('slow', function() {
																								 document.location.href=permalink; }); }); }

function navFlash(id,page) {	
		$("#navClick_"+id).fadeIn('fast', function(){
													$("#navClick_"+id).fadeOut(100, function() {
																								 document.location.href=activeURL+page; }); }); }

function deleteItem(id, sku, itemOption){
		var txt="Are you sure you want to remove this item from your basket?"
        if (!confirm (txt)) return;
        deleteItemB(id, sku, itemOption); }

function deleteItemB(id, sku, itemOption) {
	$("#item_"+id).fadeOut('fast');

	$.ajax({
   		type: "POST",
   		url: activeURL+"/code/mastercode.cfm",
   		data: "action=remove&id="+id+"&itemSku="+sku+"&itemOption="+itemOption,
		success: function(){
			$("#checkoutOverview").load(activeURL+"/includes/tpl_checkoutOverview.cfm");
		$("#leftPanel").load(activeURL+"/includes/tpl_leftPanel.cfm");
   		} });
}

function fadeForm() {
	$("#form_contact").fadeOut('slow', function() {
												$("#contactThankyou").slideDown(); }); }

function sendContact(){
		
	var options = {
	url:	activeURL+'/code/mastercode.cfm', 
	success: function() {
		fadeForm();
		} };
		
	$('#form_contact').ajaxSubmit(options); 	
}

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}


function showPic(img_src) {
	img_src2 =  window.location.protocol + "//" + window.location.host + "/users/" + window.location.host + "/images/big_" + img_src;
	img_src =  window.location.protocol + "//" + window.location.host + "/users/" + window.location.host + "/images/main_" + img_src;
	document.getElementById('imageLink').href = img_src2;
	movepic('pix1',img_src);	
}


   
    
  function voted() {
        alert("Already voted");
  }
  
  function thanks() {
        alert("Thanks for voting!");
  }
