//COOKIE
/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};

// CAROUSEL LITE
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([4-9A-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4(g){g.fn.jCarouselLite=4(a){a=g.extend({C:9,D:9,N:9,V:A,O:9,P:200,W:9,E:A,F:X,I:3,G:0,8:1,Y:A,Q:9,R:9},a||{});6 J.Z(4(){B o=A,p=a.E?"10":"H",t=a.E?"S":"T";B m=g(J),h=g("ul",m),r=g("li",h),v=r.12(),c=a.I,s=0;5(a.F){h.prepend(r.K(v-c-1+1).13()).append(r.K(0,c).13());a.G+=c}a.Y?h.hover(4(){s=1},4(){s=0}):"";B j=g("li",h),k=j.12(),f=a.G;m.7("visibility","I");j.7({14:"15",\'float\':a.E?"16":"H"});h.7({margin:"0",padding:"0",17:"18","list-style-type":"16","z-19":"1"});m.7({14:"15",17:"18","z-19":"2",H:"0px"});B l=a.E?w(j):x(j);B y=l*k;B z=l*c;j.7({T:j.T(),S:j.S()});h.7(t,y+"L").7(p,-(f*l));m.7(t,z+"L");5(a.C)g(a.C).U(4(){6 n(f-a.8)});5(a.D)g(a.D).U(4(){6 n(f+a.8)});5(a.N)g.Z(a.N,4(i,1a){g(1a).U(4(){6 n(a.F?a.I+i:i)})});5(a.V&&m.1b)m.1b(4(e,d){6 d>0?n(f-a.8):n(f+a.8)});5(a.O)setInterval(4(){n(f+a.8)},a.O+a.P);4 u(){6 j.K(f).K(0,c)};4 n(b){5(!o&&!s){5(a.Q)a.Q.1c(J,u());5(a.F){5(b<=a.G-c-1){h.7(p,-((k-(c*2))*l)+"L");f=b==a.G-c-1?k-(c*2)-1:k-(c*2)-a.8}M 5(b>=k-c+1){h.7(p,-((c)*l)+"L");f=b==k-c+1?c+1:c+a.8}M f=b}M{5(b<0||b>k-c)6;M f=b}o=X;h.animate(p=="H"?{H:-(f*l)}:{10:-(f*l)},a.P,a.W,4(){5(a.R)a.R.1c(J,u());o=A});5(!a.F){g(a.C+","+a.D).removeClass("1d");g((f-a.8<0&&a.C)||(f+a.8>k-c&&a.D)||[]).addClass("1d")}}6 A}})};4 q(b,o){6 parseInt(g.7(b[0],o))||0};4 x(b){6 b[0].offsetWidth+q(b,\'marginLeft\')+q(b,\'marginRight\')};4 w(b){6 b[0].offsetHeight+q(b,\'marginTop\')+q(b,\'marginBottom\')}})(jQuery);',[],76,'||||function|if|return|css|scroll|null|||||||||||||||||||||||||||false|var|btnPrev|btnNext|vertical|circular|start|left|visible|this|slice|px|else|btnGo|auto|speed|beforeStart|afterEnd|height|width|click|mouseWheel|easing|true|pauseOnHover|each|top||size|clone|overflow|hidden|none|position|relative|index|val|mousewheel|call|disabled'.split('|'),0,{}))

//$(function() {
//    $(".anyClass").jCarouselLite({
//        btnNext: ".carousel_next",
//        btnPrev: ".carousel_prev",
//		visible: 4,
//		auto: 3000,
//		speed: 1000
//    });
//});


//////////////////////// JQUERY COMMANDS
$(document).ready(function(){
				
$('a.llinks').live('click', function(){		
		$.cookie('nav',$(this).attr('id'), { path: '/', expires: 1 });
		$('a.llinks').removeClass('genreActive');
		var subdiv = '#' + $(this).attr('id') + 'll';
	if ($(subdiv).is(':visible')){  
		$.cookie('nav','', { path: '/', expires: 1 }); 
		$(this).removeClass('genreActive');
		$('.subLinks:visible').slideUp();
	}
	else
	{
		$(this).toggleClass('genreActive');
		$('.subLinks:visible').slideUp();
		$(subdiv).slideDown();
	}
	});

	$('div.subLinks .catName a').live('click',function(){
		var llinkActive = $(this).attr('id')
		$.cookie('navLink', llinkActive, { path: '/', expires: 1 });
	});

	$('div.artLinks .genreName a').live('click',function(){
		var llinkActive = $(this).attr('id')
		$.cookie('navLink', llinkActive, { path: '/', expires: 1 });
	});


	$('.confirmDelete').click(function(){
	//	alert('You have selected to delete all of the selected art items... ');									  
		var answer = confirm("Are you sure you want to delete this item?");
	if (answer){
		$(this).parents('form:first').submit();
	}
  });


//////////////////////// TOGGLE TAG CLASS ACTIVE
	$(".tag_list div").mousedown(function() {
		$(this).toggleClass('active_box', 100);
		$(this).find(':checkbox').attr('checked', !$(this).find(':checkbox').attr('checked'));
	});
	
	$(".tag_list div input").mousedown(function() {
		$(this).attr('checked', !$(this).attr('checked'));
	});
	


	$("a.fancybox_upload").fancybox({
			'frameHeight': 240,
			'padding': 20, 
			'hideOnContentClick': false,
			'autoDimensions': false
			}); 

	$("a.fancybox").fancybox({
			'frameHeight': 200,
			'padding': 20, 
			'hideOnContentClick': true
			}); 

	$(".fbadmin").fancybox({
			'padding': 20, 
			'hideOnContentClick': false
			}); 

	$("a[rel=Artwork]").fancybox({
//		'onComplete'	:	function() {
//			$("#fancybox-wrap").hover(function() {
//				$("#fancybox-title").show();
//			}, function() {
//				$("#fancybox-title").hide();
//			});
//		},
//
		'titleShow'			: 'true',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'outside'
//		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
//		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
//		}
	});


$('.fancyclose').click(function(){parent.$.fancybox.close();});

}); //////////////////// END JQUERY COMMANDS

//$('input:checkbox').each( function() {
//this.checked = !this.checked;
//});
//return false;
//});

function SubmitForm(whichForm)
	{
		//document[whichForm].action = whichAction;
		document.whichForm.submit(); 
		return false;
}

/////////////////// CREATE A NEW COOKIE
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
	{
	  var cookie_string = name + "=" + escape ( value );
	  if ( exp_y )
	  {
		var expires = new Date ( exp_y, exp_m, exp_d );
		cookie_string += "; expires=" + expires.toGMTString();
	  }
	  if ( path )
			cookie_string += "; path=" + escape ( path );
	  if ( domain )
			cookie_string += "; domain=" + escape ( domain );
	  if ( secure )
			cookie_string += "; secure";
	  document.cookie = cookie_string;
	}
	
/////////////////////// TOGGLE
function toggle(theDiv,cookie)
{
var toggleArray= theDiv.split(',');
	
	var x = 0;
	while (x<toggleArray.length) {
		if(document.getElementById(toggleArray[x]).tagName == 'TR'){
			if(document.getElementById(toggleArray[x]).style.display == 'table-row' || document.getElementById(toggleArray[x]).style.display == '' )
				{
				document.getElementById(toggleArray[x]).style.display = 'none';
					if (cookie !='no'){
						set_cookie (toggleArray[x], 'none')
					}
				}
				else
				{
				document.getElementById(toggleArray[x]).style.display = 'table-row';
					if (cookie !='no'){
						set_cookie (toggleArray[x], 'table-row')
					}
				}		
			}
		else if(document.getElementById(toggleArray[x]).tagName == 'A'){
			if(document.getElementById(toggleArray[x]).style.display == 'inline' || document.getElementById(toggleArray[x]).style.display == '' )
				{
				document.getElementById(toggleArray[x]).style.display = 'none';
					if (cookie !='no'){
						set_cookie (toggleArray[x], 'none')
					}
				}
				else
				{
				document.getElementById(toggleArray[x]).style.display = 'inline';
					if (cookie !='no'){
						set_cookie (toggleArray[x], 'inline')
					}
				}		
			}
		else
		{
			if(document.getElementById(toggleArray[x]).style.display == 'block' || document.getElementById(toggleArray[x]).style.display == '' )
				{
				document.getElementById(toggleArray[x]).style.display = 'none';
					if (cookie !='no'){
						set_cookie (toggleArray[x], 'none')
					}
				}
				else
				{
				document.getElementById(toggleArray[x]).style.display = 'block';
					if (cookie !='no'){
						set_cookie (toggleArray[x], 'block')
					}
				}
		}
	x++;
	} 
}	

/////////////////////////  FIELD FOCUS
function fokus(fld){
//	document.getElementById(fld).focus();
	document.getElementById(fld).select();
}

////////////////////////// REFRESH PARENT WINDOW FROM IFRAME
function refresh_parent(){
	window.parent.location = window.parent.location.href;
}

////////////////////////// CONFIRM DELETE
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to delete?");
if (agree)
	return true ;
else
	return false ;
}

/////////////////////////// OPEN A NEW POPUP WINDOW - CENTERED
// use:  <a href="page.html" target="popup" onClick="wopen('page.html', 'popup', 300, 200); return false;">TEXT</a>

function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

//////////////////////// BUTTON
/* Rounded Corner jQuery */
$(function(){$(".fg-button:not(.ui-state-disabled)").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")}).mousedown(function(){$(this).parents(".fg-buttonset-single:first").find(".fg-button.ui-state-active").removeClass("ui-state-active");if($(this).is(".ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active")){$(this).removeClass("ui-state-active")}else{$(this).addClass("ui-state-active")}}).mouseup(function(){if(!$(this).is(".fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button")){$(this).removeClass("ui-state-active")}})});


