//this is jquery  //////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){	
////////////////////////////////////////////////////////////////////////////////////////////////////////


// ALL FLASH IS EMBEDDED USING flashembed - documentation can be found here: 
//http://flowplayer.org/tools/toolbox/flashembed.html
// --------------------------------------------------------------
// --------------------------------------------------------------


// embed flash logo
flashembed("logo", {
src: "/flash/HK_LOGO.swf",
version: [9, 0] ,
wmode: 'transparent'
});
$('#logo').append('<a class="cursorfix" href="/">Hed Kandi</a> ');

//embed the FLASH sparkles
$(function() {
$(".sparkle").each(function() {
flashembed(this, {
src: 'flash/sparkle_small.swf', 
wmode: 'transparent'
});
});
});


//embed the FLASH 'camera flash effect'
$(function() {
$("#big_flash").each(function() {
flashembed(this, {
src: 'flash/big_flash.swf', 
wmode: 'transparent'
});
});
});




//embed the HOME PAGE MAIN FEATURE
/* $(function() {
$("#homemainfeature").each(function() {
flashembed(this, {
src: 'flash/home_fashion_feature1.swf', 
wmode: 'transparent'
});
});
});
*/






//embed the FLASH Map to parties
$(function() {
$("#partymap").each(function() {
flashembed(this,{ src: "/flash/flashmap.swf"/*,   wmode: 'transparent'*/},{
australia_no :  australia,
UK_no :  UK,
europe_no :  europe,
Asia_no :  Asia,
Northamerica_no :  Northamerica,
Southamerica_no :  Southamerica,
centralamerica_no :  Centralamerica,
Middleeast_no :  Middleeast,
africa_no :  Africa
});

});
});




// --------------------------------------------------------------
// --------------------------------------------------------------




// the fashion feature on the homepage 
$('#thefashionfeaturecycle').cycle({ timeout: 4000, delay: 100, speed: 1000}); 
















// MUTE controls on videos - just add 'needsmute' class to the video div or span
// BUT THE FLASH <OBJECT> TO MUTE MUST HAVE THE ID: 'mainvid' and contain the functions to be called.
//$(".needsmute").prepend("<span class='mute'>MUTE</span>");
//$(".needsmute").prepend("<span class='unmute'>unMUTE</span>");


function kill() { var flash = document.getElementById("mainvid"); flash.killsound();}
function give() { var flash = document.getElementById("mainvid"); flash.givesound();}

// MUTE: change the icon and tell flash to mute 
$(".needsmute .mute").click (function(){
kill();
$(".needsmute .mute").hide();
$(".needsmute .unmute").show();
});

// UNMUTE: change the icon and tell flash to give sound back 
$(".needsmute .unmute").click (function(){
give();
$(".needsmute .unmute").hide();
$(".needsmute .mute").show();
});




// SPECIAL HOVERS ON THE FASHION HOME PAGE
function specialhover(){
$(".specialhover").each(function(){
$(this).append('<img src="' + $(this).attr("rel") +'" alt="" class="specialhoverimage" />');
});


$(".specialhover").hover(function(){
$(this).find('.specialhoverimage').stop(true, true).fadeIn('slow');
$(this).find('.sparkle').css({'display':'block'});
},function(){
$(this).find('.specialhoverimage').stop(true, true).fadeOut('slow'); //.css({'display':'none', 'visibility':'hidden'});
$(this).find('.sparkle').css({'display':'none'}); 
});
}

specialhover();








// PARTY BUCKET HOVERS

$('.partysmallvid').hover(function(){
var $clone = $(this).find('.hovervid').clone().removeClass('hovervid').addClass('hovervidClone');
$(this).find('.hovervid').after($clone);
$(this).find('.hovervid').stop(true, true).fadeIn('slow');
}, function(){
$(this).find('.hovervid').stop(true, true).fadeOut('slow', function(){
$(this).next().removeClass('hovervidClone').addClass('hovervid');
$(this).remove();
});
}
);

