var gt = function()
{/*gauravstomar.blogspot.com
*/}
gt.prototype = {
init:function()
{
	$(".addFriend").click(function(){$(this).load("http://namen.nl/users/profile/addfriend/"+$(this).attr("fid"))});
	this.inputInit();	
	this.divInit();
	this.allInit();
	this.anchorInit();
	this.h1Init();
	this.bidFor();
},
allInit:function()
{
	$("*").each(function(){
				if($(this).attr("class")=="nav")
				{	p = $(this).offset();
					$($(this).children().eq(0)).css({"display":"none","top":(p.top+($(this).height()))+"px","left":(p.left-10)+"px"});
					$(this).hover(function(){$($(this).children().eq(0)).slideDown("fast");},function(){ $($(this).children().eq(0)).slideUp("fast");});
				}
						}
	);
},
inputInit:function()
{
	$("input").each(function(){
	if($(this).attr("title").length>0){
	$(this).hover(function(){		
								$(this).after($(document.createElement("div")).html($(this).attr("title")).css({
								"background":"#333333","position":"fixed","color":"#ffffff","padding":"0 10px"
								}));
							},
					function()
							{	$(this).parent().find("div:last").remove();
							});
	}});
},
h1Init:function()
{/*	aT = 1000;
	$("h1").each(function()
						{	if($(this).attr("align")=="animate")
							{
								$(this).fadeTo(aT,0.2).fadeTo(aT,1.0);
								setTimeout(function(){gst.h1Init();},aT*3);
							}
						});
*/},
divInit:function()
{
	$("div").each(function(){if($(this).attr("href"))$(this).css({"cursor":"pointer"}).click(function(){window.location.href=$(this).attr("href")});});
},
eM:null,
anchorInit:function()
{
	$("a").each(function(){
							if($(this).attr("lightbox")){$(this).click(function(){
	if($('#'+$(this).attr("lightbox")).css("display")=='none')
	{	p = $(this).offset(); iW = $('#'+$(this).attr("lightbox")).innerWidth(); iH = $('#'+$(this).attr("lightbox")).innerHeight();
		$('#'+$(this).attr("lightbox")).css({"display":"block","top":p.top+"px","left":p.left+"px","position":"absolute",
											"background":"#fff","height":"0","width":"0","border":"5px solid #002154"});
		$('#'+$(this).attr("lightbox")).animate({left:(($(window).width()/2)-(iW/2))+"px",top:(($(window).height()/2)-(iH/2))+"px",
												width:iW+"px",height:iH+"px"});
		$('#'+$(this).attr("lightbox")).prepend($(document.createElement('img')).css({"cursor":"pointer","position":"absolute","right":"-10px","top":"-10px"}).attr({"src":"http://namen.nl/public/images/close.gif","alt":"close","lightbox":$(this).attr("lightbox")}).click(function(){$('#'+$(this).attr("lightbox")).fadeOut("4000");$(this).remove()}));
	}else $('#'+$(this).attr("lightbox")).fadeOut("slow");						});
	$('#'+$(this).attr("lightbox")).css({"display":"none"});
														}
	if($(this).attr("hint")){$(this).hover(function(){
	aT = 2000;	p = $(this).offset();
	gst.eM = $(gst.cE()).css({"left":(p.left-233)+"px","top":(p.top+45)+"px","position":"absolute","width":"309px"});
	$(gst.eM).prepend($(gst.cE()).css({"background":"url(http://namen.nl/public/images/msg.bot.png)","height":"18px"}));
	$(gst.eM).prepend($(gst.cE()).html($(this).attr("hint")).css({"background":"url(http://namen.nl/public/images/msg.mid.png)","padding":"0 10px","text-align":"center","font-weight":"bold"}));
	$(gst.eM).prepend($(gst.cE()).css({"background":"url(http://namen.nl/public/images/msg.top.png)","height":"16px"}));
	$(gst.eM).append($(gst.cE("img")).attr({"src":"http://namen.nl/public/images/bubble.gif","alt":"Yes","align":"absmiddle"}).css({"cursor":"pointer","position":"absolute","top":"-26px","left":"256px"}))
	$("body").prepend($(gst.eM));
	$(gst.eM).fadeIn(aT/3);},function(){$(gst.eM).remove();});}
							});
},
message:function(m,t)
{	aT = 2000; t = t?t*1000:10000;
	$(".chaserMsg").fadeOut("fast");
	var eM = $(this.cE()).addClass("chaserMsg").css({"left":"-333px","top":"10px","position":"fixed","width":"309px"});
	$(eM).prepend($(this.cE()).css({"background":"url(http://namen.nl/public/images/msg.bot.png)","height":"18px"}));
	$(eM).prepend($(this.cE()).html(m).css({"background":"url(http://namen.nl/public/images/msg.mid.png)","padding":"0 10px","text-align":"center"}));
	$(eM).prepend($(this.cE()).css({"background":"url(http://namen.nl/public/images/msg.top.png)","height":"16px"}));
	$("body").prepend($(eM));
	$(eM).animate({left:(($("body").width()/2))},aT).animate({left:(($("body").width()/2)-150)},aT/2);
	setTimeout(function(){$(eM).animate({left:(($(window).width()/2)-300)},aT/2).animate({left:$(window).width()},aT)},t);
	setTimeout(function(){$(eM).remove()},t+(aT*2));
},
cE:function(o)
{
	return document.createElement(o?o:"div");
},
bidFor:function()
{
	$("div").each(function(){
					if($(this).attr("bidfor"))
					{	o = $(this).children();
						$(o[1]).css({"cursor":"pointer"}).click(function()
																		{	minRate = new Number(($($($($(this).parents().eq(1))).children().eq(1)).html()).replace('EUR',''));
																			x = $($($(this).parent().eq(0)).children().eq(0));
																			v = new Number(($(x).html()).replace('E',''));
																			cost = new Number($(x).attr("tbids"));
																			$(x).fadeTo("fast", 0.11).fadeTo("fast", 1.00);
																			if((v-cost)>=minRate)$(x).html((v-cost));
																			else gst.message("Please bid more than "+minRate,4);
																		}); 
						$(o[2]).css({"cursor":"pointer"}).click(function()
																		{	minRate = new Number(($($($($(this).parents().eq(1))).children().eq(3)).html()).replace('EUR',''));
																			minRatx = new Number(($($($($(this).parents().eq(1))).children().eq(1)).html()).replace('EUR',''));
																			x = $($($(this).parent().eq(0)).children().eq(0));
																			v = new Number(($(x).html()).replace('E',''));
																			cost = new Number($(x).attr("tbids"));
																			$(x).fadeTo("fast", 0.11).fadeTo("fast", 1.00);
																			$(x).html((v==0?(minRate>0?minRate:minRatx):(v<minRate?minRate:v))+cost);
																		});
					}
							});
},
sure:function(o,m)
{	aT = 2000;	p = $(o).offset();
	
	var eM = $(this.cE()).css({"left":(p.left-150)+"px","top":(p.top+10)+"px","position":"absolute","width":"309px"});
	$(eM).prepend($(this.cE()).css({"background":"url(http://namen.nl/public/images/msg.bot.png)","height":"18px"}));
	$(eM).prepend($(this.cE()).html(m).css({"background":"url(http://namen.nl/public/images/msg.mid.png)","padding":"0 10px","text-align":"center","font-weight":"bold"})
		 .append($(this.cE("br"))).append($(this.cE("br")))
		 .append($(this.cE("img")).attr({"src":"http://namen.nl/public/images/yes.gif","alt":"Yes","align":"absmiddle"}).css({"cursor":"pointer"})
		 .click(function()
		 				{	$(eM).fadeOut(aT);
							$.post("http://namen.nl/users/mayfair",{"id":$(o).attr("id")});
							gst.message('Your request to buy domain is send. <br />Please check your email.',5);
							setTimeout(function(){window.location.reload()},aT);
						})).append($(this.cE("img")).attr({"src":"http://namen.nl/public/images/no.gif","alt":"No","align":"absmiddle"})
		.css({"cursor":"pointer"}).click(function()
												{	$(eM).fadeOut("4000");
													setTimeout(function(){$(eM).remove()},aT);
												})));
	$(eM).prepend($(this.cE()).css({"background":"url(http://namen.nl/public/images/msg.top.png)","height":"16px"}));
	$("body").prepend($(eM));
	$(eM).fadeIn(aT).animate({top:(p.top-($(eM).height()/2))},aT/2);
},
placeBid:function()
{	
	aT = 5000;	
	c = $(".active-box-domainhead1");
	t = f = 0;
	for(i=0;i<c.length;i++)if($($(c[i]).children().eq(7)).children().length>0)
	{	minRate = new Number(($($(c[i]).children().eq(1)).html()).replace('E',''));
		myBid = new Number(($($($(c[i]).children().eq(7)).children().eq(0)).html()).replace('E',''));
		minBid = new Number(($($($(c[i]).children().eq(7)).children().eq(0)).attr('last')));
		//alert(minRate+':minRate\n'+myBid+':myBid\n'+minBid+':minBid');
		if(myBid>minBid)
		{	t++;
			$(c[i]).addClass('bggreen').removeClass('bgred').fadeTo(aT/2,0.5).fadeTo(aT/2,1);
		}
		if(myBid<minBid)$(c[i]).addClass('bgred').removeClass('bggreen').fadeTo(aT/2,0.5).fadeTo(aT/2,1);
		if(myBid<=minRate) 
		{	f++;
			$(c[i]).removeClass('bggreen').removeClass('bgred').fadeTo(aT,0.1).fadeTo(aT,1);
		}else  $.get('http://namen.nl/auction?a='+$(c[i]).attr("id")+'&b='+myBid);
	}
	m = '';
	if(t>0)m = "Your "+t+" bid(s) are saved.";
	//if(t>0 && f>0) m = m+"<br /><br /><hr noshade=noshade color=#002154 /><br />";
	//if(f>0)m = m+"Your "+f+" bid(s) are not acceptable because they are less then minimum bid limit.";
	if(!m.length>0)m = "No any bid to be saved.";
	this.message('<h2>'+m+'</h2>',7);setTimeout(function(){window.location.reload();},3000);
},
viewMore:function()
{	o = $('#vMore').children();
	for(i=0;i<o.length;i++)$(o[i]).hide(i*500);
	setTimeout(function(){window.location.href='http://namen.nl/auction';},1000)
}				};
