this.newsletter = function(obj){	

	$("a[href$='#newsletter']").each(function(){	
		$(this).attr("href","#TB_inline?height=250&amp;width=240&amp;inlineId=newsletterBox&amp;modal=true");	
		$(this).addClass("thickbox");	
    });	
	
	newsletterFields();

};

this.newsletterFields = function(){	
	var txt1 = "Your Name";
	$(".newsletterName").val(txt1);
	$(".newsletterName").focus(function(){	
		this.value = (this.value != txt1) ? this.value : "";	   
    });	
	$(".newsletterName").blur(function(){	
		this.value = (this.value != txt1 && this.value != "") ? this.value : txt1;
    });		
	var txt2 = "Your Email Address";
	$(".newsletterEmail").val(txt2);
	$(".newsletterEmail").focus(function(){	
		this.value = (this.value != txt2) ? this.value : "";	   
    });	
	$(".newsletterEmail").blur(function(){	
		this.value = (this.value != txt2 && this.value != "") ? this.value : txt2;
    });			
};

this.searchField = function(){	
	var txt = "Search This Site";
	$("#s").val(txt);
	$("#s").focus(function(){	
		this.value = (this.value != txt) ? this.value : "";	   
    });	
	$("#s").blur(function(){	
		this.value = (this.value != txt && this.value != "") ? this.value : txt;
    });		
};

this.blankwin = function(){	
	$("a").each(function(){			    	
		var hostname = window.location.hostname;
		hostname = hostname.replace("www.","").toLowerCase();
		this.check = function(obj){
			var href = obj.href.toLowerCase();
			return ((href.indexOf("http://")!=-1 || href.indexOf("https://")!=-1)&& href.indexOf(hostname)==-1) ? true : false;				
		};
		this.set = function(obj){
			obj.target = "_blank";
			obj.className = "external";
		};	
		if(check(this)) set(this);			
	});	
};

this.collapse = function(){	
	$("#extra").each(function(){			    	
		$(this).hide();
		$(this).after('<p><a href="javascript:void(0)" id="extraLink">Read more...</a></p>');
		$("#extraLink").toggle(
			function(){
				$("#extra").show("fast");
				$(this).html("");	
			},
			function(){
				$("#extra").hide("fast");
				$(this).html("Read more...");			
			}			
		);
	});	
};


this.orderby = function(){	
	var over;
	$(".orderby p").mouseover(function(){
		over = true;
		$(".orderby ul").show();
	});
	$(".orderby").hover(
		function(){
			if(over) $(".orderby ul").show();
		},
		function(){
			$(".orderby ul").hide();
			over = false;
		}
	);
};

this.feedback = function(){	

	$("#feedback").remove();
	
	this.kampyleLink = function(obj){
		$(obj).attr("href","javascript:void(0);");	
		$(obj).attr("target","");	
		$(obj).click(function(){						   	
			window.open('http://www.kampyle.com/feedback_form/ff-feedback-form.php?&site_code=7043240&form_id=1784&lang=en&url='+encodeURIComponent(window.location.href), 'kampyle_ff','left='+((window.screenX||window.screenLeft)+10)+',top='+((window.screenY||window.screenTop)+10)+',height=502px,width=440px,resizable=false');
		//return false;		  										   
		});	
	};

	$("#container").append("<div id='sideButton'>Give us Feedback</div>");
	var l = ($("#container").width()/2)+480;
	$("#feedback").css("left",l+"px");
	kampyleLink($("#sideButton"));

};

$(document).ready(function(){	
	//blankwin();
	newsletter();
	searchField();
	feedback();
	collapse();
	orderby();
});
$(window).bind('resize', function() {
	feedback();
});