// PARTYHOME  MAIN VID
$('#partymainfeature .partymainvid').clone().removeClass('partymainvid').addClass('partymainvidclone').appendTo($('#partymainfeature'));

$("#partymainfeature .partyPlayVideo").click(function() {
$('.partymainvid').show();
$('.partymaintitle').hide();
$('.partymainvidclone').hide();
$('#partymainfeature .partymainvid').flashembed({
src : "/flash/imagedriver_largevid.swf", 
id: "mainvid", wmode: 'transparent'
},{
//vidfile: ('/Uploads/Parties/'+($(this).attr("title"))), 
vidfile: '/Uploads/Parties/image_driver_ibiza.flv',
soundlevel: 50 
});
$(this).hide();
//$('.mute').show();
$('#partymainfeature').append('<span class="partyStopVideo"></span>');
});

$('.partyStopVideo').live('click', function(){
$('.partymaintitle').fadeIn('slow');
$('.partymainvidclone').fadeIn(200, function(){
$('.partymainvid').empty();
});
$(this).remove();
//$('.mute').hide();
$('.partyPlayVideo').fadeIn('slow');
});

//embed the FLASH party2 hovervid
$(function() {
$(".partysmallvid .hovervid").each(function() {
flashembed(this, {
src: ('/Uploads/Parties/'+($(this).attr("title"))), 
wmode: 'transparent'
});

});
});


// if the user has no flash (if they are using mobile safari) do not show the play button
function isIPad() {
return /iPad;.U/.test( navigator.userAgent );
}

function isIPhone() {
return /iPhone;.U/.test( navigator.userAgent );
}

var iPad   = isIPad();
var iPhone = isIPhone();

if( iPad || iPhone ) {
$(".partyPlayVideo").hide();  //alert('Jamie has an iPhone');
$('.singlesPreview').hide();
$('.mediaplayerlink').hide();
// XXX $('.showcatwalk').parent().remove();
}







// EMPTY THE SEARCH FIELD ON FOCUS
$('.searchinput').focus(function() {
if( this.value == this.defaultValue ) {
this.value = ""; 
$(this).css({'color':'black'}); 
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
$(this).css({'color':'#999999'}); 
}
});


// detect for IE6 (for functions NOT to be called if IE6 )
if(typeof document.body.style.maxHeight === "undefined") {
//        alert('ie6 is not good for you');
} else {
//  alert('yay');
}


// attislideshow
// this applies the thumbnail hover slideshow on the fashion product thumb listings
$(".showslide").hover(function(){
if ($.browser.msie) {
$(this).css('z-index', '9999');
} 
$(this).append("<div class='thumbslideshow'><a href='" + $(this).attr("href") + "'><img  src='"+ $(this).attr("rel") +"' alt='' /></a></div>");
// $(this).append("<div class='thumbslideshow'><img  src='"+ $(this).attr("rel") +"_1.jpg' alt='' /><img  src='"+ $(this).attr("rel") +"_2.jpg' alt='' /><img  src='"+ $(this).attr("rel") +"_3.jpg' alt='' /></div>");

// slideshow is disabled for now...
// $('.thumbslideshow').cycle({ timeout: 10, delay: 10}); 
},function(){


if ($.browser.msie) {
$(this).css('z-index', '1');
}

$(".thumbslideshow").remove();
}); 




// OTHER VIEWS CONTENT SLIDER ///// START ////////////////////////////////////////////////////////    
var otherviewslider = $("#otherviewthumbs #otherviewslider");
var findoutsliderlength = ($('#otherviewslider > a').size()) * 70 ;
$(otherviewslider).css({"width" : (findoutsliderlength + 11)  });

// set some css to make the slider work 
$(otherviewslider).css({"position" : "absolute" });
$("#otherviews #otherviewslidercontainer").css({  "height" : "80px",  "position" : "relative"});

