


function loadXml(urlxml, thisis){
	var checked = 0;
	var found = null;
         if(urlxml == "")return; 
        // Parsing happens here
		urlxmllower = urlxml.toLowerCase();
		 
        var nurlxml = urlxmllower.replace("www\.","").replace(/\s*$/,"");
        $('#'+ thisis + ' .countefeitWarrning'  ).fadeIn("slow");
		$('#'+ thisis  + ' .countefeitWarrning'   ).animate({ 
				height: "150px"
			  }, 1500 );
		
        $(dataNew).find("website").each(function() {
			//console.debug(this);
			var aa = $(this).find("url").text().toLowerCase();
			if(aa == nurlxml){
			 
				if($(this).attr("authorized").toLowerCase() == "no"){
					$('.countefeitWarrning p').html("<img src='/images/counterfeit/NOTauthorized_onlineRetailer.gif' alt='This is a NOT an Authorized Online Retailers' />");
					$('.countefeitWarrning').addClass("counterfeitWarn");
						
						
						s.linkTrackVars='eVar32,events'; 
						s.linkTrackEvents='event29'; 
						s.eVar32 = urlxml; 
						s.events='event29'; 
						s.tl();  
						
					 found = "notauthorized";
					 return;
				}
				
			}
			
		});
		checked++;
		//console.debug(checked)
		$(dataNew2).find("website").each(function() {
			//console.debug(this);
			var bb = $(this).find("url").text().toLowerCase();
			if( bb == nurlxml ){
			 
				if($(this).attr("authorized").toLowerCase() == "yes"){
					$('.countefeitWarrning p').html("<img src='/images/counterfeit/authorized_onlineRetailer.gif' alt='This is an UGG Australia Authorized Online Retailers' />");
					$('.countefeitWarrning').addClass("authorizedWarn");
						
						
						s.linkTrackVars='eVar32,events'; 
						s.linkTrackEvents='event30'; 
						s.eVar32 = urlxml; 
						s.events='event30'; 
						s.tl();  
					   
					found = "authorized";
					return;
				}
				
			}
				
		});
		checked++;
		//console.debug(checked)
		if(checked == 2 && found == null){
			$('.countefeitWarrning p').html("<img src='/images/counterfeit/nodata_authorized_onlineRetailer.gif' alt='This Online Retailers is not in our database' />");
			$('.countefeitWarrning').addClass("noRecWarn");	
			$('.preloader').css('display', 'none');	 
						
						
						s.linkTrackVars='eVar32,events'; 
						s.linkTrackEvents='event31'; 
						s.eVar32 = urlxml; 
						s.events='event31'; 
						s.tl(); 
		}
		$('.preloader').css('display', 'none');
		

}


function checkUrl(url, thiis){
	 
	loadXml(url, thiis);

}

/* create a lookback for js regex */
String.prototype.reverse = function () { return this.split('').reverse().join('');};



$(document).ready(function() {
	$(".fancy").fancybox();
	$.ajax({
    url: "/Count_counterfeitLookUp.xml",
    dataType: "xml",
    success: function(data){dataNew = data;}});
    
    $.ajax({
    url: "/Auth_counterfeitLookUp.xml",
    dataType: "xml",
    success: function(data2){dataNew2 = data2;}});
    

	$('.on').each(function() {
			var newImage = $(this).attr('src').replace(/^(.*?)(\.(?:gif|jpg|png))$/, "$1_over$2"); //adjust for your scheme
			$(this).attr('src', newImage);
	  });
	$('img.rollover').hover(
		function() {
		//over
			if($(this).is('.off')){
				var newImage = $(this).attr('src').replace(/^(.*?)(\.(?:gif|jpg|png))$/, "$1_over$2"); //adjust for your scheme
				$(this).attr('src', newImage);
			}
		},
		function() {
			//out
			if($(this).is('.off')){
				var newImage = $(this).attr('src').replace('_over', '');
				$(this).attr('src', newImage);
			}
		}
	);
	$("img.rollover").click(function () { 
			if($('#counterfeitgallery').is(':visible') ){
				
				$("#counterfeitgallery").fadeOut('slow');
				$("#lifimage").fadeIn('fast');
			
			}
			$('.on').each(function() {
				
				var newImage = $(this).attr('src').replace('_over', '');
				$(this).attr('src', newImage);
				$(this).removeClass('on');
				$(this).addClass('off');
				$('#'+ $(this).attr("divtoopen")).fadeOut("fast");
				
			});/**/
			$(this).removeClass('off');
			$(this).addClass('on');
			var newImage = $(this).attr('src').replace('_over',  "_over"); //adjust for your scheme
			$(this).attr('src', newImage);	
			$('#'+ $(this).attr("divtoopen")).fadeIn("slow");
			$('#leftContent').css("height",$('#'+ $(this).attr("divtoopen")).height());
			 $(".countefeitWarrning").fadeOut('fast');

    });
	$(".closediv").click(function () { 
	 found = null
       $(".countefeitWarrning").animate({height: "0" }, 1000, function(){  $(".countefeitWarrning").fadeOut('fast'); }  );
       
    });
    $("#howto").click(function () { 
		
		$("#counterfeitgallery").fadeIn('slow');
		$("#lifimage").fadeOut('fast');
		
       
    });
   $(".enterLookup").click(function () { 
		$('.countefeitWarrning p').html("");
		$('.preloader').css('display', 'block');
		checkUrl($('#'+ $(this).parent().attr("xwho")).val(), $(this).parent().attr("id"));
		  
       
    });
 });
