﻿$(document).ready(function(){
    $(".ct").live({
      click: function() {
        getc('c', $(this).attr('id'));
      },
      mouseover: function() {
         $(this).addClass("over");
      },
      mouseout: function() {
         $(this).removeClass("over");
      }
    });
    
    $(".pd").live({
      click: function() {
        getc('pd', $(this).attr('id'));
      },
      mouseover: function() {
         $(this).addClass("over");
      },
      mouseout: function() {
         $(this).removeClass("over");
      }
    });
    
    function getc(type, id) {
     //todo: need to get the root url from somewhere
     
     $.ajax({	
            type: "POST",
            url: 'http://www.bennysbikestore.com/Services.asmx/GetItem',
            data: "{'type': '" +id + "'}",   data: "{'type': '" +type + "', 'id': '" +id+ "'}", 
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function(msg) {
                AjaxSucceeded(msg);
            },
            error: AjaxFailed
        });      
        function AjaxSucceeded(result) {
            if(result != null) {
		$(location).attr('href',result);
            }
        }
        function AjaxFailed(result) {
            alert(result.status + ' ' + result.statusText);
        }
     }  
});