// if there are more than 1 other views
if (($('#otherviewslider > a').size()) > 1) {
$('#otherviews  h3.otherviewstitle').show();
$('#otherviews #otherviewthumbs').show();
}

// if there are more than 3 other views 
if (($('#otherviewslider > a').size()) > 3) {
$('#otherviews #otherviewthumbs .nextviews').show();
$('#otherviews #otherviewthumbs .prevviews').show();
}

var themaximumslideingwidth = (parseInt($(otherviewslider).css('width'))) - 229 ;

//alert(findoutsliderlength);
function slideleft() { $(otherviewslider).filter(':not(:animated)').animate({ "margin-left" : "+=72px"}, 800 ); }
function slideright() {$(otherviewslider).filter(':not(:animated)').animate({ "margin-left" : "-=72px"}, 800 ); }

$("#otherviewthumbs .prevviews").click(function(){
if (parseInt($(otherviewslider).css('margin-left')) > -1) {} 
else {slideleft();}
return false;
});

$("#otherviewthumbs .nextviews").click(function(){

if (parseInt($(otherviewslider).css('margin-left')) < -themaximumslideingwidth )   {}  
else {slideright();}
return false;
});

// OTHER VIEWS CONTENT SLIDER ////////// FIN ///////////////////////////////////////////////////   



// THIS LOOKS HOT WITH CONTENT SLIDER ///// START ////////////////////////////////////////////////////////    
// (should have made this into a function and used with above - but, Hey Ho...)
var lookshotwithslider = $("#lookshotwiththumbs #lookshotwithslider");
var findoutlookshotwithsliderlength = ($('#lookshotwithslider > a').size()) * 70 ;
$(lookshotwithslider).css({"width" : (findoutlookshotwithsliderlength + 9)  });

// set some css to make the slider work 
$(lookshotwithslider).css({"position" : "absolute" });
$("#otherviews #lookshotwithslidercontainer").css({  "height" : "80px",  "position" : "relative"});

// if there are more than 1 other views
if (($('#lookshotwithslider > a').size()) > 0) {
//$('#otherviews  h3.otherviewstitle').show();
$('#otherviews #lookshotwiththumbs').show();
}

// if there are more than 3 other views 
if (($('#lookshotwithslider > a').size()) > 3) {
$('#otherviews #lookshotwiththumbs .nextviews').show();
$('#otherviews #lookshotwiththumbs .prevviews').show();
}

var themaximumlookshotwithslideingwidth = (parseInt($(lookshotwithslider).css('width'))) - 229 ;

//alert(findoutsliderlength);
function hotslideleft() { $(lookshotwithslider).filter(':not(:animated)').animate({ "margin-left" : "+=72px"}, 800 ); }
function hotslideright() {$(lookshotwithslider).filter(':not(:animated)').animate({ "margin-left" : "-=72px"}, 800 ); }

$("#lookshotwiththumbs .prevviews").click(function(){
if (parseInt($(lookshotwithslider).css('margin-left')) > -1) {} 
else {hotslideleft();}
return false;
});

$("#lookshotwiththumbs .nextviews").click(function(){

if (parseInt($(lookshotwithslider).css('margin-left')) < -themaximumlookshotwithslideingwidth )   {}  
else {hotslideright();}
return false;
});

// THIS LOOKS HOT WITH CONTENT SLIDER ////////// FIN ///////////////////////////////////////////////////   



