// FAQ Page
$(document).ready(function() {

	var CatalogSubCatID// = $.query.get('SubCatID');
	var CatalogCategoryID
	var linkText

	// FAQ Page
	$("#landing h1").click(function() {
		if($('#landing div').get(0).className == "closed") {
			$("div.closed").animateClass('open','closed',500);
		} else {
			$("div.open").animateClass('closed','open',500);
		}	
	});
	
	// 
	$("#leftback, #landingmain, #rightback").equalizeCols();
	$('#landtext1 p').eq(1).css('marginTop','5px');
	$('#landtext2 p').eq(1).css('marginTop','10px');
	$('#landtext3 p').eq(1).css('marginTop','7px');
	$('#landtext4 p').eq(1).css('marginTop','7px');
	
	$("div.data").hide(); // hides all faqdata divs at start
	
	$("#forward-form").hide();

	$('#frontimg').click(function() {window.location = "/search.asp"});
	
	
	// tabs =========================================================
	
	CatalogSubCatID = $.query.get('SubCatID');
	URL = location.pathname;
	
	$('#tabs li.sw img').click(function(){
		$('#tabs li:eq(1) img').css('background','#D8E4EF');
	});
	
	$('#tabs li.sw img').hover(
		function(){
			$(this).attr('src',$(this).attr('src').replace('normal','hover'));
			$(this).css('background','#fff');//D8E4EF
			$('#tabs li ul').hide(50);
			$('#tabs li:eq(1) img').css('background','#D8E4EF');
		},
		function(){
			$(this).attr('src',$(this).attr('src').replace('hover','normal'));
			$(this).css('background','#D8E4EF');
			$('#tabs li ul').hide(50);
			$('#tabs li:eq(1) img').css('background','#D8E4EF');
		}
	);


	
	if (URL=='' || URL=='/default.asp') {$('#homelink').attr('src',$('#homelink').attr('src').replace('normal','selected'))}
	if (URL=='/builder.asp') {$('#designlink').attr('src',$('#designlink').attr('src').replace('normal','selected'))}
	if (URL=='/search.asp' && location.href.indexOf("Mode=Type")<0 && location.href.indexOf("CategoryID=2")<0) {$('#designlink').attr('src',$('#designlink').attr('src').replace('normal','selected'))}
	if (location.href.indexOf("Mode=Type") > -1 || location.href.indexOf("CategoryID=2") > -1) {$('#packagedlink').attr('src',$('#packagedlink').attr('src').replace('normal','selected'))}
	
	// end tabs ===================================================
	
	// png alpha support
	$(window).load(function() {
	$.ifixpng('/mlnapp/img/1px.gif');
	$('img[@src$=.png]').ifixpng(); 
	// dropshadows!
	//$(".browse img").dropShadow({left: 6, top: 6, color:'black'});
	//$(".browse a").dropShadow({left: 3, top: 3, color:'black'});
	});


	if (CatalogSubCatID !='1') {
		//$('.browsecat a')
		$('.browsecat a[@href$="/search.asp?SubCatID=' +CatalogSubCatID+ '"]').addClass('browsecaton');
		
	} else {
		$('.browsecat a[@href$="/search.asp?SubCatID=1"]').addClass('browsecaton');
	}
	

	if (CatalogCategoryID == '2' || CatalogSubCatID >'6') {
		//$('.browsecat a')
		$('.browsecat a[@href$="/search.asp?CategoryID=2"]').addClass('browsecaton');
		
	}

	$('.bannermid img').hide()
	$('.bannerleft').click( function() {
		$(this).parent().find('.bannermid img').toggle('slow')
	})
	
	// front page
	$('#categorybreakout div').hide();
	$('#frontcat li').click(function(){
		$('#frontcat li').css({color:'#361C11'});
		$('#categorybreakout div').hide();
		linkText = $(this).attr('class');
		$('#categorybreakout').children().filter('.'+linkText).show();
		$(this).css({color:'#F3429F'});
	});
	//$('#frontcat li').hover(function(){$(this).css({color:'#864B2A'});},function(){$(this).css({color:'#361C11'});});
	
	$('#frontcat li:not(:first)').css({borderLeft:'1px solid #371C12'});
	$('.breakoutsub ul li:not(:first-child)').css({borderLeft:'1px solid #F3429F'});
	
	$('#front .frontslides div img').iunfixpng(); 
	
	// front page animation
	// =================================================
	$('.frontslides').cycle({
	    fx:     'fade', 
	    speed:  500, 
	    timeout: 6000, 
	    pause: 1, 
	    next: '#fsnext',
	    prev: '#fsprev',
	    slideExpr: 'img'
	});
	
	$("#create_caricature").hover(function(){$(this).attr("src",$(this).attr("src").replace(".gif","_on.gif"));},function(){$(this).attr("src",$(this).attr("src").replace("_on.gif",".gif"));});

	$('#mypose').click(function(){
		 $.cookie('MyPose','1');
		 //alert($.cookie('MyPose'));
	});
	
	$('#designlink').click(function(){
		 $.cookie('MyPose','');
	});





	// silhouettes
	// =================================================
	$("#silslides img[@src$=.png]").ifixpng();
	$('#silslides').cycle({
	    fx:     'scrollRight', 
	    speed:  500, 
	    timeout: 0, 
	    next: '#assetnext',
	    prev: '#assetprev',
	    after: onAfter
	});


	// detail
	// =================================================
	$('#detailslides').cycle({
	    speed:  500, 
	    timeout: 4000, 
	    next: '#detailnext',
	    prev: '#detailprev'
	});
	
	$('#detailnext, #detailprev').iunfixpng(); 
	
	$('#detail input.submit').hover(function(){
		$(this).css({color:'#864B2A'});
		},function(){
		$(this).css({color:'#462414'});
		});
	
	$('.detailslidecontrol').mousedown( function() {$(this).attr('src',$(this).attr('src').replace('0','1'))});
	$('.detailslidecontrol').mouseup( function() {
		var thisimage = $(this)
		setTimeout( function(){
		thisimage.attr('src',thisimage.attr('src').replace('1','0'))
		},500);
		//alert(thisimage.attr('src'));
		});
	
	// =================================================

	// adjustments for landing pages
	switch(PageID)
	{
		case "164":
		$("#landtext1").css({lineHeight:'100%', margin: '0 0 0 0'});
		$("#landtext1 p:first").css({lineHeight:'110%', margin: '20px 30px 0 30px'});

		$("#landtext2 p:first").css({marginTop: '25px'});
		
		$("#landtext3 p").css({lineHeight: '130%'});
		$("#landtext4 p").css({lineHeight: '100%'});
		break;

		case "167":
		$("#landtext1").css({lineHeight:'100%', margin: '0 0 0 0'});
		$("#landtext1 p:first").css({lineHeight:'120%', margin: '20px 30px 0 30px'});

		$("#landtext2 p:first").css({marginTop: '25px'});
		$("#landtext2 p").css({lineHeight: '120%'});
		
		$("#landtext3 p").css({lineHeight: '130%'});
		$("#landtext4 p").css({lineHeight: '130%'});
		break;

		case "165":
		$("#landtext1").css({lineHeight:'100%', margin: '0 0 0 0'});
		$("#landtext1 p").css({margin: '8px 27px 0 27px'});
		$("#landtext1 p:first").css({margin: '23px 27px 0 27px'});

		$("#landtext2 p:first").css({marginTop: '25px'});
		$("#landtext2 p").css({lineHeight: '130%'});
		
		$("#landtext3 p").css({lineHeight: '130%'});
		$("#landtext4 p").css({lineHeight: '110%'});
		break;

	}

	

});



function onAfter(curr, next, opts) {
    var index = $(this).parent().children().index(this);
    //$('#prev')[index == 0 ? 'hide' : 'show']();
    //$('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
    //alert($(this).parent().eq(index).is('.asset5'));
    //alert($(this).is('.asset5'));
    if ($(this).is('.asset5')==true) {$('#sillabel').html('Couples');$('#sillabel').css('width','210px');}
    if ($(this).is('.asset2')==true) {$('#sillabel').html('Brides');}
    if ($(this).is('.asset4')==true) {$('#sillabel').html('Pregnant Women');}
    if ($(this).is('.asset6')==true) {$('#sillabel').html('Miscellaneous');}
    if ($(this).is('.asset1')==true) {$('#sillabel').html('Chic');}
}