jQuery.fn.center = function () {
	//this.css("position","fixed");
	//this.css("top", 0+ "px");
	//this.css("right", 330+ "px");
    return this;
}

jQuery.jwbox = {
	lightbox	:	null,
	player	: null,
	toggle	: function(context) {
		if (!$.jwbox.lightbox) {
				$.jwbox.lightbox = $(".jwbox_hidden", context);
				$.jwbox.center();
				$("#jwbox_background").fadeIn("fast");
				$.jwbox.lightbox.css("display","block")
				$.jwbox.center();
				$("#jwbox_background").fadeTo(0, 1);
				$("object", context).each(function(){
					$.jwbox.player = document.getElementById(this.id);
				});
		} else if ((context.className == 'jwbox_content')) {
		} else {
			try {
				$.jwbox.player.sendEvent("STOP");
				$.jwbox.player = null;
			} catch (err) {
			}
			$.jwbox.lightbox.css("display","none");
			$.jwbox.lightbox = null;
			$("#jwbox_background").fadeOut("fast");
			$("#logo img").attr("src", "images/auto-blast-ltd.gif");
		}
	},
	center	: function() {
		if ($.jwbox.lightbox) {
			$.jwbox.lightbox.center();
		}
	}
}

$(document).keyup(function(event){
    if (event.keyCode == 27 && $.jwbox.lightbox) {
		$.jwbox.toggle($("#jwbox_background"));
    }
});

$(document).ready(function () {
	
	
	
	var username=getCookie("username");
	if (username!=null && username!=""){
		$(".jwbox_hidden").hide();
		$('#logo img').attr('src', 'images/auto-blast-ltd.gif');
		//alert("Welcome again " + username);
	}
	else{
		username="aa";
			if (username!=null && username!=""){
				setCookie("username",username,365);
				$(".jwbox_hidden").show();
				$("body").append('<div id="jwbox_background"><div class="inner">&nbsp;</div></div>');
				$(".jwbox_hidden").click(function(){$.jwbox.toggle(this); return false;});
				$.jwbox.toggle(this); return false;
				$("#jwbox_background").click(function () {$.jwbox.toggle(this); return false;});
				$(".jwbox_content").click(function () {$.jwbox.toggle(this); return false;});
				$(window).resize(function() {$.jwbox.center();});
			}
	}
	
});
function changeImage(){
	$('#logo img').attr('src', 'images/auto-blast-ltd.gif');
	}
	
function getCookie(c_name){
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++){
		  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		  x=x.replace(/^\s+|\s+$/g,"");
		  if (x==c_name)
			{
			return unescape(y);
			}
	  }
}

function setCookie(c_name,value,exdays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