// OTHER VIEWS SWITCH MAIN IMAGE /////// START //////////////////////////////////////////////////////    
$(".showotherview").click(function(){ 
$("#proddetails .testcatwalk").remove();
$("#proddetails .testcatwalk_demo").remove();
$(".catwalkplay").css({"background-image" : "url(/images/branding/buttons/play.png)"});

function changethephoto() {  
$('.imagezoom').attr("src" , thenewimagedetail);
$('.imagezoom').attr("alt" , thenewimagezoom);
$('#magnifier > img').attr("src" , thenewimagezoom); 		 
}


var thenewimagedetail =   $(this).attr("src").replace("_thumb","_Standard");
var thenewimagezoom   =   $(this).attr("src").replace("_thumb","___Selected");


$('.imagezoom').fadeOut('fast').delay(100);
window.setTimeout(changethephoto, 200, true);

$('.imagezoom').fadeIn('fast');

// :  /uploads/products/fashion/product_zoom_back_21033_FashionProduct2_jpg_thumb.jpg
// :  /uploads/products/fashion/product_zoom_back_21033_FashionProduct2_jpg_Standard.jpg
// :  /uploads/products/fashion/product_zoom_back_21033_FashionProduct2_jpg___Selected.jpg
return false; });
// OTHER VIEWS SWITCH MAIN IMAGE ////// FIN ///////////////////////////////////////////////////////    



// show & hide catwalk vid on product detail page ////// START /////////////////////////////////////////////////////// 
$(".showcatwalk").parent().append("<span class='catwalkplay'></span>");

$(".showcatwalk").parent().click(function(){
$("#proddetails .testcatwalk").remove();
$("#proddetails .testcatwalk_demo").remove();
$("#proddetails .handwriting").hide();
if ($('.imagezoom').css('display') === 'block')
{
//	var thecatwalkvideo = 'http://testmos.webdev02/flash/MinistryDemo.flv'

$(".catwalkplay").css({"background-image" : "url(/images/branding/buttons/stop.png)"});







if( iPad || iPhone ) {

			//this is a hardcoded HTML5 vid
			var thevideoposter = $(".showcatwalk").attr('src');
			thevideoposter = thevideoposter.replace(/Thumb/i, "Standard");
			$("#proddetails").prepend('<div class="testcatwalk"><video width="460"  height="560" loop="" controls="" autoplay="" poster="' + thevideoposter + '" src="' + theiPadvideo + '" type="video/mp4" >THIS IS iPhone/iPad video</video></div> ');
			
		} else {
            $("#proddetails").prepend("<div class='testcatwalk'></div>");
			//embed the FLASH test_catwalk.swf on the product detail page
			$(function() {
			$("#proddetails .testcatwalk").each(function() {
			flashembed(this, {
			src: '/flash/catwalk_player.swf', 
			wmode: 'transparent'}, {
			audio: thecatwalkaudio,
			vidfile: thecatwalkvideo
			});
			});
			});
		}


$(".imagezoom").hide();

} else  // ($(".imagezoom").css({"display" : "none"})) 
{ 
$(".catwalkplay").css({"background-image" : "url(/images/branding/buttons/play.png)"});
$(".imagezoom").fadeIn(888); 
// showhandwriting();
}

return false;
})



// show facebook share thumb
if ($('.showotherview').length) {
  var fbooksharethumb = "http://hk.fsukmusic.co.uk" + $('.showotherview').attr('src');
	$("link[rel*='image_src']").attr({  href: fbooksharethumb});
 	}
	

// show facebook share thumb
if ($('#albumdetailimage').length) {
  var fbooksharethumb = "http://hk.fsukmusic.co.uk" + $('#albumdetailimage img').attr('src');
	$("link[rel*='image_src']").attr({  href: fbooksharethumb});
 	}
	




// show & hide catwalk vid on product detail page ////// FIN /////////////////////////////////////////////////////// 

