  $(document).ready(function() {
 
	$('a.jtip').each(function(){
		var valuePDC = $(this).attr('value'); 
		var flag = 0;
			if(isNaN(valuePDC)){
				//alert('not a number');
				getTxt(valuePDC,flag);	
			}else{
				getPDC(valuePDC,flag);	
				$(this).click(function(){
					openTopPDC(valuePDC);
					topVar(pdcname);
					return false;
				});	
			}	
	});
	
	$('area.jtip').each(function(){
		var valuePDC = $(this).attr('value'); 
		var flag = 1;
			if(isNaN(valuePDC)){
				//alert('not a number');
				getTxt(valuePDC,flag);	
			}else{
				getPDC(valuePDC,flag);				
				$(this).click(function(){
					openTopPDC(valuePDC);
					topVar(pdcname);
					return false;
				});	
			}						
	});
	$('.jtip').removeAttr("title");

});

	function openTopPDC(PDC){
		top.openPDC(PDC);	
	}

	function topVar(pdcname){
		top.s.eVar16=pdcname;	
	}
	


	function getTxt(pdcid,flag){
		if(flag==0){
			$('a[value='+pdcid+'].jtip').attr('name',pdcid).attr('title'); 		
			$('a[value='+pdcid+'].jtip').cluetip({
				arrows:  false,
				width:  130, 
				cluezIndex: 999999, 
				splitTitle: '|',
				positionBy: 'auto',
				sticky:    false,
				cluetipClass:'tag',
				titleAttribute:'name',
				escapeTitle:      true,  
				dropShadowSteps:  2,  
				tracking: true
			 }); 
		}else{
			$('area[value='+pdcid+'].jtip').attr('name',pdcid).attr('title'); 		
			$('area[value='+pdcid+'].jtip').cluetip({
				arrows:  false,
				width:  130, 
				cluezIndex: 999999, 
				splitTitle: '|',
				positionBy: 'auto',
				sticky:    false,
				cluetipClass:'tag',
				titleAttribute:'name',
				escapeTitle:      true,  
				dropShadowSteps:  2,  
				tracking: true
			 }); 
		}
	}	
	
	function getPDC(pdcid,flag){
		pdcLINK = '/online/handbags/ProductShortDescriptionJSONView?storeId=10551&catalogId=10051&langId=-1&productIds='+pdcid;
		if(flag==0){
		$.getJSON(pdcLINK, parsePDC);
		}else{
		$.getJSON(pdcLINK, parsePDCarea);
		}
	}

  	function parsePDC(data){
		if (data.products[0].unitPrice == null){
			
		}else{
			var price = convert(data.products[0].unitPrice);	
			$('a[value='+data.products[0].catEntryId+'].jtip').attr('name',data.products[0].productName+'|'+price).attr('title'); 		
			$('a[value='+data.products[0].catEntryId+'].jtip').cluetip({
			arrows:  false,
			width:  130, 
			cluezIndex: 999999, 
			splitTitle: '|',
			positionBy: 'auto',
			sticky:    false,
			cluetipClass:'tag',
			titleAttribute:'name',
			escapeTitle:      true,  
			dropShadowSteps:  2,  
			tracking: true
			  }); 
		}
	}
	function parsePDCarea(data){
	if (data.products[0].unitPrice == null){
		alert('null');
		
	}else{
		var price = convert(data.products[0].unitPrice);	
		$('area[value='+data.products[0].catEntryId+'].jtip').attr('name',data.products[0].productName+'|'+price).attr('title'); 		
		$('area[value='+data.products[0].catEntryId+'].jtip').cluetip({
		arrows:  false,
		width:  130, 
		cluezIndex:  999999, 
		sticky:    false,
		splitTitle: '|',
		positionBy: 'auto',
		cluetipClass:'tag',
		titleAttribute:'name',
		escapeTitle:      true,  
		dropShadowSteps:  2,  
		tracking: true
          }); 
	}		
}

	function convert(price){
		price = parseFloat(price);
		price = price / 100;		
		price = price.toFixed(2);
		price = '$'+price;
		return price;
		//alert(price);	
	}		