// HANDWRITING - random on product details
/*		 $('.imagezoom[src*="33_"]').parent().append("<span class='caution handwriting'></span>");
$('.imagezoom[src*="34_"]').parent().append("<span class='caution handwriting'></span>");
$('.imagezoom[src*="101_"]').parent().append("<span class='caution handwriting'></span>");
$('.imagezoom[src*="21_"]').parent().append("<span class='fab_darling handwriting'></span>");
$('.imagezoom[src*="23_"]').parent().append("<span class='fab_darling handwriting'></span>");
$('.imagezoom[src*="24_"]').parent().append("<span class='fab_darling handwriting'></span>");
$('.imagezoom[src*="44_"]').parent().append("<span class='hk_loves handwriting'></span>");
$('.imagezoom[src*="46_"]').parent().append("<span class='hk_loves handwriting'></span>");
$('.imagezoom[src*="48_"]').parent().append("<span class='hk_loves handwriting'></span>");
$('.imagezoom[src*="49_"]').parent().append("<span class='hk_loves handwriting'></span>");
$('.imagezoom[src*="0_"]').parent().append("<span class='its_exhausting handwriting'></span>");
$('.imagezoom[src*="26_"]').parent().append("<span class='iwantkandi handwriting'></span>");
$('.imagezoom[src*="20_"]').parent().append("<span class='kiss handwriting'></span>");
$('.imagezoom[src*="5_"]').parent().append("<span class='kiss handwriting'></span>");
$('.imagezoom[src*="78_"]').parent().append("<span class='thats_hot handwriting'></span>");
$('.imagezoom[src*="79_"]').parent().append("<span class='thats_hot handwriting'></span>");
$('.imagezoom[src*="77_"]').parent().append("<span class='thats_hot handwriting'></span>");


$(".imagezoom").hover(function()
{   
if($.support.opacity) { $("#proddetails .handwriting").fadeOut();}
if($.browser.msie){  $("#proddetails .handwriting").hide(); }
});
function showhandwriting(){
if($.support.opacity) { $("#proddetails .handwriting").fadeIn();}
if($.browser.msie){  $("#proddetails .handwriting").show(); }
}

*/

// FANCYBOX MODAL WINDOWS 
// (some product detail popups are in their own function at the bottom)
/////////////////////////////////////////////////////////

// MAILING LIST
// detect for IE6 (for functions NOT to be called if IE6 )
if(typeof document.body.style.maxHeight === "undefined") {  
var ie6message = "<br /><br /><div class='error'>You are using an outdated browser</div><br /><p>For a better experience using this site, please upgrade to a modern web browser.</p><a href=http://www.firefox.com target=_blank>Firefox 3.5</a>&nbsp;|&nbsp;<a href=http://www.browserforthebetter.com/download.html target=_blank>Internet Explorer 8</a>&nbsp;|&nbsp;<a href=http://www.apple.com/safari/download/ target=_blank>Safari 4</a>&nbsp;|&nbsp;<a href=http://www.google.com/chrome target=_blank>Google Chrome</a>";
//$("a#mailinglistsignup_link").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
$("a.mailinglist").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
$("a.bookingform").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 500, 'height': 500, 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
$("a.ChristmasComp").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 500, 'height': 500, 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  


$("a.sizeguide").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
$("a.deliveryandreturns").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    }); 
$("a.competitionLauncher").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });   
$("a#bigtest").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });   

} 
else {
 //$("a#mailinglistsignup_link").fancybox({ 'width': 440, 'height' : 280, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
 $("a.mailinglist").fancybox({ 'width': 440, 'height' : 280, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
$("a.bookingform").fancybox({ 'width': 500, 'height' : 500, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
$("a.ChristmasComp").fancybox({ 'width': 500, 'height' : 765, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});


$("a.sizeguide").fancybox({ 'width': 800, 'height' : 470, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
$("a.deliveryandreturns").fancybox({ 'width': 800, 'height' : 480, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
$("a.competitionLauncher").fancybox({ 'width': 800, 'height' : 550, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
$("a#bigtest").fancybox({ 'width': 340, 'height' : 270, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});


var thecatwalkshow = '<object width="720" height="430"><param value="/flash/CATWALK_VIDEOPLAYER/vid_player.swf" name="movie">  <param value="sameDomain" name="allowScriptAccess"> <param value="newPath=http://imagevault.ministryofsound.com/hedkandi/hk_videos/HK_Catwalk_2.flv" name="FlashVars"><param value="transparent" name="wmode"><embed width="720" height="430" wmode="transparent" type="application/x-shockwave-flash" flashvars="newPath=http://imagevault.ministryofsound.com/hedkandi/hk_videos/HK_Catwalk_2.flv" src="/flash/CATWALK_VIDEOPLAYER/vid_player.swf"></object>';
$("a.watchthecatwalk").click(function(){  $.fancybox( thecatwalkshow, { 'autoDimensions'	: false, 'width': 720, 'height': 430, 'transitionIn': 'none','scrolling' : 'no' , 'transitionOut': 'none' }	); return false;    });  

}


//PRODUCT CARE 
var carestuff = $("#ProductCare").html();
if ($("#ProductCare span").html() != "")

{
$("a.care").show();
$("a.care").click(function(){   $.fancybox( carestuff, { 'autoDimensions'	: false, 'width': 390, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
}
else
{}


// SIZE GUIDE (hide if product has not sizes)
if ($('.variantselector option').html() != "One Size")  {
$('#prodinformation .sizeguide').show();
}
if  ($('.variantselector option').html() == "One Size (out of stock)")  {
$('#prodinformation .sizeguide').hide();

}










// THE MAIN GALLERY FUNCTION CALL
$("a.fancygallery").fancybox();




// FANCYBOX MODAL WINDOWS  END
/////////////////////////////////////////////////////////




// TABS 

//this is jquery for the text to show/hide tabs on the product detail page
//hides h4s that are there for script to degrade gracefully
$(".tabnav").show();
$("#tab4").hide();
$("#tab3").hide();
$("#tab2").hide();
// When a link is clicked
$(".tabnav  a").click(function () {

// switch all tabs off
$(".tabnav  a.active").removeClass("active");
// switch this tab on
$(this).addClass("active");

// slide all content up
$(".infoBox").hide();
// slide this content up
var content_show = $(this).attr("rel");
$("#"+content_show).show();
return false;
});




// PARTIES - center the title graphic

$('.partymaintitle').load(function(){	 


var partytitlewidth =  $("#partymainfeature .partymaintitle").width();
$("#partymainfeature .partymaintitle").css('margin-left' , (-( partytitlewidth / 2) + 'px'));
});






// PARTIES LIST - tooltip details


// stops the tooltip from appearing outside the viewport - JA
(function($){
var win = $(window);
$.fn.viewportOffset = function() {
var offset = $(this).offset();
return {
 left: offset.left - win.scrollLeft(),
 top: offset.top - win.scrollTop()
};
};
})(jQuery);



$("td .partydetails").hoverIntent(function(){
var shizzle = $(this).parent();
if ( shizzle.viewportOffset().top > ($(window).height() - 352 ) ) {
$(this).parent().find('.detailtooltip').css('top', '-300px');
$(this).parent().find('.tooltiparrow').css('top', '287px').attr('src', '/images/branding/blacktooltiparrow_down.gif');
} else {
$(this).parent().find('.detailtooltip').css('top', '27px');
$(this).parent().find('.tooltiparrow').css('top', '-11px').attr('src', '/images/branding/blacktooltiparrow.gif');
}
$(this).parent().find(".detailtooltip").show();
},function(){
$(this).parent().find(".detailtooltip").hide();
}); 				

// SALE AND NEW roundals
$(".smallthumbbox .sale a").append('<span class="sale_roundal">SALE</span>');
$(".smallthumbbox .new a").append('<span class="new_roundal">NEW</span>');




// PRICE SLIDER FILTER 
// script is on actual page - below hides the elements need if JS disabled
$(".priceinput").css('visibility', 'hidden');
$("#priceslider label").css('display', 'none');






// OPEN MEDIA PLAYER MINI IN NEW POPUP WINDOW //////////
// this de-activates the a links and opens a the playlist and music players in a new browser window the correct size

$('a[href = "/MediaPlayerMini/PlaylistPlayer_MINI.html"]').click(function(){
window.open( this.href, "miniplayer", "toolbar=no, location=no, directories=no, status=no, menubar=no,scrollbars=no, resizable=no,width=390,height=420" );
return false;
});

$('a[href = "/MediaPlayerMini/RadioPlayer_MINI.html"]').click(function(){
window.open( this.href, "miniplayer", "toolbar=no, location=no, directories=no, status=no, menubar=no,scrollbars=no, resizable=no,width=390,height=420" );
return false;
});


// var w = window.open(); if (w) w.focus()







// Tooltip for social network links in footer  ////////////////
// disable sn logo link if has tooltip



// hoverintent the sn logo
$('#socialnetworklinks li.has_tooltip').hoverIntent(show_sntooltip,hide_sntooltip);
function show_sntooltip() {  $(this).find('.sn_tooltip').show();   }
function hide_sntooltip() {  $(this).find('.sn_tooltip').fadeOut(); }

// $('#socialnetworklinks li .sn_tooltip').bind("mouseenter",function(){    $(this, '.sn_tooltip').show(); });
//$('#socialnetworklinks li .sn_tooltip').bind("mouseleave",function(){    $(this, '.sn_tooltip').delay(222).fadeOut(); });




// Hide basket summary on ordersummary & checkout page 
if (window.location.href.indexOf('OrderSummary.aspx') != -1)	{ $('#header #accountlinks').hide();}
if (window.location.href.indexOf('/Profile/Checkout.aspx') != -1) { $('#header #accountlinks').hide();}





// Hide "THIS LOOKS HOT WITH" if there is no shizzle

if ($('.relateditem').length != 0) {
$('.thislookshotwithmessage').css('visibility','visible');
}
$('#partymap a').click(function(){  getloader();  });




// MUSIC PRODUCT DETAILS
// show video button if there is a youtube id
// if (musicdetailsvideo != "") {alert(musicdetailsvideo);} else {alert(musicdetailsvideo);}

if(typeof musicdetailsvideo == 'undefined') {}
else {
		if (musicdetailsvideo != "") {
		$('#albumdetailtext .video').show();
		
		 var testvid ="<object width='640' height='385' wmode='transparent'><param  name='movie' value='http://www.youtube.com/v/" + musicdetailsvideo + "&hl=en_US&fs=1&autoplay=1'></param><param name='allowFullScreen' value='true'></param><param name='wmode' value='transparent'> </param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/" + musicdetailsvideo + "&hl=en_US&fs=1&autoplay=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='640' height='385' wmode='transparent'></embed></object>"
		  $("#albumdetailtext  .video").click(function(){   $.fancybox( testvid, { 'autoDimensions'	: false, 'width': 640, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none', 'wmode' : 'transparent' }	); return false;    });  
		}
}





// hotspots
$('#catlandingfeature').hover (function () {
$('.hotspots').fadeIn('fast'); 
}, function (){ $('.hotspots').fadeOut('fast');  }); 
 


// HK Bars - whats on poster cycle
$('#hkbar #eventslider').cycle({ timeout: 9000, delay: 200, speed: 1000}); 






// random jewellery for the fasiohn homepage campaign
var randomizer = Math.floor(Math.random()*2);

if (randomizer ==1) {
$('.firstwave').show();
$('.secondwave').hide();


} else {
$('.firstwave').hide();
$('.secondwave').show();

}
 



}); // DO NOT DELETE THIS LINE ///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////




// ADDED TO BAG MESSAGE
function addedtobasket() {
var addedtobasket = "<h3 class='dottedunderline'>Item added to bag</h3><br /><a href='#' onClick='javascript:$.fancybox.close();' class='continueshopping' >Continue Shopping</a> <a href='/OrderSummary.aspx' class='viewyourbag'>View Your Bag</a><br class='clear'/>"
$.fancybox(addedtobasket, { 'autoDimensions': false, 'width': 320, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' });  
}


function getloader() {  
//       var loader = "<img src='/images/branding/loader.gif' style='margin:auto;' alt='loading'/>"
//         $.fancybox(loader, { 'autoDimensions': false, 'width': 40, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' });  
//     $("#fancybox-close").hide();
$('body').append('<img src="/images/branding/loader.gif" style="position:absolute; z-index:99999; top:50%; left:50%; margin:-20px 0 0 -20px; display:block;" alt="loading"/><div id="fancybox-overlay" style="background-color:white; opacity: 0.65; filter:alpha(opacity=40); display: block;"></div>');

}



// PRODUCT DETAIL POPUPS
function productdetailpopups() {
// detect for IE6 (for functions NOT to be called if IE6 )

}


//THIS STUFF WILL BE CALLED AFTER EVERY UPDATE PANEL 


function pageLoad() {


if(typeof document.body.style.maxHeight === "undefined") {  

var ie6message = "<br /><br /><div class='error'>You are using an outdated browser</div><br /><p>For a better experience using this site, please upgrade to a modern web browser.</p><a href=http://www.firefox.com target=_blank>Firefox 3.5</a>&nbsp;|&nbsp;<a href=http://www.browserforthebetter.com/download.html target=_blank>Internet Explorer 8</a>&nbsp;|&nbsp;<a href=http://www.apple.com/safari/download/ target=_blank>Safari 4</a>&nbsp;|&nbsp;<a href=http://www.google.com/chrome target=_blank>Google Chrome</a>";
$("a.sizeguide").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
$("a.deliveryandreturns").click(function(){   $.fancybox( ie6message, { 'autoDimensions'	: false, 'width': 350, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
} 
else {
$("a.sizeguide").fancybox({ 'width': 800, 'height' : 470, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
$("a.deliveryandreturns").fancybox({ 'width': 800, 'height' : 480, 'autoScale' : true, 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'scrolling' : 'no','type': 'iframe'});
}



//PRODUCT CARE 
var carestuff = $("#ProductCare").html();
if ($("#ProductCare span").html() != "")

{
$("a.care").show();
$("a.care").click(function(){   $.fancybox( carestuff, { 'autoDimensions'	: false, 'width': 390, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none' }	); return false;    });  
}
else
{}

// SIZE GUIDE (hide if product has not sizes)
if ($('.variantselector option').html() != "One Size")  {
$('#prodinformation .sizeguide').show();
}
if  ($('.variantselector option').html() == "One Size (out of stock)")  {
$('#prodinformation .sizeguide').hide();

}



//clothing size guide stuff (imported from MoS)
    $('.sizeTable td').hover(function(){
    	$('.sizeHeading td').eq($(this).index()).stop().animate({'color': '#000000'});
    }, function(){
    	$('.sizeHeading td').eq($(this).index()).stop().animate({'color': '#666666'});
    });
    
    $('.sizeGuideLink a').live('click', function(){
    	$('#sizePopUp').show();
    	$('body').append('<div id="popUpOverlay" style="display: block;">&nbsp;</div>');
    	$('#sizePopUp').animate({
    		'height': 440,
    		'width': 700,
    		'top': 220,
    		'margin-left': -350,
    		'margin-top': 0
    	}, function(){
    		$(this).find('.padding15').fadeIn();
    	});
    	return false;
    });
    
    $('.closeSize').live('click', function(){
    	$('#popUpOverlay').remove();
    	$('#sizePopUp .padding15').hide();
		$('#sizePopUp').css({
			'display': 'none',
			'width': 200,
			'height': 200,
			'margin-left': -100,
			'margin-top': -100,
			'top': '50%'
		});
		return false;
    });




}



