var prevurl = "";
var searchnow = true;
var currentcomment="";
var currentpostid = 0;

jQuery(document).ready(function(){
	show1stprofile();
	registerforumregisterlink();
	makeround();	
	setupbookmark();	
	fixiframesforIE();
	jQuery(document).pngFix();
});

function ow(strSrc) {
	var left;
	var top;
	left = (screen.width - 800) / 2;
	top = (screen.height - 400) / 2 - 20;
	window.open(strSrc, "", "width=800,height=400,top=" + top + ",left=" + left + ",alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=1,copyhistory=0");
}

function show1stprofile()
{
	var qs = new Querystring();
	var action = qs.get("mev_action");
	if (action==="show_profile"){
			jQuery.ajax({
				type: "GET",
				url: "/",
				data: "mev_action=profile",
				success: function(result){
					var output = eval("(" + result + ")");
					jQuery("#firstname").val(output.firstname);
					jQuery("#lastname").val(output.lastname);
					jQuery("#emailaddress").val(output.emailaddress);
					jQuery("#screenname").val(output.screenname);


					if (!output.screenname) {
						jQuery("#screenname").removeAttr("readonly");
					}					
					jQuery("#subscribenews").attr('checked', (output.sendnewsletter === "on"));
					
					jQuery("#newpassword").val("");
					jQuery("#confirmnewpassword").val("");
					
					if (output.defaultphoto === "default") {
						jQuery("#userdefaultimage").attr('checked', true);
					}
					else {
						jQuery("#userownimage").attr('checked', true);
					}
					showprofilephoto();
					
					if (output.gender === "male") {
						jQuery("#p_gender_male").attr('checked', true);
					}
					else 
						if (output.gender === "female") {
							jQuery("#p_gender_female").attr('checked', true);
						}
					jQuery("#p_postcode").val(output.postcode);
					jQuery("#p_dob").val(output.dob);
					tb_show("Edit Profile","#TB_inline?&height=330&width=673&inlineId=profilebox&modal=true");
				}
			});
	}
}

function loadprofile()
{
	jQuery('.profilelink').click(
		function()
		{
			jQuery.ajax({
				type: "GET",
				url: "/",
				data: "mev_action=profile",
				success: function(result){					
					var output = eval("(" + result + ")" );
					jQuery("#firstname").val(output.firstname);
					jQuery("#lastname").val(output.lastname);
					jQuery("#emailaddress").val(output.emailaddress);
					jQuery("#screenname").val(output.screenname);
					jQuery("#subscribenews").attr('checked', (output.sendnewsletter==="on"));
					
					jQuery("#newpassword").val("");
					jQuery("#confirmnewpassword").val("");
					
					if (!output.screenname) {
						jQuery("#screenname").removeAttr("readonly");
					}

					if (output.defaultphoto==="default"){jQuery("#userdefaultimage").attr('checked',true);}else
					{jQuery("#userownimage").attr('checked',true);}					
					showprofilephoto();
					
					if (output.gender==="male"){jQuery("#p_gender_male").attr('checked',true);}
					else if(output.gender==="female"){jQuery("#p_gender_female").attr('checked',true);}
					jQuery("#p_postcode").val(output.postcode);
					jQuery("#p_dob").val(output.dob);
				}
			});		
		}
	);
}



function registerforumregisterlink()
{
	jQuery(".forumregister").click(
		function()
		{
			jQuery("#jointab").click();
			return false;		
		}
	);	
}

function fixiframesforIE()
{
	if (jQuery.browser.msie)
	{		
		jQuery(".hideinsidegreen").css("position","relative");
		jQuery(".hideinsidegreen").find("input[type='text']").attr("position","relative");		
		jQuery("#header").css("z-index","300");
	}
}

function setuphistory()
{
	jQuery.ajaxHistory.initialize();
}

function setupmoveupdownlinks()
{
	var graycorner = "<div id='moreinfocornerbutton' class='moreinfograycorner'></div>";
	var greencorner = "<div id='moreinfocornerbutton' class='moreinfogreencorner'></div>";
	
	jQuery(".moreinfo").click(
		function()
		{
			var morelink = jQuery(this);
			jQuery(this).prev('div.accordioncontent').slideToggle("medium",
				function()
				{
					divdisplaystatus = jQuery(this).css("display");
					if (divdisplaystatus==="block"){
						jQuery(morelink).html("LESS INFO&nbsp;"+greencorner);							
						if (jQuery(morelink).attr("maploaded")!="true")
						{
							createmap(jQuery(this).find(".targetmap"),jQuery(morelink).attr("title"));
							jQuery(morelink).attr("maploaded","true");
						}
					}
					else{
						jQuery(morelink).html("MORE INFO&nbsp;"+graycorner);
					}
				}
			);
		}
	);
	
	jQuery(".moreinfotitle").click(
		function()
		{			
			var morelink = jQuery(this).next("div.description").next("div.accordioncontent").next("div.moreinfo");
			jQuery(this).next("div.description").next('div.accordioncontent').slideToggle("medium",
				function()
				{
					divdisplaystatus = jQuery(this).css("display");
					if (divdisplaystatus==="block"){
						jQuery(morelink).html("LESS INFO&nbsp;"+greencorner);							
						if (jQuery(morelink).attr("maploaded")!="true")
						{	
							createmap(jQuery(this).find(".targetmap"),jQuery(morelink).attr("title"));
							jQuery(morelink).attr("maploaded","true");
						}
					}
					else{
						jQuery(morelink).html("MORE INFO&nbsp;"+graycorner);
					}
				}
			);						
		}
	);
}

function createmap(maptarget, url)
{
	jQuery(maptarget).html("<iframe frameborder='0' scrolling='no' style='width: 300px; height: 250px;'	src='" + url + "'></iframe>");
}

function getcontentsintodiv(url,con)
{
	jQuery.ajax({
		type: "GET",
		url: url,
		success: function(msg){
			jQuery("#" + con).html(msg);
		}
		
	});
}

function showprivacy()
{
	jQuery("#privacylink").click();
}

function showerror(title,message)
{
	if(document.getElementById("TB_overlay") === null)
	{
		var closebutton = "<input type='button' style='float:right;' onclick='tb_remove();' value='Close'></input>";
		message=message+closebutton;
		jQuery("#loginerror").html(message);		
		tb_show(title,"#TB_inline?&width=340&height=100&inlineId=messagebox&modal=true");	
	}
	else
	{
		alert(message);
	}
}

function setupbookmark()
{
	jQuery("#bookmarksite").click(
		function()
		{
			var title = "Mevolution";
			var url = "http://www.mevolution.com";
			if (window.sidebar) {// Mozilla Firefox Bookmark
				window.sidebar.addPanel(title, url,"");
			} else if( window.external ) {// IE Favorite
				window.external.AddFavorite( url, title); }
			else if(window.opera && window.print) { // Opera Hotlist
				return true; 
			}
			else{
				alert("Please press Control + D to add this page as a bookmark.");
			}
		}
	);
}

function makeround(){
	jQuery('.active .articlelistcontainer').cornerz({radius:0, background:"#E6E6E6", corners:"bl br"});
	jQuery(".inner").cornerz({radius:10, background:"#E6E6E6"});
	jQuery('.categorycontainer').cornerz({radius:10, background:"#E6E6E6", corners:"tr br bl"});
	jQuery('.topleft').cornerz({radius:10, background:"#A0BE3A", corners:"tl", borderWidth:12, borderColor:"white"});
	jQuery('.bottomleft').cornerz({radius:10, background:"#A0BE3A", corners:"bl", borderWidth:12, borderColor:"white"});
	jQuery('.reversebr').cornerz({radius:10, background:"white", corners:"br", borderWidth:12, borderColor:"#A0BE3A"});
	jQuery('#acclist').cornerz({radius:10, background:"#E6E6E6", corners:"tl bl"});

	
	//Forum Related Corners
	jQuery(".foruminner").cornerz({radius:10, background:"#E6E6E6"});
	jQuery(".topiceven").cornerz({radius:10, background:"#FFFFFF"});	
	jQuery(".topicodd").cornerz({radius:10, background:"#FFFFFF"});
	jQuery(".threadeven").cornerz({radius:10, background:"#FFFFFF"});
	jQuery(".threadodd").cornerz({radius:10, background:"#FFFFFF"});	
}

function makeroundaftercontentload()
{
	jQuery('.post').cornerz({radius:10, background:"#E6E6E6", corners:"tr br bl"});		
	jQuery('.categorycontainer').cornerz({radius:10, background:"#E6E6E6", corners:"tr br bl"});

	jQuery("h3#comments").cornerz({radius:10, background:"#E6E6E6", corners:"tl tr"});	
	jQuery(".navbar").cornerz({radius:10, background:"#E6E6E6"});
	jQuery('.commentlist li').cornerz({radius:10, background:"white", borderWidth:7, borderColor:"#E6E6E6"});
	jQuery('.commentlist').cornerz({radius:10, corners:"bl br", background:"#E6E6E6", borderColor:"white"});
	
	//Forum Related Corners
	jQuery('.wpf .commentlist').cornerz({radius:10, corners:"bl br", background:"#FFFFFF", borderColor:"white"});
	
}

function setupcontentlinks()
{
	jQuery('#contents a').click(
		function()
		{
			var url = jQuery(this).attr("href");
			var fileextension = url.substring(url.length-3);
			if (fileextension!="jpg")
			{
				getcontents(url,
					function()
					{
						if (jQuery.browser.msie)
						{
							setupIEcollapsibles();
						}
						else
						{
							setupmoveupdownlinks();
						}
					}
				);
			}
			else
			{
				tb_show("",url,true);
			}
			return false;
		}
	);
	jQuery(".commentboxlink").click(
		function()
		{
			jQuery.scrollTo("#commentlistbox");				
		}
	);
}

function getcontents_override(url,af)
{
	pasteintocontentbox(url,af);
}

function getcontents(url,af)
{
	if (url!=prevurl)
	{
		pasteintocontentbox(url,af);
	}
}

function pasteintocontentbox(url,af){
	jQuery.ajax({
		type: "GET",
		url: url,
		success: function(msg){				
			jQuery("#contents").html(msg);
			makeroundaftercontentload();												
			prevurl = url;
			setupcontentlinks();
			if(af){af();}
			
			jQuery('#contents a').click(
				function() {						
					var url = jQuery(this).attr("href");
					
					var fileextension = url.substring(url.length-3);
					if (fileextension!="jpg"){						
						window.open(url,'_target').focus();
					}
					else
					{
						tb_show("",url,true);
						return false;
					}
				}
			);
		}
	});
}

function submitcomment()
{
	var commenturl = "wp-comments-post.php";
	var comment = jQuery("#comment").val();
	
	if (comment.length>200)
	{
		showerror("commenterror","Comments should be less than 200 characters.");
	}
	else{			
		var commentid = jQuery("input[name='comment_post_ID']").attr("value");
		jQuery.ajax({
			type: "POST",
			url: commenturl,
			data: "comment=" + comment + "&comment_post_ID="+commentid,
			success: function(msg){			
				getcontents_override('/?p='+commentid);
				currentcomment = comment;
				currentpostid = commentid;
				showcomment_pop_box();
			},
			error: function(xhr, ajaxOptions, thrownError){
				showerror("commenterror","An error occurred.");
			}	
		});
	}
}

function refresh(){
    window.location.reload();
}

function redirect(sURL){
	window.location = sURL;
}

function setupnavlinks()
{
	jQuery('#acclist a').click(
		function()
		{
			getcontents(jQuery(this).attr("href"));
			return false;
		}
	);
}

function moveratingcontrol()
{
	var t=jQuery(".ratingcontrol").html();
	jQuery(".ratingcontrol").html("");
	//jQuery("#commentform").prepend(t);
	jQuery("#commentratebox").prepend(t);
}


function checkurl()
{
	var queryString = window.location.href.substring((window.location.href.indexOf('=') + 1), (window.location.href.indexOf('=') + 4));	
	switch (queryString)
	{
		case '28#':
		    //Articles
		    break;
		case '49':
		    //Events
		    break;
		case '31':
		    //Forum
		    break;
		case '100':			
		    //Directory
		    break;
		default:
		    //Home
	}
}

function showsearchresults()
{
	var hash = window.location.hash;
	if (hash.substring(1,12)=="searchgroup"){		
		var query = hash.substring(13,hash.length);
		if(hash.substring(12,13)=="/"){
			showgroupsearchresults(query);	
		}
	}
	else if(hash.substring(1,14)=="searchproduct"){
		var query = hash.substring(15,hash.length);
		if(hash.substring(14,15)=="/"){
			showproductsearchresults(query);
		}			
	}
	else if(hash.substring(1,19)=="searchpractitioner"){
		var query = hash.substring(20,hash.length);
		if(hash.substring(19,20)=="/"){			
			showpractitionersearchresults(query);			
		}
	}
}

function showgroupsearchresults(query){
	getcontents("/?dir_action=showdirectories&dir_type=Groups&dir_query="+query,
		function()
		{
			jQuery("#txtgroupsearch").val(query);
			jQuery('#acclist').accordion("activate",1);
			
			makeroundaftercontentload();
			if (jQuery.browser.msie)
			{
				setupIEcollapsibles();
			}
			else
			{
				setupmoveupdownlinks();
			}			
		}
	);
}

function showproductsearchresults(query){
	getcontents("/?dir_action=showdirectories&dir_type=Products&dir_query="+query,
		function()
		{
			jQuery("#txtproductsearch").val(query);
			jQuery('#acclist').accordion("activate",0);
			
			makeroundaftercontentload();
			if (jQuery.browser.msie)
			{
				setupIEcollapsibles();
			}
			else
			{
				setupmoveupdownlinks();
			}			
		}
	);
}

function showpractitionersearchresults(query){
	getcontents("/?dir_action=showdirectories&dir_type=Practitioners&dir_query="+query,
		function()
		{
			jQuery("#txtpracsearch").val(query);
			jQuery('#acclist').accordion("activate",2);
			
			makeroundaftercontentload();
			if (jQuery.browser.msie)
			{
				setupIEcollapsibles();
			}
			else
			{
				setupmoveupdownlinks();
			}			
		}
	);
}


function setupIEcollapsibles()
{
	var graycorner = "<div id='moreinfocornerbutton' class='moreinfograycorner'></div>";
	var greencorner = "<div id='moreinfocornerbutton' class='moreinfogreencorner'></div>";	
	jQuery(".moreinfo").click(
		function()
		{						
			var morelink = jQuery(this);
			jQuery(this).prev('div.accordioncontent').slideToggle("medium",
				function()
				{
					divdisplaystatus = jQuery(this).css("display");
					if (divdisplaystatus==="block"){
						jQuery(morelink).html("LESS INFO&nbsp;"+greencorner);							
						if (jQuery(morelink).attr("maploaded")!="true")
						{	
							createmap(jQuery(this).find(".targetmap"),jQuery(morelink).attr("title"));
							jQuery(morelink).attr("maploaded","true");
						}
					}
					else{
						jQuery(morelink).html("MORE INFO&nbsp;"+graycorner);
					}
				}
			);
		}
	);
	jQuery(".moreinfotitle").click(
		function()
		{			
			var morelink = jQuery(this).next("div.description").next("div.accordioncontent").next("div.moreinfo");
			jQuery(this).next("div.description").next('div.accordioncontent').slideToggle("medium",
				function()
				{
					divdisplaystatus = jQuery(this).css("display");
					if (divdisplaystatus==="block"){
						jQuery(morelink).html("LESS INFO&nbsp;"+greencorner);							
						if (jQuery(morelink).attr("maploaded")!="true")
						{	
							createmap(jQuery(this).find(".targetmap"),jQuery(morelink).attr("title"));
							jQuery(morelink).attr("maploaded","true");
						}
					}
					else{
						jQuery(morelink).html("MORE INFO&nbsp;"+graycorner);
					}
				}
			);						
		}
	);
}


//Start Articles (Social Networking)

function showcomment_pop_box()
{
	tb_show("Click below to also publish your comment on:","#TB_inline?&height=35&width=500&inlineId=articlecommentpopbox&modal=true");
}

function callPublish(attachment, action_link) {
	tb_remove();
	var msg = currentcomment;
	var postid = currentpostid;
	FB.ensureInit(function () {
		var loc = ". Posted at http://www.mevolution.com/articles#ate" + postid;
		msg=msg+loc;
		FB.Connect.streamPublish(msg, attachment, null, null, 'What do you think?', fbcallback);
	});
}

function fbcallback (post_id, exception) {
	if(post_id){
		//submitcomment();
	}
} 

function postusingtwitterauth(userid){
	tb_remove();
	var postid = currentpostid;
	message = URLEncode("Posted a comment at http://www.mevolution.com/articles#ate" + postid);
	ow('http://mevolution.com/?mev_action=authorisetwitter&commenttype=article&u='+userid+'&message='+message);
}
//End Articles (Social Networking)

//Start Forum (Social Networking)

function showforumcomment_pop_box()
{
	tb_show("Click below to also publish your comment on:","#TB_inline?&height=35&width=500&inlineId=forumcommentpopbox&modal=true");
}

function callPublish_Forum(attachment, action_link) {
	tb_remove();
	var msg = jQuery('#lastcomment').html();
	FB.ensureInit(function () {
		var url = window.location.toString().replace("&posttosn=1","");
		var loc = ". Posted at " + url;
		msg=msg+loc;
		FB.Connect.streamPublish(msg, attachment, null, null, 'What do you think?', fbcallback_Forum);
	});
}

function fbcallback_Forum(post_id, exception) {
	if(post_id){
		//jQuery("#forumcommentbutton").click();
	}
}

function postusingtwitterauth_Forum(userid){
	tb_remove();
	var url = window.location.toString().replace("&posttosn=1","");
	var message = URLEncode("Posted a comment at " + url);	
	ow('http://mevolution.com/?mev_action=authorisetwitter&commenttype=forum&u='+userid+'&message='+message);jQuery("#forumcommentbutton").click();
}
//End Forum (Social Networking)



function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


//Not needed
function postviatwitter()
{
	var twitterid = jQuery("#twitterid").val();
	var password = jQuery("#twitterpassword").val();
	var comment = document.getElementById('comment').value;
	var message = "Posted a comment at " + window.location;
	jQuery.ajax({
		type: "POST",
		url: "/",
		data: "mev_action=twitterlogin&twitterid="+ twitterid +"&twitterpassword="+ escape(password) + "&message=" + message,
		success: function(msg){			
			var redirecturl = window.location || window.location.hash;			
			if(msg==="yes"){
				//refresh(redirecturl);
				submitcomment();
			}
			else
			{				
				showerror("loginerror","Your twitter id or password is incorrect. Please try again.");
			}
		}
	});
}
//Not needed


function HtmlDecode(s)
{
      var out = "";
      if (s==null) return;
      var l = s.length;
      for (var i=0; i<l; i++)
      {
            var ch = s.charAt(i);
            if (ch == '&')
            {
                  var semicolonIndex = s.indexOf(';', i+1);
				if (semicolonIndex > 0)
				{
					var entity = s.substring(i + 1, semicolonIndex);
                    if (entity.length > 1 && entity.charAt(0) == '#')
                    {
						if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X')
							ch = String.fromCharCode(eval('0'+entity.substring(1)));
                              else

                                    ch = String.fromCharCode(eval(entity.substring(1)));

                        }

                    else

                      {

                              switch (entity)

                              {

                                    case 'quot': ch = String.fromCharCode(0x0022); break;

                                    case 'amp': ch = String.fromCharCode(0x0026); break;

                                    case 'lt': ch = String.fromCharCode(0x003c); break;

                                    case 'gt': ch = String.fromCharCode(0x003e); break;

                                    case 'nbsp': ch = String.fromCharCode(0x00a0); break;

                                    case 'iexcl': ch = String.fromCharCode(0x00a1); break;

                                    case 'cent': ch = String.fromCharCode(0x00a2); break;

                                    case 'pound': ch = String.fromCharCode(0x00a3); break;

                                    case 'curren': ch = String.fromCharCode(0x00a4); break;

                                    case 'yen': ch = String.fromCharCode(0x00a5); break;

                                    case 'brvbar': ch = String.fromCharCode(0x00a6); break;

                                    case 'sect': ch = String.fromCharCode(0x00a7); break;

                                    case 'uml': ch = String.fromCharCode(0x00a8); break;

                                    case 'copy': ch = String.fromCharCode(0x00a9); break;

                                    case 'ordf': ch = String.fromCharCode(0x00aa); break;

                                    case 'laquo': ch = String.fromCharCode(0x00ab); break;

                                    case 'not': ch = String.fromCharCode(0x00ac); break;

                                    case 'shy': ch = String.fromCharCode(0x00ad); break;

                                    case 'reg': ch = String.fromCharCode(0x00ae); break;

                                    case 'macr': ch = String.fromCharCode(0x00af); break;

                                    case 'deg': ch = String.fromCharCode(0x00b0); break;

                                    case 'plusmn': ch = String.fromCharCode(0x00b1); break;

                                    case 'sup2': ch = String.fromCharCode(0x00b2); break;

                                    case 'sup3': ch = String.fromCharCode(0x00b3); break;

                                    case 'acute': ch = String.fromCharCode(0x00b4); break;

                                    case 'micro': ch = String.fromCharCode(0x00b5); break;

                                    case 'para': ch = String.fromCharCode(0x00b6); break;

                                    case 'middot': ch = String.fromCharCode(0x00b7); break;

                                    case 'cedil': ch = String.fromCharCode(0x00b8); break;

                                    case 'sup1': ch = String.fromCharCode(0x00b9); break;

                                    case 'ordm': ch = String.fromCharCode(0x00ba); break;

                                    case 'raquo': ch = String.fromCharCode(0x00bb); break;

                                    case 'frac14': ch = String.fromCharCode(0x00bc); break;

                                    case 'frac12': ch = String.fromCharCode(0x00bd); break;

                                    case 'frac34': ch = String.fromCharCode(0x00be); break;

                                    case 'iquest': ch = String.fromCharCode(0x00bf); break;

                                    case 'Agrave': ch = String.fromCharCode(0x00c0); break;

                                    case 'Aacute': ch = String.fromCharCode(0x00c1); break;

                                    case 'Acirc': ch = String.fromCharCode(0x00c2); break;

                                    case 'Atilde': ch = String.fromCharCode(0x00c3); break;

                                    case 'Auml': ch = String.fromCharCode(0x00c4); break;

                                    case 'Aring': ch = String.fromCharCode(0x00c5); break;

                                    case 'AElig': ch = String.fromCharCode(0x00c6); break;

                                    case 'Ccedil': ch = String.fromCharCode(0x00c7); break;

                                    case 'Egrave': ch = String.fromCharCode(0x00c8); break;

                                    case 'Eacute': ch = String.fromCharCode(0x00c9); break;

                                    case 'Ecirc': ch = String.fromCharCode(0x00ca); break;

                                    case 'Euml': ch = String.fromCharCode(0x00cb); break;

                                    case 'Igrave': ch = String.fromCharCode(0x00cc); break;

                                    case 'Iacute': ch = String.fromCharCode(0x00cd); break;

                                    case 'Icirc': ch = String.fromCharCode(0x00ce ); break;

                                    case 'Iuml': ch = String.fromCharCode(0x00cf); break;

                                    case 'ETH': ch = String.fromCharCode(0x00d0); break;

                                    case 'Ntilde': ch = String.fromCharCode(0x00d1); break;

                                    case 'Ograve': ch = String.fromCharCode(0x00d2); break;

                                    case 'Oacute': ch = String.fromCharCode(0x00d3); break;

                                    case 'Ocirc': ch = String.fromCharCode(0x00d4); break;

                                    case 'Otilde': ch = String.fromCharCode(0x00d5); break;

                                    case 'Ouml': ch = String.fromCharCode(0x00d6); break;

                                    case 'times': ch = String.fromCharCode(0x00d7); break;

                                    case 'Oslash': ch = String.fromCharCode(0x00d8); break;

                                    case 'Ugrave': ch = String.fromCharCode(0x00d9); break;

                                    case 'Uacute': ch = String.fromCharCode(0x00da); break;

                                    case 'Ucirc': ch = String.fromCharCode(0x00db); break;

                                    case 'Uuml': ch = String.fromCharCode(0x00dc); break;

                                    case 'Yacute': ch = String.fromCharCode(0x00dd); break;

                                    case 'THORN': ch = String.fromCharCode(0x00de); break;

                                    case 'szlig': ch = String.fromCharCode(0x00df); break;

                                    case 'agrave': ch = String.fromCharCode(0x00e0); break;

                                    case 'aacute': ch = String.fromCharCode(0x00e1); break;

                                    case 'acirc': ch = String.fromCharCode(0x00e2); break;

                                    case 'atilde': ch = String.fromCharCode(0x00e3); break;

                                    case 'auml': ch = String.fromCharCode(0x00e4); break;

                                    case 'aring': ch = String.fromCharCode(0x00e5); break;

                                    case 'aelig': ch = String.fromCharCode(0x00e6); break;

                                    case 'ccedil': ch = String.fromCharCode(0x00e7); break;

                                    case 'egrave': ch = String.fromCharCode(0x00e8); break;

                                    case 'eacute': ch = String.fromCharCode(0x00e9); break;

                                    case 'ecirc': ch = String.fromCharCode(0x00ea); break;

                                    case 'euml': ch = String.fromCharCode(0x00eb); break;

                                    case 'igrave': ch = String.fromCharCode(0x00ec); break;

                                    case 'iacute': ch = String.fromCharCode(0x00ed); break;

                                    case 'icirc': ch = String.fromCharCode(0x00ee); break;

                                    case 'iuml': ch = String.fromCharCode(0x00ef); break;

                                    case 'eth': ch = String.fromCharCode(0x00f0); break;

                                    case 'ntilde': ch = String.fromCharCode(0x00f1); break;

                                    case 'ograve': ch = String.fromCharCode(0x00f2); break;

                                    case 'oacute': ch = String.fromCharCode(0x00f3); break;

                                    case 'ocirc': ch = String.fromCharCode(0x00f4); break;

                                    case 'otilde': ch = String.fromCharCode(0x00f5); break;

                                    case 'ouml': ch = String.fromCharCode(0x00f6); break;

                                    case 'divide': ch = String.fromCharCode(0x00f7); break;

                                    case 'oslash': ch = String.fromCharCode(0x00f8); break;

                                    case 'ugrave': ch = String.fromCharCode(0x00f9); break;

                                    case 'uacute': ch = String.fromCharCode(0x00fa); break;

                                    case 'ucirc': ch = String.fromCharCode(0x00fb); break;

                                    case 'uuml': ch = String.fromCharCode(0x00fc); break;

                                    case 'yacute': ch = String.fromCharCode(0x00fd); break;

                                    case 'thorn': ch = String.fromCharCode(0x00fe); break;

                                    case 'yuml': ch = String.fromCharCode(0x00ff); break;

                                    case 'OElig': ch = String.fromCharCode(0x0152); break;

                                    case 'oelig': ch = String.fromCharCode(0x0153); break;

                                    case 'Scaron': ch = String.fromCharCode(0x0160); break;

                                    case 'scaron': ch = String.fromCharCode(0x0161); break;

                                    case 'Yuml': ch = String.fromCharCode(0x0178); break;

                                    case 'fnof': ch = String.fromCharCode(0x0192); break;

                                    case 'circ': ch = String.fromCharCode(0x02c6); break;

                                    case 'tilde': ch = String.fromCharCode(0x02dc); break;

                                    case 'Alpha': ch = String.fromCharCode(0x0391); break;

                                    case 'Beta': ch = String.fromCharCode(0x0392); break;

                                    case 'Gamma': ch = String.fromCharCode(0x0393); break;

                                    case 'Delta': ch = String.fromCharCode(0x0394); break;

                                    case 'Epsilon': ch = String.fromCharCode(0x0395); break;

                                    case 'Zeta': ch = String.fromCharCode(0x0396); break;

                                    case 'Eta': ch = String.fromCharCode(0x0397); break;

                                    case 'Theta': ch = String.fromCharCode(0x0398); break;

                                    case 'Iota': ch = String.fromCharCode(0x0399); break;

                                    case 'Kappa': ch = String.fromCharCode(0x039a); break;

                                    case 'Lambda': ch = String.fromCharCode(0x039b); break;

                                    case 'Mu': ch = String.fromCharCode(0x039c); break;

                                    case 'Nu': ch = String.fromCharCode(0x039d); break;

                                    case 'Xi': ch = String.fromCharCode(0x039e); break;

                                    case 'Omicron': ch = String.fromCharCode(0x039f); break;

                                    case 'Pi': ch = String.fromCharCode(0x03a0); break;

                                    case ' Rho ': ch = String.fromCharCode(0x03a1); break;

                                    case 'Sigma': ch = String.fromCharCode(0x03a3); break;

                                    case 'Tau': ch = String.fromCharCode(0x03a4); break;

                                    case 'Upsilon': ch = String.fromCharCode(0x03a5); break;

                                    case 'Phi': ch = String.fromCharCode(0x03a6); break;

                                    case 'Chi': ch = String.fromCharCode(0x03a7); break;

                                    case 'Psi': ch = String.fromCharCode(0x03a8); break;

                                    case 'Omega': ch = String.fromCharCode(0x03a9); break;

                                    case 'alpha': ch = String.fromCharCode(0x03b1); break;

                                    case 'beta': ch = String.fromCharCode(0x03b2); break;

                                    case 'gamma': ch = String.fromCharCode(0x03b3); break;

                                    case 'delta': ch = String.fromCharCode(0x03b4); break;

                                    case 'epsilon': ch = String.fromCharCode(0x03b5); break;

                                    case 'zeta': ch = String.fromCharCode(0x03b6); break;

                                    case 'eta': ch = String.fromCharCode(0x03b7); break;

                                    case 'theta': ch = String.fromCharCode(0x03b8); break;

                                    case 'iota': ch = String.fromCharCode(0x03b9); break;

                                    case 'kappa': ch = String.fromCharCode(0x03ba); break;

                                    case 'lambda': ch = String.fromCharCode(0x03bb); break;

                                    case 'mu': ch = String.fromCharCode(0x03bc); break;

                                    case 'nu': ch = String.fromCharCode(0x03bd); break;

                                    case 'xi': ch = String.fromCharCode(0x03be); break;

                                    case 'omicron': ch = String.fromCharCode(0x03bf); break;

                                    case 'pi': ch = String.fromCharCode(0x03c0); break;

                                    case 'rho': ch = String.fromCharCode(0x03c1); break;

                                    case 'sigmaf': ch = String.fromCharCode(0x03c2); break;

                                    case 'sigma': ch = String.fromCharCode(0x03c3); break;

                                    case 'tau': ch = String.fromCharCode(0x03c4); break;

                                    case 'upsilon': ch = String.fromCharCode(0x03c5); break;

                                    case 'phi': ch = String.fromCharCode(0x03c6); break;

                                    case 'chi': ch = String.fromCharCode(0x03c7); break;

                                    case 'psi': ch = String.fromCharCode(0x03c8); break;

                                    case 'omega': ch = String.fromCharCode(0x03c9); break;

                                    case 'thetasym': ch = String.fromCharCode(0x03d1); break;

                                    case 'upsih': ch = String.fromCharCode(0x03d2); break;

                                    case 'piv': ch = String.fromCharCode(0x03d6); break;

                                    case 'ensp': ch = String.fromCharCode(0x2002); break;

                                    case 'emsp': ch = String.fromCharCode(0x2003); break;

                                    case 'thinsp': ch = String.fromCharCode(0x2009); break;

                                    case 'zwnj': ch = String.fromCharCode(0x200c); break;

                                    case 'zwj': ch = String.fromCharCode(0x200d); break;

                                    case 'lrm': ch = String.fromCharCode(0x200e); break;

                                    case 'rlm': ch = String.fromCharCode(0x200f); break;

                                    case 'ndash': ch = String.fromCharCode(0x2013); break;

                                    case 'mdash': ch = String.fromCharCode(0x2014); break;

                                    case 'lsquo': ch = String.fromCharCode(0x2018); break;

                                    case 'rsquo': ch = String.fromCharCode(0x2019); break;

                                    case 'sbquo': ch = String.fromCharCode(0x201a); break;

                                    case 'ldquo': ch = String.fromCharCode(0x201c); break;

                                    case 'rdquo': ch = String.fromCharCode(0x201d); break;

                                    case 'bdquo': ch = String.fromCharCode(0x201e); break;

                                    case 'dagger': ch = String.fromCharCode(0x2020); break;

                                    case 'Dagger': ch = String.fromCharCode(0x2021); break;

                                    case 'bull': ch = String.fromCharCode(0x2022); break;

                                    case 'hellip': ch = String.fromCharCode(0x2026); break;

                                    case 'permil': ch = String.fromCharCode(0x2030); break;

                                    case 'prime': ch = String.fromCharCode(0x2032); break;

                                    case 'Prime': ch = String.fromCharCode(0x2033); break;

                                    case 'lsaquo': ch = String.fromCharCode(0x2039); break;

                                    case 'rsaquo': ch = String.fromCharCode(0x203a); break;

                                    case 'oline': ch = String.fromCharCode(0x203e); break;

                                    case 'frasl': ch = String.fromCharCode(0x2044); break;

                                    case 'euro': ch = String.fromCharCode(0x20ac); break;

                                    case 'image': ch = String.fromCharCode(0x2111); break;

                                    case 'weierp': ch = String.fromCharCode(0x2118); break;

                                    case 'real': ch = String.fromCharCode(0x211c); break;

                                    case 'trade': ch = String.fromCharCode(0x2122); break;

                                    case 'alefsym': ch = String.fromCharCode(0x2135); break;

                                    case 'larr': ch = String.fromCharCode(0x2190); break;

                                    case 'uarr': ch = String.fromCharCode(0x2191); break;

                                    case 'rarr': ch = String.fromCharCode(0x2192); break;

                                    case 'darr': ch = String.fromCharCode(0x2193); break;

                                    case 'harr': ch = String.fromCharCode(0x2194); break;

                                    case 'crarr': ch = String.fromCharCode(0x21b5); break;

                                    case 'lArr': ch = String.fromCharCode(0x21d0); break;

                                    case 'uArr': ch = String.fromCharCode(0x21d1); break;

                                    case 'rArr': ch = String.fromCharCode(0x21d2); break;

                                    case 'dArr': ch = String.fromCharCode(0x21d3); break;

                                    case 'hArr': ch = String.fromCharCode(0x21d4); break;

                                    case 'forall': ch = String.fromCharCode(0x2200); break;

                                    case 'part': ch = String.fromCharCode(0x2202); break;

                                    case 'exist': ch = String.fromCharCode(0x2203); break;

                                    case 'empty': ch = String.fromCharCode(0x2205); break;

                                    case 'nabla': ch = String.fromCharCode(0x2207); break;

                                    case 'isin': ch = String.fromCharCode(0x2208); break;

                                    case 'notin': ch = String.fromCharCode(0x2209); break;

                                    case 'ni': ch = String.fromCharCode(0x220b); break;

                                    case 'prod': ch = String.fromCharCode(0x220f); break;

                                    case 'sum': ch = String.fromCharCode(0x2211); break;

                                    case 'minus': ch = String.fromCharCode(0x2212); break;

                                    case 'lowast': ch = String.fromCharCode(0x2217); break;

                                    case 'radic': ch = String.fromCharCode(0x221a); break;

                                    case 'prop': ch = String.fromCharCode(0x221d); break;

                                    case 'infin': ch = String.fromCharCode(0x221e); break;

                                    case 'ang': ch = String.fromCharCode(0x2220); break;

                                    case 'and': ch = String.fromCharCode(0x2227); break;

                                    case 'or': ch = String.fromCharCode(0x2228); break;

                                    case 'cap': ch = String.fromCharCode(0x2229); break;

                                    case 'cup': ch = String.fromCharCode(0x222a); break;

                                    case 'int': ch = String.fromCharCode(0x222b); break;

                                    case 'there4': ch = String.fromCharCode(0x2234); break;

                                    case 'sim': ch = String.fromCharCode(0x223c); break;

                                    case 'cong': ch = String.fromCharCode(0x2245); break;

                                    case 'asymp': ch = String.fromCharCode(0x2248); break;

                                    case 'ne': ch = String.fromCharCode(0x2260); break;

                                    case 'equiv': ch = String.fromCharCode(0x2261); break;

                                    case 'le': ch = String.fromCharCode(0x2264); break;

                                    case 'ge': ch = String.fromCharCode(0x2265); break;

                                    case 'sub': ch = String.fromCharCode(0x2282); break;

                                    case 'sup': ch = String.fromCharCode(0x2283); break;

                                    case 'nsub': ch = String.fromCharCode(0x2284); break;

                                    case 'sube': ch = String.fromCharCode(0x2286); break;

                                    case 'supe': ch = String.fromCharCode(0x2287); break;

                                    case 'oplus': ch = String.fromCharCode(0x2295); break;

                                    case 'otimes': ch = String.fromCharCode(0x2297); break;

                                    case 'perp': ch = String.fromCharCode(0x22a5); break;

                                    case 'sdot': ch = String.fromCharCode(0x22c5); break;

                                    case 'lceil': ch = String.fromCharCode(0x2308); break;

                                    case 'rceil': ch = String.fromCharCode(0x2309); break;

                                    case 'lfloor': ch = String.fromCharCode(0x230a); break;

                                    case 'rfloor': ch = String.fromCharCode(0x230b); break;

                                    case 'lang': ch = String.fromCharCode(0x2329); break;

                                    case 'rang': ch = String.fromCharCode(0x232a); break;

                                    case 'loz': ch = String.fromCharCode(0x25ca); break;

                                    case 'spades': ch = String.fromCharCode(0x2660); break;

                                    case 'clubs': ch = String.fromCharCode(0x2663); break;

                                    case 'hearts': ch = String.fromCharCode(0x2665); break;

                                    case 'diams': ch = String.fromCharCode(0x2666); break;

                                    default: ch = ''; break;

                              }

                        }

                        i = semicolonIndex;

                  }

            }

           

            out += ch;

      }

 

      return out;
}
/*
 * jQuery UI Accordion 1.6
 * 
 * Copyright (c) 2007 Jörn Zaefferer
 *
 * http://docs.jquery.com/UI/Accordion
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.accordion.js 4876 2008-03-08 11:49:04Z joern.zaefferer $
 *
 */

;(function($) {
	
// If the UI scope is not available, add it
$.ui = $.ui || {};

$.fn.extend({
	accordion: function(options, data) {
		var args = Array.prototype.slice.call(arguments, 1);

		return this.each(function() {
			if (typeof options == "string") {
				var accordion = $.data(this, "ui-accordion");
				accordion[options].apply(accordion, args);
			// INIT with optional options
			} else if (!$(this).is(".ui-accordion"))
				$.data(this, "ui-accordion", new $.ui.accordion(this, options));
		});
	},
	// deprecated, use accordion("activate", index) instead
	activate: function(index) {
		return this.accordion("activate", index);
	}
});

$.ui.accordion = function(container, options) {
	
	// setup configuration
	this.options = options = $.extend({}, $.ui.accordion.defaults, options);
	this.element = container;
	
	$(container).addClass("ui-accordion");
	
	if ( options.navigation ) {
		var current = $(container).find("a").filter(options.navigationFilter);
		if ( current.length ) {
			if ( current.filter(options.header).length ) {
				options.active = current;
			} else {
				options.active = current.parent().parent().prev();
				current.addClass("current");
			}
		}
	}
	
	// calculate active if not specified, using the first header
	options.headers = $(container).find(options.header);
	options.active = findActive(options.headers, options.active);

	if ( options.fillSpace ) {
		var maxHeight = $(container).parent().height();
		options.headers.each(function() {
			maxHeight -= $(this).outerHeight();
		});
		var maxPadding = 0;
		options.headers.next().each(function() {
			maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
		}).height(maxHeight - maxPadding);
	} else if ( options.autoheight ) {
		var maxHeight = 0;
		options.headers.next().each(function() {
			maxHeight = Math.max(maxHeight, $(this).outerHeight());
		}).height(maxHeight);
	}

	options.headers
		.not(options.active || "")
		.next()
		.hide();
	options.active.parent().andSelf().addClass(options.selectedClass);
	
	if (options.event)
		$(container).bind((options.event) + ".ui-accordion", clickHandler);
};

$.ui.accordion.prototype = {
	activate: function(index) {
		// call clickHandler with custom event
		clickHandler.call(this.element, {
			target: findActive( this.options.headers, index )[0]
		});
	},
	
	enable: function() {
		this.options.disabled = false;
	},
	disable: function() {
		this.options.disabled = true;
	},
	destroy: function() {
		this.options.headers.next().css("display", "");
		if ( this.options.fillSpace || this.options.autoheight ) {
			this.options.headers.next().css("height", "");
		}
		$.removeData(this.element, "ui-accordion");
		$(this.element).removeClass("ui-accordion").unbind(".ui-accordion");
	}
}

function scopeCallback(callback, scope) {
	return function() {
		return callback.apply(scope, arguments);
	};
}

function completed(cancel) {
	// if removed while animated data can be empty
	if (!$.data(this, "ui-accordion"))
		return;
	var instance = $.data(this, "ui-accordion");
	var options = instance.options;
	options.running = cancel ? 0 : --options.running;
	if ( options.running )
		return;
	if ( options.clearStyle ) {
		options.toShow.add(options.toHide).css({
			height: "",
			overflow: ""
		});
	}
	
	jQuery("#acclist div.title").removeClass("selectedtop");
	jQuery("#acclist div.title").removeClass("selectedbottom");
	jQuery(options.toShow.next('div')).addClass("selectedtop");
	jQuery(jQuery(jQuery(options.toShow.prev('div'))).prev('div')).prev('div').addClass("selectedbottom");
			
	$(this).triggerHandler("change.ui-accordion", [options.data], options.change);
}

function toggle(toShow, toHide, data, clickedActive, down) {
	var options = $.data(this, "ui-accordion").options;
	options.toShow = toShow;
	options.toHide = toHide;
	options.data = data;
	var complete = scopeCallback(completed, this);
	
	// count elements to animate
	options.running = toHide.size() == 0 ? toShow.size() : toHide.size();
	
	if ( options.animated ) {
		if ( !options.alwaysOpen && clickedActive ) {
			$.ui.accordion.animations[options.animated]({
				toShow: jQuery([]),
				toHide: toHide,
				complete: complete,
				down: down,
				autoheight: options.autoheight
			});
		} else {
			$.ui.accordion.animations[options.animated]({
				toShow: toShow,
				toHide: toHide,
				complete: complete,
				down: down,
				autoheight: options.autoheight
			});
		}
	} else {
		if ( !options.alwaysOpen && clickedActive ) {
			toShow.toggle();
		} else {
			toHide.hide();
			toShow.show();
		}
		complete(true);
	}
}

function clickHandler(event) {	

	var options = $.data(this, "ui-accordion").options;
	if (options.disabled)
		return false;
	
	// called only when using activate(false) to close all parts programmatically
	if ( !event.target && !options.alwaysOpen ) {
		options.active.parent().andSelf().toggleClass(options.selectedClass);
		var toHide = options.active.next(),
			data = {
				instance: this,
				options: options,
				newHeader: jQuery([]),
				oldHeader: options.active,
				newContent: jQuery([]),
				oldContent: toHide
			},
			toShow = options.active = $([]);
		toggle.call(this, toShow, toHide, data );
		return false;
	}
	// get the click target
	var clicked = $(event.target);
	
	// due to the event delegation model, we have to check if one
	// of the parent elements is our actual header, and find that
	if ( clicked.parents(options.header).length )
		while ( !clicked.is(options.header) )
			clicked = clicked.parent();
	
	var clickedActive = clicked[0] == options.active[0];
	
	// if animations are still active, or the active header is the target, ignore click
	if (options.running || (options.alwaysOpen && clickedActive))
		return false;
	if (!clicked.is(options.header))
		return;

	// switch classes
	options.active.parent().andSelf().toggleClass(options.selectedClass);
	if ( !clickedActive ) {
		clicked.parent().andSelf().addClass(options.selectedClass);
	}

	// find elements to show and hide
	var toShow = clicked.next(),
		toHide = options.active.next(),
		//data = [clicked, options.active, toShow, toHide],
		data = {
			instance: this,
			options: options,
			newHeader: clicked,
			oldHeader: options.active,
			newContent: toShow,
			oldContent: toHide
		},
		down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
	
	options.active = clickedActive ? $([]) : clicked;
	toggle.call(this, toShow, toHide, data, clickedActive, down );
	
	//customise

	return false;
};

function findActive(headers, selector) {
	return selector != undefined
		? typeof selector == "number"
			? headers.filter(":eq(" + selector + ")")
			: headers.not(headers.not(selector))
		: selector === false
			? $([])
			: headers.filter(":eq(0)");
}

$.extend($.ui.accordion, {
	defaults: {
		selectedClass: "selected",
		alwaysOpen: true,
		animated: 'slide',
		event: "click",
		header: "a",
		autoheight: true,
		running: 0,
		navigationFilter: function() {
			return this.href.toLowerCase() == location.href.toLowerCase();
		}
	},
	animations: {
		slide: function(options, additions) {
			options = $.extend({
				easing: "swing",
				duration: 300
			}, options, additions);
			if ( !options.toHide.size() ) {
				options.toShow.animate({height: "show"}, options);
				return;
			}
			var hideHeight = options.toHide.height(),
				showHeight = options.toShow.height(),
				difference = showHeight / hideHeight;
			options.toShow.css({ height: 0, overflow: 'hidden' }).show();
			options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
				step: function(now) {
					var current = (hideHeight - now) * difference;
					if ($.browser.msie || $.browser.opera) {
						current = Math.ceil(current);
					}
					options.toShow.height( current );
				},
				duration: options.duration,
				easing: options.easing,
				complete: function() {
					if ( !options.autoheight ) {
						options.toShow.css("height", "auto");
					}
					options.complete();
				}
			});
		},
		bounceslide: function(options) {
			this.slide(options, {
				easing: options.down ? "bounceout" : "swing",
				duration: options.down ? 1000 : 200
			});
		},
		easeslide: function(options) {
			this.slide(options, {
				easing: "easeinout",
				duration: 700
			})
		}
	}
});

})(jQuery);
/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {
	
	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		/*
		jQuery(this).find("img[@src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});
		*/
		
		

		// fix css background pngs
		jQuery(this).find(".png").each(function(){			
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}			
		});
		
		//fix input with png-source
		/*
		jQuery(this).find("input[@src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});*/
	
	}
	
	return jQuery;

};

})(jQuery);
var Core = {};

// W3C DOM 2 Events model
if (document.addEventListener)
{
  Core.addEventListener = function(target, type, listener)
  {
    target.addEventListener(type, listener, false);
  };

  Core.removeEventListener = function(target, type, listener)
  {
    target.removeEventListener(type, listener, false);
  };

  Core.preventDefault = function(event)
  {
    event.preventDefault();
  };

  Core.stopPropagation = function(event)
  {
    event.stopPropagation();
  };
}
// Internet Explorer Events model
else if (document.attachEvent)
{
  Core.addEventListener = function(target, type, listener)
  {
    // prevent adding the same listener twice, since DOM 2 Events ignores
    // duplicates like this
    if (Core._findListener(target, type, listener) != -1) return;

    // listener2 calls listener as a method of target in one of two ways,
    // depending on what this version of IE supports, and passes it the global
    // event object as an argument
    var listener2 = function()
    {
      var event = window.event;

      if (Function.prototype.call)
      {
        listener.call(target, event);
      }
      else
      {
        target._currentListener = listener;
        target._currentListener(event)
        target._currentListener = null;
      }
    };

    // add listener2 using IE's attachEvent method
    target.attachEvent("on" + type, listener2);

    // create an object describing this listener so we can clean it up later
    var listenerRecord =
    {
      target: target,
      type: type,
      listener: listener,
      listener2: listener2
    };

    // get a reference to the window object containing target
    var targetDocument = target.document || target;
    var targetWindow = targetDocument.parentWindow;

    // create a unique ID for this listener
    var listenerId = "l" + Core._listenerCounter++;

    // store a record of this listener in the window object
    if (!targetWindow._allListeners) targetWindow._allListeners = {};
    targetWindow._allListeners[listenerId] = listenerRecord;

    // store this listener's ID in target
    if (!target._listeners) target._listeners = [];
    target._listeners[target._listeners.length] = listenerId;

    // set up Core._removeAllListeners to clean up all listeners on unload
    if (!targetWindow._unloadListenerAdded)
    {
      targetWindow._unloadListenerAdded = true;
      targetWindow.attachEvent("onunload", Core._removeAllListeners);
    }
  };

  Core.removeEventListener = function(target, type, listener)
  {
    // find out if the listener was actually added to target
    var listenerIndex = Core._findListener(target, type, listener);
    if (listenerIndex == -1) return;

    // get a reference to the window object containing target
    var targetDocument = target.document || target;
    var targetWindow = targetDocument.parentWindow;

    // obtain the record of the listener from the window object
    var listenerId = target._listeners[listenerIndex];
    var listenerRecord = targetWindow._allListeners[listenerId];

    // remove the listener, and remove its ID from target
    target.detachEvent("on" + type, listenerRecord.listener2);
    target._listeners.splice(listenerIndex, 1);

    // remove the record of the listener from the window object
    delete targetWindow._allListeners[listenerId];
  };

  Core.preventDefault = function(event)
  {
    event.returnValue = false;
  };

  Core.stopPropagation = function(event)
  {
    event.cancelBubble = true;
  };

  Core._findListener = function(target, type, listener)
  {
    // get the array of listener IDs added to target
    var listeners = target._listeners;
    if (!listeners) return -1;

    // get a reference to the window object containing target
    var targetDocument = target.document || target;
    var targetWindow = targetDocument.parentWindow;

    // searching backward (to speed up onunload processing), find the listener
    for (var i = listeners.length - 1; i >= 0; i--)
    {
      // get the listener's ID from target
      var listenerId = listeners[i];

      // get the record of the listener from the window object
      var listenerRecord = targetWindow._allListeners[listenerId];

      // compare type and listener with the retrieved record
      if (listenerRecord.type == type && listenerRecord.listener == listener)
      {
        return i;
      }
    }
    return -1;
  };

  Core._removeAllListeners = function()
  {
    var targetWindow = this;

    for (id in targetWindow._allListeners)
    {
      var listenerRecord = targetWindow._allListeners[id];
      listenerRecord.target.detachEvent(
          "on" + listenerRecord.type, listenerRecord.listener2);
      delete targetWindow._allListeners[id];
    }
  };

  Core._listenerCounter = 0;
}

Core.addClass = function(target, theClass)
{
  if (!Core.hasClass(target, theClass))
  {
    if (target.className == "")
    {
      target.className = theClass;
    }
    else
    {
      target.className += " " + theClass;
    }
  }
};

Core.getElementsByClass = function(theClass)
{
  var elementArray = [];

  if (typeof document.all != "undefined")
  {
    elementArray = document.all;
  }
  else
  {
    elementArray = document.getElementsByTagName("*");
  }

  var matchedArray = [];
  var pattern = new RegExp("(^| )" + theClass + "( |$)");

  for (var i = 0; i < elementArray.length; i++)
  {
    if (pattern.test(elementArray[i].className))
    {
      matchedArray[matchedArray.length] = elementArray[i];
    }
  }

  return matchedArray;
};

Core.hasClass = function(target, theClass)
{
  var pattern = new RegExp("(^| )" + theClass + "( |$)");

  if (pattern.test(target.className))
  {
    return true;
  }

  return false;
};

Core.removeClass = function(target, theClass)
{
  var pattern = new RegExp("(^| )" + theClass + "( |$)");

  target.className = target.className.replace(pattern, "$1");
  target.className = target.className.replace(/ $/, "");
};

Core.getComputedStyle = function(element, styleProperty)
{
  var computedStyle = null;

  if (typeof element.currentStyle != "undefined")
  {
    computedStyle = element.currentStyle;
  }
  else
  {
    computedStyle = document.defaultView.getComputedStyle(element, null);
  }

  return computedStyle[styleProperty];
};

Core.start = function(runnable)
{
  Core.addEventListener(window, "load", runnable.init);
};
var GreenTabs =
{
    init: function()
    {
        var queryString = window.location.href.substring((window.location.href.indexOf('=') + 1), (window.location.href.indexOf('=') + 4));
        switch (queryString)
        {
        case '28#':
            document.getElementById('articlestab').style.backgroundImage = "url(/wp-content/themes/default/images/tabs/article-selected.jpg)";
            break;
        case '49':
            document.getElementById('eventstab').style.backgroundImage = "url(/wp-content/themes/default/images/tabs/events-selected.jpg)";
            break;
        case '710':
            document.getElementById('forumtab').style.backgroundImage = "url(/wp-content/themes/default/images/tabs/forum-selected.jpg)";
            break;
        case '100':			
            document.getElementById('directab').style.backgroundImage = "url(/wp-content/themes/default/images/tabs/directories-selected.jpg)";
            break;
        default:
            document.getElementById('hometab').style.backgroundImage = "url(/wp-content/themes/default/images/tabs/home-selected.jpg)";
        }
		
		
		//
		//var qs = window.location.href.substring((window.location.href.indexOf('/') + 1),
		
    }
};

Core.start(GreenTabs);// Trick: 
// The a link contains the id of the div as its class
// So a link with class p1 will open a div having the id p1
var lastTab = "";

jQuery(document).ready(function(){
    lastTab = jQuery(".hideme").get(0); //At first select the first tab as the last selected tab

    jQuery("#fourwhite a").click(
        function(){
      		var ct = "#" + jQuery(this).attr("class").substring(0,2); //Selected tab's class
      		var cod = "#" + jQuery(lastTab).attr("id");//Last tab's contents id

                  if (ct == cod)//Click the last tab
      		{
      			jQuery(lastTab).slideDown("slow");      			
      		}
      		else //Click a different tab
      		{
				//jQuery(lastTab).find(".hideinsidegreen").css("display","none");
				//var t = lastTab;
				
				jQuery(lastTab).slideUp(
					"slow",
					function()
					{
						//jQuery(t).find(".hideinsidegreen").css("display","block");
						jQuery(ct).slideDown("slow");
					}
				);
				lastTab = jQuery(ct);
                document.getElementById('abouttab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/about-us-deselected.png')";
                document.getElementById('contactab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/contact-us-deselected.png')";
                document.getElementById('newstab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/newsletter-deselected.png')";
                document.getElementById('jointab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/register-off.png')";

                  }

                  switch (ct)
                  {
                        case '#p1':
                            document.getElementById('abouttab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/about-us-selected.png')";
                            break;
                        case '#p2':
                            document.getElementById('contactab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/contact-us-selected.png')";
                            break;
                        case '#p3':
                            document.getElementById('newstab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/newsletter-selected.png')";
                            break;
                        case '#p4':
                            document.getElementById('jointab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/register-on.png')";
                            break;
                  }
        }
    );

jQuery(".close a").click(
      function(){
      		jQuery(lastTab).slideUp("slow");

      		var ct = "#" + jQuery(this).attr("class"); //Selected tab's class

                  switch (ct) {
                        case '#p1':
                            document.getElementById('abouttab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/about-us-deselected.png')";
                            break;
                        case '#p2':
                            document.getElementById('contactab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/contact-us-deselected.png')";
                            break;
                        case '#p3':
                            document.getElementById('newstab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/newsletter-deselected.png')";
                            break;
                        case '#p4':
                            document.getElementById('jointab').style.backgroundImage = "url('/wp-content/themes/default/images/tabs/register-off.png')";
                            break;
                 }
        }
    );
});// Customizing this JavaScript code requires specifying eight values.

// Value One:
// Specify the maximum number of characters the form field
// may contain. If you have no maximum, specify 0 (zero).

var MaximumCharacters = "300";

// Value Three:
// Specify the form's name (provided by the name="_____"
// attribute in the FORM tag).

var FormName = "contactform";

// Value Four:
// Specify the name of the text field being monitored
// (provided by the name="_____" attribute in the
// INPUT or TEXTAREA tag).

var TextFieldName = "comments";

// Value Six:
// Specify the field name where where is to be displayed
// the number of characters left that may be typed.
// Make it blank (nothing between the quotation marks)
// if you aren't displaying the number of characters
// left.

var CharactersLeftFieldName = "charleft";

//////////////////////////////////////////////////////
//                                                  //
//  No modfications are required below this point.  //
//                                                  //
//////////////////////////////////////////////////////

var MaxChars = parseInt(MaximumCharacters);
var textfield = 'document.' + FormName + '.' + TextFieldName + '.value';

function CharLengthCheck(s,l) {
if(s.length > l) { s = s.substring(0,l); }
return s;
} // function CharLengthCheck()

function InputCharacterLengthCheck() {
if(MaxChars <= 0) { return; }
var currentstring = new String();
eval('currentstring = ' + textfield);
var currentlength = currentstring.length;
eval('currentstring = CharLengthCheck(' + textfield + ',' + MaxChars + ')');
if(CharactersLeftFieldName.length > 0) {
	var left = 0;
	eval('left = ' + MaxChars + ' - ' + textfield + '.length');
	if(left < 0) { left = 0; }
	eval('document.' + FormName + '.' + CharactersLeftFieldName + '.value = ' + left);
	if(currentstring.length < currentlength) { eval(textfield + ' = currentstring.substring(0)'); }
	}
} // function InputCharacterLengthCheck()


/**
* Cornerz 0.1 - Bullet Proof Corners
* Jonah Fox (jonah@parkerfox.co.uk) 2008
* 
* Usage: $('.myclass').curve(options)
* options is a hash with the following parameters. Bracketed is the default
*   radius (10)
*   borderWidth (read from BorderTopWidth or 0)
*   background ("white"). Note that this is not calculated from the HTML as it is expensive
*   borderColor (read from BorderTopColor)
*   corners ("tl br tr bl"). Specify which borders
*/

(function($){
  
  $.fn.cornerz = function(options){

    function canvasCorner(t,l, r,bw,bc,bg){
	    var sa,ea,cw,sx,sy,x,y, p = 1.57, css="position:absolute;"
	    if(t) 
		    {sa=-p; sy=r; y=0; css+="top:-"+bw+"px;";  }
	    else 
		    {sa=p; sy=0; y=r; css+="bottom:-"+bw+"px;"; }
	    if(l) 
		    {ea=p*2; sx=r; x=0;	css+="left:-"+bw+"px;"}
	    else 
		    {ea=0; sx=0; x=r; css+="right:-"+bw+"px;";	}
		
	    var canvas=$("<canvas width="+r+"px height="+ r +"px style='" + css+"' ></canvas>")
	    var ctx=canvas[0].getContext('2d')
	    ctx.beginPath();
	    ctx.lineWidth=bw*2;	
	    ctx.arc(sx,sy,r,sa,ea,!(t^l));
	    ctx.strokeStyle=bc
	    ctx.stroke()
	    ctx.lineWidth = 0
	    ctx.lineTo(x,y)
	    ctx.fillStyle=bg
	    ctx.fill()
	    return canvas
    }

    function canvasCorners(t, corners, r, bw,bc,bg) {
	    var $$ = $(t)
        $.each(corners.split(" "), function() {
	      $$.append(canvasCorner(this[0]=="t",this[1]=="l", r,bw,bc,bg).css("z-index",0))//canvasCorners returns a DOM element
	    })
    }

    function vmlCurve(r,b,c,m,ml,mt, right_fix) {
        var l = m-ml-right_fix
        var t = m-mt
        return "<v:arc filled='False' strokeweight='"+b+"px' strokecolor='"+c+"' startangle='0' endangle='361' style=' top:" + t +"px;left: "+ l + ";width:" + r+ "px; height:" + r+ "px' />"
    }
    
    var cornerzIECache = {}
    function vmlCorners(corners, r, bw, bc, bg) {
      var key = corners+ r+ "_" +bw+ bc+ bg
      cornerzIECache[key] = cornerzIECache[key] || _vmlCorners(corners, r, bw, bc, bg)
      return cornerzIECache[key]
    }
    
    function vmlCorners(t, corners, r, bw, bc, bg, w) {
        var inl = $(t).css("display")
      var h ="<div class='.vml' style='display: "+ inl +" ;text-align: right; padding-right: " + (r-bw-2) + "px;'>"
      $.each($.trim(corners).split(" "), function() {
        var css,ml=1,mt=1,right_fix=0
        if(this.charAt(0)=="t") {
          css="top:-"+bw+"px;"
        }
        else {
          css= "bottom:-"+bw+"px;"
          mt=r
        }
        if(this.charAt(1)=="l")
          css+="left:-"+bw+"px;"
        else {
          css +=" margin-right:-"+(bw-r)+"px; " // odd width gives wrong margin?
           ml=r
           right_fix = 0
        }
        //css+="background:red;"
        h+="<div style='"+css+"; position: absolute; overflow:hidden; width:"+ r +"px; height: " + r + "px;'>"
        h+="<div style='text-align:left'>"
        h+= "<v:group  style='width:10px;height:10px;position:absolute;' coordsize='10,10' >"
        h+= vmlCurve(r*3,r+bw,bg, -r/2,ml,mt,right_fix) 
        if(bw>0)
          h+= vmlCurve(r*2-bw,bw,bc, bw/2,ml,mt,right_fix)
        h+="</v:group>"
        h+="</div>"
        h+= "</div>" 
      })
    h+="</div>"
      t.innerHTML += h//need to use innerHTML rather than jQuery
    }

    var settings = {
      corners : "tl tr bl br",
      radius : 10,
      background: "white",
      borderWidth: 0
    }
        
    $.extend(settings, options || {});
    
    if($.browser.msie ) {
        // //document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
        // if(document.namespaces['v'] == null) { 
        // //      var stl = document.createStyleSheet(); 
        //  //    stl.addRule("v\\:*", "behavior: url(#default#VML);"); 
        // document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); 
        //var ss = document.createStyleSheet();
        //ss.cssText = "v\\:*{behavior:url(#default#VML);}"
        
        
		var ss = document.createElement('STYLE');
		document.documentElement.firstChild.appendChild(ss);
		
		try
		{
			ss.styleSheet.cssText = "v\\:*{behavior:url(#default#VML);}";
		}
		catch(err)
		{
			/*txt="There was an error on this page.\n\n";
			txt+="Error description: " + err.description + "\n\n";
			txt+="Click OK to continue.\n\n";
			alert(txt);*/
		}		
        // }
    }
    
    return this.each(function() {
      var $$ = $(this)
      var r = settings.radius*1.0
      var bw = (settings.borderWidth || parseInt($$.css("borderTopWidth")) || 0)*1.0
      var bg = settings.background
      var bc = settings.borderColor
      bc = bc || ( bw > 0 ? $$.css("borderTopColor") : bg)
      
      var cs = settings.corners
      if($.browser.msie) 
        vmlCorners(this, cs,r,bw,bc,bg, $(this).width() )     
      else  
        canvasCorners(this, cs,r,bw,bc,bg)
        
      if(this.style.position != "absolute")
        this.style.position = "relative"
        this.style.zoom = 1 // give it a layout in IE
      })  
  
  }
})(jQuery);
jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		guid: 1,
		global: {},
		regex: /^([0-9]+)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseInt(result[1], 10);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			if (!element.$timers) 
				element.$timers = {};
			
			if (!element.$timers[label])
				element.$timers[label] = {};
			
			fn.$timerID = fn.$timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.$timerID = fn.$timerID;
			
			if (!element.$timers[label][fn.$timerID]) 
				element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);
			
			if ( !this.global[label] )
				this.global[label] = [];
			this.global[label].push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = element.$timers, ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.$timerID ) {
							window.clearInterval(timers[label][fn.$timerID]);
							delete timers[label][fn.$timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					element.$timers = null;
			}
		}
	}
});

if (jQuery.browser.msie)
	jQuery(window).one("unload", function() {
		var global = jQuery.timer.global;
		for ( var label in global ) {
			var els = global[label], i = els.length;
			while ( --i )
				jQuery.timer.remove(els[i], label);
		}
	});


jQuery.extend({


    createUploadIframe: function(id, uri) {
        //create frame
        var frameId = 'jUploadFrame' + id;

        if (window.ActiveXObject) {
            var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
            if (typeof uri == 'boolean') {
                io.src = 'javascript:false';
            }
            else if (typeof uri == 'string') {
                io.src = uri;
            }
        }
        else {
            var io = document.createElement('iframe');
            io.id = frameId;
            io.name = frameId;
        }
        io.style.position = 'absolute';
        io.style.top = '-1000px';
        io.style.left = '-1000px';

        document.body.appendChild(io);

        return io
    },
    createUploadForm: function(id, fileElementId) {
        //create form	
        var formId = 'jUploadForm' + id;
        var fileId = 'jUploadFile' + id;
        var form = jQuery('<form  action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
        var oldElement = jQuery('#' + fileElementId);
        var newElement = jQuery(oldElement).clone();
        jQuery(oldElement).attr('id', fileId);
        jQuery(oldElement).before(newElement);
        jQuery(oldElement).appendTo(form);
        //set attributes
        jQuery(form).css('position', 'absolute');
        jQuery(form).css('top', '-1200px');
        jQuery(form).css('left', '-1200px');
        jQuery(form).appendTo('body');
        return form;
    },

    ajaxFileUpload: function(s) {
        // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout		
        s = jQuery.extend({}, jQuery.ajaxSettings, s);
        var id = new Date().getTime()
        var form = jQuery.createUploadForm(id, s.fileElementId);
        var io = jQuery.createUploadIframe(id, s.secureuri);
        var frameId = 'jUploadFrame' + id;
        var formId = 'jUploadForm' + id;
        // Watch for a new set of requests
        if (s.global && !jQuery.active++) {
            jQuery.event.trigger("ajaxStart");
        }
        var requestDone = false;
        // Create the request object
        var xml = {}
        if (s.global)
            jQuery.event.trigger("ajaxSend", [xml, s]);
        // Wait for a response to come back
        var uploadCallback = function(isTimeout) {
            var io = document.getElementById(frameId);
            try {
                if (io.contentWindow) {
                    xml.responseText = io.contentWindow.document.body ? io.contentWindow.document.body.innerHTML : null;
                    xml.responseXML = io.contentWindow.document.XMLDocument ? io.contentWindow.document.XMLDocument : io.contentWindow.document;

                } else if (io.contentDocument) {
                    xml.responseText = io.contentDocument.document.body ? io.contentDocument.document.body.innerHTML : null;
                    xml.responseXML = io.contentDocument.document.XMLDocument ? io.contentDocument.document.XMLDocument : io.contentDocument.document;
                }
            } catch (e) {
                jQuery.handleError(s, xml, null, e);
            }
            if (xml || isTimeout == "timeout") {
                requestDone = true;
                var status;
                try {
                    status = isTimeout != "timeout" ? "success" : "error";
                    // Make sure that the request was successful or notmodified
                    if (status != "error") {
                        // process the data (runs the xml through httpData regardless of callback)
                        var data = jQuery.uploadHttpData(xml, s.dataType);
                        // If a local callback was specified, fire it and pass it the data
                        if (s.success)
                            s.success(data, status);

                        // Fire the global callback
                        if (s.global)
                            jQuery.event.trigger("ajaxSuccess", [xml, s]);
                    } else
                        jQuery.handleError(s, xml, status);
                } catch (e) {
                    status = "error";
                    jQuery.handleError(s, xml, status, e);
                }

                // The request was completed
                if (s.global)
                    jQuery.event.trigger("ajaxComplete", [xml, s]);

                // Handle the global AJAX counter
                if (s.global && ! --jQuery.active)
                    jQuery.event.trigger("ajaxStop");

                // Process result
                if (s.complete)
                    s.complete(xml, status);

                jQuery(io).unbind()

                setTimeout(function() {
                    try {
                        jQuery(io).remove();
                        jQuery(form).remove();

                    } catch (e) {
                        jQuery.handleError(s, xml, null, e);
                    }

                }, 100)

                xml = null

            }
        }
        // Timeout checker
        if (s.timeout > 0) {
            setTimeout(function() {
                // Check to see if the request is still happening
                if (!requestDone) uploadCallback("timeout");
            }, s.timeout);
        }
        try {
            // var io = jQuery('#' + frameId);
            var form = jQuery('#' + formId);
            jQuery(form).attr('action', s.url);
            jQuery(form).attr('method', 'POST');
            jQuery(form).attr('target', frameId);
            if (form.encoding) {
                form.encoding = 'multipart/form-data';
            }
            else {
                form.enctype = 'multipart/form-data';
            }
            jQuery(form).submit();

        } catch (e) {
            jQuery.handleError(s, xml, null, e);
        }
        if (window.attachEvent) {
            document.getElementById(frameId).attachEvent('onload', uploadCallback);
        }
        else {
            document.getElementById(frameId).addEventListener('load', uploadCallback, false);
        }
        return { abort: function() { } };

    },

    uploadHttpData: function(r, type) {
        var data = !type;
        data = type == "xml" || data ? r.responseXML : r.responseText;
        // If the type is "script", eval it in global context
        if (type == "script")
            jQuery.globalEval(data);
        // Get the JavaScript object, if JSON is used.
        if (type == "json")
            eval("data = " + data);
        // evaluate scripts within html
        if (type == "html")
            jQuery("<div>").html(data).evalScripts();
        //alert(jQuery('param', data).each(function(){alert(jQuery(this).attr('value'));}));
        return data;
    }
})

jQuery.fn.highlightFade = function(settings) {
	var o = (settings && settings.constructor == String) ? {start: settings} : settings || {};
	var d = jQuery.highlightFade.defaults;
	var i = o['interval'] || d['interval'];
	var a = o['attr'] || d['attr'];
	var ts = {
		'linear': function(s,e,t,c) { return parseInt(s+(c/t)*(e-s)); },
		'sinusoidal': function(s,e,t,c) { return parseInt(s+Math.sin(((c/t)*90)*(Math.PI/180))*(e-s)); },
		'exponential': function(s,e,t,c) { return parseInt(s+(Math.pow(c/t,2))*(e-s)); }
	};
	var t = (o['iterator'] && o['iterator'].constructor == Function) ? o['iterator'] : ts[o['iterator']] || ts[d['iterator']] || ts['linear'];
	if (d['iterator'] && d['iterator'].constructor == Function) t = d['iterator'];
	return this.each(function() {
		if (!this.highlighting) this.highlighting = {};
		var e = (this.highlighting[a]) ? this.highlighting[a].end : jQuery.highlightFade.getBaseValue(this,a) || [255,255,255];
		var c = jQuery.highlightFade.getRGB(o['start'] || o['colour'] || o['color'] || d['start'] || [255,255,128]);
		var s = jQuery.speed(o['speed'] || d['speed']);
		var r = o['final'] || (this.highlighting[a] && this.highlighting[a].orig) ? this.highlighting[a].orig : jQuery.curCSS(this,a);
		if (o['end'] || d['end']) r = jQuery.highlightFade.asRGBString(e = jQuery.highlightFade.getRGB(o['end'] || d['end']));
		if (typeof o['final'] != 'undefined') r = o['final'];
		if (this.highlighting[a] && this.highlighting[a].timer) window.clearInterval(this.highlighting[a].timer);
		this.highlighting[a] = { steps: ((s.duration) / i), interval: i, currentStep: 0, start: c, end: e, orig: r, attr: a };
		jQuery.highlightFade(this,a,o['complete'],t);
	});
};

jQuery.highlightFade = function(e,a,o,t) {
	e.highlighting[a].timer = window.setInterval(function() { 
		var newR = t(e.highlighting[a].start[0],e.highlighting[a].end[0],e.highlighting[a].steps,e.highlighting[a].currentStep);
		var newG = t(e.highlighting[a].start[1],e.highlighting[a].end[1],e.highlighting[a].steps,e.highlighting[a].currentStep);
		var newB = t(e.highlighting[a].start[2],e.highlighting[a].end[2],e.highlighting[a].steps,e.highlighting[a].currentStep);
		jQuery(e).css(a,jQuery.highlightFade.asRGBString([newR,newG,newB]));
		if (e.highlighting[a].currentStep++ >= e.highlighting[a].steps) {
			jQuery(e).css(a,e.highlighting[a].orig || '');
			window.clearInterval(e.highlighting[a].timer);
			e.highlighting[a] = null;
			if (o && o.constructor == Function) o.call(e);
		}
	},e.highlighting[a].interval);
};

jQuery.highlightFade.defaults = {
	start: [255,255,128],
	interval: 50,
	speed: 400,
	attr: 'backgroundColor'
};

jQuery.highlightFade.getRGB = function(c,d) {
	var result;
	if (c && c.constructor == Array && c.length == 3) return c;
	if (result == /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))
		return [parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];
	else if (result == /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))
		return [parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];
	else if (result == /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))
		return [parseInt("0x" + result[1]),parseInt("0x" + result[2]),parseInt("0x" + result[3])];
	else if (result == /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))
		return [parseInt("0x"+ result[1] + result[1]),parseInt("0x" + result[2] + result[2]),parseInt("0x" + result[3] + result[3])];
	else
		return jQuery.highlightFade.checkColorName(c) || d || null;
};

jQuery.highlightFade.asRGBString = function(a) {
	return "rgb(" + a.join(",") + ")";
};

jQuery.highlightFade.getBaseValue = function(e,a,b) {
	var s, t;
	b = b || false;
	t = a = a || jQuery.highlightFade.defaults['attr'];
	do {
		s = jQuery(e).css(t || 'backgroundColor');
		if ((s  != '' && s != 'transparent') || (e.tagName.toLowerCase() == "body") || (!b && e.highlighting && e.highlighting[a] && e.highlighting[a].end)) break; 
		t = false;
	} while (e == e.parentNode);
	if (!b && e.highlighting && e.highlighting[a] && e.highlighting[a].end) s = e.highlighting[a].end;
	if (s == undefined || s == '' || s == 'transparent') s = [255,255,255];
	return jQuery.highlightFade.getRGB(s);
};

jQuery.highlightFade.checkColorName = function(c) {
	if (!c) return null;
	switch(c.replace(/^\s*|\s*$/g,'').toLowerCase()) {
		case 'aqua': return [0,255,255];
		case 'black': return [0,0,0];
		case 'blue': return [0,0,255];
		case 'fuchsia': return [255,0,255];
		case 'gray': return [128,128,128];
		case 'green': return [0,128,0];
		case 'lime': return [0,255,0];
		case 'maroon': return [128,0,0];
		case 'navy': return [0,0,128];
		case 'olive': return [128,128,0];
		case 'purple': return [128,0,128];
		case 'red': return [255,0,0];
		case 'silver': return [192,192,192];
		case 'teal': return [0,128,128];
		case 'white': return [255,255,255];
		case 'yellow': return [255,255,0];
	}
};
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Date: 2/19/2008
 * @author Ariel Flesler
 * @version 1.3.3
 */
;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:1};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-06-20 03:23:36 +0200 (Mi, 20 Jun 2007) $
 * $Rev: 2110 $
 *
 * Version 2.1
 */

(function($){

/**
 * The bgiframe is chainable and applies the iframe hack to get 
 * around zIndex issues in IE6. It will only apply itself in IE 
 * and adds a class to the iframe called 'bgiframe'. The iframe
 * is appeneded as the first child of the matched element(s) 
 * with a tabIndex and zIndex of -1.
 * 
 * By default the plugin will take borders, sized with pixel units,
 * into account. If a different unit is used for the border's width,
 * then you will need to use the top and left settings as explained below.
 *
 * NOTICE: This plugin has been reported to cause perfromance problems
 * when used on elements that change properties (like width, height and
 * opacity) a lot in IE6. Most of these problems have been caused by 
 * the expressions used to calculate the elements width, height and 
 * borders. Some have reported it is due to the opacity filter. All 
 * these settings can be changed if needed as explained below.
 *
 * @example $('div').bgiframe();
 * @before <div><p>Paragraph</p></div>
 * @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
 *
 * @param Map settings Optional settings to configure the iframe.
 * @option String|Number top The iframe must be offset to the top
 * 		by the width of the top border. This should be a negative 
 *      number representing the border-top-width. If a number is 
 * 		is used here, pixels will be assumed. Otherwise, be sure
 *		to specify a unit. An expression could also be used. 
 * 		By default the value is "auto" which will use an expression 
 * 		to get the border-top-width if it is in pixels.
 * @option String|Number left The iframe must be offset to the left
 * 		by the width of the left border. This should be a negative 
 *      number representing the border-left-width. If a number is 
 * 		is used here, pixels will be assumed. Otherwise, be sure
 *		to specify a unit. An expression could also be used. 
 * 		By default the value is "auto" which will use an expression 
 * 		to get the border-left-width if it is in pixels.
 * @option String|Number width This is the width of the iframe. If
 *		a number is used here, pixels will be assume. Otherwise, be sure
 * 		to specify a unit. An experssion could also be used.
 *		By default the value is "auto" which will use an experssion
 * 		to get the offsetWidth.
 * @option String|Number height This is the height of the iframe. If
 *		a number is used here, pixels will be assume. Otherwise, be sure
 * 		to specify a unit. An experssion could also be used.
 *		By default the value is "auto" which will use an experssion
 * 		to get the offsetHeight.
 * @option Boolean opacity This is a boolean representing whether or not
 * 		to use opacity. If set to true, the opacity of 0 is applied. If
 *		set to false, the opacity filter is not applied. Default: true.
 * @option String src This setting is provided so that one could change 
 *		the src of the iframe to whatever they need.
 *		Default: "javascript:false;"
 *
 * @name bgiframe
 * @type jQuery
 * @cat Plugins/bgiframe
 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 */
$.fn.bgIframe = $.fn.bgiframe = function(s) {
	// This is only for IE6
	if ( $.browser.msie && parseInt($.browser.version) <= 6 ) {
		s = $.extend({
			top     : 'auto', // auto == .currentStyle.borderTopWidth
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
			width   : 'auto', // auto == offsetWidth
			height  : 'auto', // auto == offsetHeight
			opacity : true,
			src     : 'javascript:false;'
		}, s || {});
		var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
		               'style="display:block;position:absolute;z-index:-1;'+
			               (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
					       'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
					       'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
					       'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
					       'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
					'"/>';
		return this.each(function() {
			if ( $('> iframe.bgiframe', this).length == 0 )
				this.insertBefore( document.createElement(html), this.firstChild );
		});
	}
	return this;
};

// Add browser.version if it doesn't exist
if (!$.browser.version)
	$.browser.version = navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1];

})(jQuery);/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-06-22 04:38:37 +0200 (Fr, 22 Jun 2007) $
 * $Rev: 2141 $
 *
 * Version: 1.0b2
 */

(function($){

// store a copy of the core height and width methods
var height = $.fn.height,
    width  = $.fn.width;

$.fn.extend({
	/**
	 * If used on document, returns the document's height (innerHeight)
	 * If used on window, returns the viewport's (window) height
	 * See core docs on height() to see what happens when used on an element.
	 *
	 * @example $("#testdiv").height()
	 * @result 200
	 *
	 * @example $(document).height()
	 * @result 800
	 *
	 * @example $(window).height()
	 * @result 400
	 *
	 * @name height
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	height: function() {
		if ( this[0] == window )
			return self.innerHeight ||
				$.boxModel && document.documentElement.clientHeight || 
				document.body.clientHeight;
		
		if ( this[0] == document )
			return Math.max( document.body.scrollHeight, document.body.offsetHeight );
		
		return height.apply(this, arguments);
	},
	
	/**
	 * If used on document, returns the document's width (innerWidth)
	 * If used on window, returns the viewport's (window) width
	 * See core docs on height() to see what happens when used on an element.
	 *
	 * @example $("#testdiv").width()
	 * @result 200
	 *
	 * @example $(document).width()
	 * @result 800
	 *
	 * @example $(window).width()
	 * @result 400
	 *
	 * @name width
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	width: function() {
		if ( this[0] == window )
			return self.innerWidth ||
				$.boxModel && document.documentElement.clientWidth ||
				document.body.clientWidth;

		if ( this[0] == document )
			return Math.max( document.body.scrollWidth, document.body.offsetWidth );

		return width.apply(this, arguments);
	},
	
	/**
	 * Returns the inner height value (without border) for the first matched element.
	 * If used on document, returns the document's height (innerHeight)
	 * If used on window, returns the viewport's (window) height
	 *
	 * @example $("#testdiv").innerHeight()
	 * @result 800
	 *
	 * @name innerHeight
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	innerHeight: function() {
		return this[0] == window || this[0] == document ?
			this.height() :
			this.is(':visible') ?
				this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') :
				this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom');
	},
	
	/**
	 * Returns the inner width value (without border) for the first matched element.
	 * If used on document, returns the document's Width (innerWidth)
	 * If used on window, returns the viewport's (window) width
	 *
	 * @example $("#testdiv").innerWidth()
	 * @result 1000
	 *
	 * @name innerWidth
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	innerWidth: function() {
		return this[0] == window || this[0] == document ?
			this.width() :
			this.is(':visible') ?
				this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') :
				this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight');
	},
	
	/**
	 * Returns the outer height value (including border) for the first matched element.
	 * Cannot be used on document or window.
	 *
	 * @example $("#testdiv").outerHeight()
	 * @result 1000
	 *
	 * @name outerHeight
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	outerHeight: function() {
		return this[0] == window || this[0] == document ?
			this.height() :
			this.is(':visible') ?
				this[0].offsetHeight :
				this.height() + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') + num(this, 'paddingTop') + num(this, 'paddingBottom');
	},
	
	/**
	 * Returns the outer width value (including border) for the first matched element.
	 * Cannot be used on document or window.
	 *
	 * @example $("#testdiv").outerHeight()
	 * @result 1000
	 *
	 * @name outerHeight
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	outerWidth: function() {
		return this[0] == window || this[0] == document ?
			this.width() :
			this.is(':visible') ?
				this[0].offsetWidth :
				this.width() + num(this, 'borderLeftWidth') + num(this, 'borderRightWidth') + num(this, 'paddingLeft') + num(this, 'paddingRight');
	},
	
	/**
	 * Returns how many pixels the user has scrolled to the right (scrollLeft).
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollLeft()
	 * @result 100
	 *
	 * @name scrollLeft
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	/**
	 * Sets the scrollLeft property and continues the chain.
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollLeft(10).scrollLeft()
	 * @result 10
	 *
	 * @name scrollLeft
	 * @param Number value A positive number representing the desired scrollLeft.
	 * @type jQuery
	 * @cat Plugins/Dimensions
	 */
	scrollLeft: function(val) {
		if ( val != undefined )
			// set the scroll left
			return this.each(function() {
				if (this == window || this == document)
					window.scrollTo( val, $(window).scrollTop() );
				else
					this.scrollLeft = val;
			});
		
		// return the scroll left offest in pixels
		if ( this[0] == window || this[0] == document )
			return self.pageXOffset ||
				$.boxModel && document.documentElement.scrollLeft ||
				document.body.scrollLeft;
				
		return this[0].scrollLeft;
	},
	
	/**
	 * Returns how many pixels the user has scrolled to the bottom (scrollTop).
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollTop()
	 * @result 100
	 *
	 * @name scrollTop
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	/**
	 * Sets the scrollTop property and continues the chain.
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollTop(10).scrollTop()
	 * @result 10
	 *
	 * @name scrollTop
	 * @param Number value A positive number representing the desired scrollTop.
	 * @type jQuery
	 * @cat Plugins/Dimensions
	 */
	scrollTop: function(val) {
		if ( val != undefined )
			// set the scroll top
			return this.each(function() {
				if (this == window || this == document)
					window.scrollTo( $(window).scrollLeft(), val );
				else
					this.scrollTop = val;
			});
		
		// return the scroll top offset in pixels
		if ( this[0] == window || this[0] == document )
			return self.pageYOffset ||
				$.boxModel && document.documentElement.scrollTop ||
				document.body.scrollTop;

		return this[0].scrollTop;
	},
	
	/** 
	 * Returns the top and left positioned offset in pixels.
	 * The positioned offset is the offset between a positioned
	 * parent and the element itself.
	 *
	 * @example $("#testdiv").position()
	 * @result { top: 100, left: 100 }
	 * 
	 * @name position
	 * @param Map options Optional settings to configure the way the offset is calculated.
	 * @option Boolean margin Should the margin of the element be included in the calculations? False by default.
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
	 *                            chain will not be broken and the result will be assigned to this object.
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	position: function(options, returnObject) {
		var elem = this[0], parent = elem.parentNode, op = elem.offsetParent,
		    options = $.extend({ margin: false, border: false, padding: false, scroll: false }, options || {}),
			x = elem.offsetLeft,
			y = elem.offsetTop, 
			sl = elem.scrollLeft, 
			st = elem.scrollTop;
			
		// Mozilla and IE do not add the border
		if ($.browser.mozilla || $.browser.msie) {
			// add borders to offset
			x += num(elem, 'borderLeftWidth');
			y += num(elem, 'borderTopWidth');
		}

		if ($.browser.mozilla) {
			do {
				// Mozilla does not add the border for a parent that has overflow set to anything but visible
				if ($.browser.mozilla && parent != elem && $.css(parent, 'overflow') != 'visible') {
					x += num(parent, 'borderLeftWidth');
					y += num(parent, 'borderTopWidth');
				}

				if (parent == op) break; // break if we are already at the offestParent
			} while ((parent = parent.parentNode) && (parent.tagName.toLowerCase() != 'body' || parent.tagName.toLowerCase() != 'html'));
		}
		
		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
		
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
		else              { return returnValue; }
	},
	
	/**
	 * Returns the location of the element in pixels from the top left corner of the viewport.
	 *
	 * For accurate readings make sure to use pixel values for margins, borders and padding.
	 * 
	 * Known issues:
	 *  - Issue: A div positioned relative or static without any content before it and its parent will report an offsetTop of 0 in Safari
	 *    Workaround: Place content before the relative div ... and set height and width to 0 and overflow to hidden
	 *
	 * @example $("#testdiv").offset()
	 * @result { top: 100, left: 100, scrollTop: 10, scrollLeft: 10 }
	 *
	 * @example $("#testdiv").offset({ scroll: false })
	 * @result { top: 90, left: 90 }
	 *
	 * @example var offset = {}
	 * $("#testdiv").offset({ scroll: false }, offset)
	 * @result offset = { top: 90, left: 90 }
	 *
	 * @name offset
	 * @param Map options Optional settings to configure the way the offset is calculated.
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
	 *                        to the returned object, scrollTop and scrollLeft. 
	 * @options Boolean lite Will use offsetLite instead of offset when set to true. False by default.
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
	 *                            chain will not be broken and the result will be assigned to this object.
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	offset: function(options, returnObject) {
		var x = 0, y = 0, sl = 0, st = 0,
		    elem = this[0], parent = this[0], op, parPos, elemPos = $.css(elem, 'position'),
		    mo = $.browser.mozilla, ie = $.browser.msie, sf = $.browser.safari, oa = $.browser.opera,
		    absparent = false, relparent = false, 
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true, lite: false }, options || {});
		
		// Use offsetLite if lite option is true
		if (options.lite) return this.offsetLite(options, returnObject);
		
		if (elem.tagName.toLowerCase() == 'body') {
			// Safari is the only one to get offsetLeft and offsetTop properties of the body "correct"
			// Except they all mess up when the body is positioned absolute or relative
			x = elem.offsetLeft;
			y = elem.offsetTop;
			// Mozilla ignores margin and subtracts border from body element
			if (mo) {
				x += num(elem, 'marginLeft') + (num(elem, 'borderLeftWidth')*2);
				y += num(elem, 'marginTop')  + (num(elem, 'borderTopWidth') *2);
			} else
			// Opera ignores margin
			if (oa) {
				x += num(elem, 'marginLeft');
				y += num(elem, 'marginTop');
			} else
			// IE does not add the border in Standards Mode
			if (ie && jQuery.boxModel) {
				x += num(elem, 'borderLeftWidth');
				y += num(elem, 'borderTopWidth');
			}
		} else {
			do {
				parPos = $.css(parent, 'position');
			
				x += parent.offsetLeft;
				y += parent.offsetTop;

				// Mozilla and IE do not add the border
				if (mo || ie) {
					// add borders to offset
					x += num(parent, 'borderLeftWidth');
					y += num(parent, 'borderTopWidth');

					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
					if (mo && parPos == 'absolute') absparent = true;
					// IE does not include the border on the body if an element is position static and without an absolute or relative parent
					if (ie && parPos == 'relative') relparent = true;
				}

				op = parent.offsetParent;
				if (options.scroll || mo) {
					do {
						if (options.scroll) {
							// get scroll offsets
							sl += parent.scrollLeft;
							st += parent.scrollTop;
						}
				
						// Mozilla does not add the border for a parent that has overflow set to anything but visible
						if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
							x += num(parent, 'borderLeftWidth');
							y += num(parent, 'borderTopWidth');
						}
				
						parent = parent.parentNode;
					} while (parent != op);
				}
				parent = op;

				if (parent.tagName.toLowerCase() == 'body' || parent.tagName.toLowerCase() == 'html') {
					// Safari and IE Standards Mode doesn't add the body margin for elments positioned with static or relative
					if ((sf || (ie && $.boxModel)) && elemPos != 'absolute' && elemPos != 'fixed') {
						x += num(parent, 'marginLeft');
						y += num(parent, 'marginTop');
					}
					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
					// IE does not include the border on the body if an element is positioned static and without an absolute or relative parent
					if ( (mo && !absparent && elemPos != 'fixed') || 
					     (ie && elemPos == 'static' && !relparent) ) {
						x += num(parent, 'borderLeftWidth');
						y += num(parent, 'borderTopWidth');
					}
					break; // Exit the loop
				}
			} while (parent);
		}

		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);

		if (returnObject) { $.extend(returnObject, returnValue); return this; }
		else              { return returnValue; }
	},
	
	/**
	 * Returns the location of the element in pixels from the top left corner of the viewport.
	 * This method is much faster than offset but not as accurate. This method can be invoked
	 * by setting the lite option to true in the offset method.
	 *
	 * @name offsetLite
	 * @param Map options Optional settings to configure the way the offset is calculated.
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
	 *                        to the returned object, scrollTop and scrollLeft. 
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
	 *                            chain will not be broken and the result will be assigned to this object.
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	offsetLite: function(options, returnObject) {
		var x = 0, y = 0, sl = 0, st = 0, parent = this[0], op, 
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true }, options || {});
				
		do {
			x += parent.offsetLeft;
			y += parent.offsetTop;

			op = parent.offsetParent;
			if (options.scroll) {
				// get scroll offsets
				do {
					sl += parent.scrollLeft;
					st += parent.scrollTop;
					parent = parent.parentNode;
				} while(parent != op);
			}
			parent = op;
		} while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html');

		var returnValue = handleOffsetReturn(this[0], options, x, y, sl, st);

		if (returnObject) { $.extend(returnObject, returnValue); return this; }
		else              { return returnValue; }
	}
});

/**
 * Handles converting a CSS Style into an Integer.
 * @private
 */
var num = function(el, prop) {
	return parseInt($.css(el.jquery?el[0]:el,prop))||0;
};

/**
 * Handles the return value of the offset and offsetLite methods.
 * @private
 */
var handleOffsetReturn = function(elem, options, x, y, sl, st) {
	if ( !options.margin ) {
		x -= num(elem, 'marginLeft');
		y -= num(elem, 'marginTop');
	}

	// Safari and Opera do not add the border for the element
	if ( options.border && ($.browser.safari || $.browser.opera) ) {
		x += num(elem, 'borderLeftWidth');
		y += num(elem, 'borderTopWidth');
	} else if ( !options.border && !($.browser.safari || $.browser.opera) ) {
		x -= num(elem, 'borderLeftWidth');
		y -= num(elem, 'borderTopWidth');
	}

	if ( options.padding ) {
		x += num(elem, 'paddingLeft');
		y += num(elem, 'paddingTop');
	}
	
	// do not include scroll offset on the element
	if ( options.scroll ) {
		sl -= elem.scrollLeft;
		st -= elem.scrollTop;
	}

	return options.scroll ? { top: y - st, left: x - sl, scrollTop:  st, scrollLeft: sl }
	                      : { top: y, left: x };
};

})(jQuery);/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 JÃ¶rn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide().css("opacity","");}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();if(settings(this).fixPNG)helper.parent.unfixPNG();}})(jQuery);/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
		  
var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif";
var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png";

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

//on page load call tb_init
jQuery(document).ready(function(){   
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
});

//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
	jQuery(domChunk).click(function(){
	var t = this.title || this.name || null;
	var a = this.href || this.alt;
	var g = this.rel || false;
	tb_show(t,a,g);
	this.blur();	
	return false;
	});
}

function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link

	try {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			jQuery("body","html").css({height: "100%", width: "100%"});
			jQuery("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}
		
		if(tb_detectMacXFF()){
			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		
		if(caption===null){caption="";}
		jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
		jQuery('#TB_load').show();//show loader
		
		var baseURL;
	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
	   }else{ 
	   		baseURL = url;
	   }
	   
	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   var urlType = baseURL.toLowerCase().match(urlString);

		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
				
			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if(imageGroup){
				TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
						if (!(TB_TempArray[TB_Counter].href == url)) {						
							if (TB_FoundURL) {
								TB_NextCaption = TB_TempArray[TB_Counter].title;
								TB_NextURL = TB_TempArray[TB_Counter].href;
								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
							} else {
								TB_PrevCaption = TB_TempArray[TB_Counter].title;
								TB_PrevURL = TB_TempArray[TB_Counter].href;
								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
							}
						} else {
							TB_FoundURL = true;
							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);											
						}
				}
			}

			imgPreloader = new Image();
			imgPreloader.onload = function(){		
			imgPreloader.onload = null;
				
			// Resizing large images - orginal by Christian Montoya edited by me.
			var pagesize = tb_getPageSize();
			var x = pagesize[0] - 150;
			var y = pagesize[1] - 150;
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (imageWidth > x) {
				imageHeight = imageHeight * (x / imageWidth); 
				imageWidth = x; 
				if (imageHeight > y) { 
					imageWidth = imageWidth * (y / imageHeight); 
					imageHeight = y; 
				}
			} else if (imageHeight > y) { 
				imageWidth = imageWidth * (y / imageHeight); 
				imageHeight = y; 
				if (imageWidth > x) { 
					imageHeight = imageHeight * (x / imageWidth); 
					imageWidth = x;
				}
			}
			// End Resizing
			
			TB_WIDTH = imageWidth + 30;
			TB_HEIGHT = imageHeight + 60;
			jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div>"); 		
			
			jQuery("#TB_closeWindowButton").click(tb_remove);
			
			if (!(TB_PrevHTML === "")) {
				function goPrev(){
					if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
					jQuery("#TB_window").remove();
					jQuery("body").append("<div id='TB_window'></div>");
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
					return false;	
				}
				jQuery("#TB_prev").click(goPrev);
			}
			
			if (!(TB_NextHTML === "")) {		
				function goNext(){
					jQuery("#TB_window").remove();
					jQuery("body").append("<div id='TB_window'></div>");
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
					return false;	
				}
				jQuery("#TB_next").click(goNext);
				
			}

			document.onkeydown = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				} else if(keycode == 190){ // display previous image
					if(!(TB_NextHTML == "")){
						document.onkeydown = "";
						goNext();
					}
				} else if(keycode == 188){ // display next image
					if(!(TB_PrevHTML == "")){
						document.onkeydown = "";
						goPrev();
					}
				}	
			};
			
			tb_position();
			jQuery("#TB_load").remove();
			jQuery("#TB_ImageOff").click(tb_remove);
			jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show
			};
			
			imgPreloader.src = url;
		}else{//code to show html
			
			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );

			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL	
			
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;
			
			//alert(params['height']);
			
			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
					urlNoQuery = url.split('TB_');
					jQuery("#TB_iframeContent").remove();
					if(params['modal'] != "true"){//iframe no modal
						jQuery("#TB_window").append("<div id='TB_ltitle'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_whitespace'></div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
						jQuery("#TB_window").append("<div id='TB_footer'><div id='TB_whitespace'></div><div id='TB_footer_right_corner'></div></div>");	
						
					}else{//iframe modal
						jQuery("#TB_overlay").unbind();
						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
					}
			}else{// not an iframe, ajax
					if(jQuery("#TB_window").css("display") != "block"){					
						if(params['modal'] != "true"){//ajax no modal
							jQuery("#TB_window").append("<div id='TB_ltitle'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_whitespace'></div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'><img src='" + tb_closeImage + "' /></a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
							jQuery("#TB_window").append("<div id='TB_footer'><div id='TB_whitespace'></div><div id='TB_footer_right_corner'></div></div>");
						}else{//ajax modal
							jQuery("#TB_overlay").unbind();
							jQuery("#TB_window").append("<div id='TB_ltitle'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_whitespace'></div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'><img src='" + tb_closeImage + "' /></a></div></div>");
							jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
							jQuery("#TB_window").append("<div id='TB_footer'><div id='TB_whitespace'></div><div id='TB_footer_right_corner'></div></div>");	
						}
					}else{//this means the window is already up, we are just loading new content via ajax
						jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
						jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
						jQuery("#TB_ajaxContent")[0].scrollTop = 0;
						jQuery("#TB_ajaxWindowTitle").html(caption);
					}
			}

			if(!params['info'])
			{
				jQuery("#TB_ajaxContent").css("overflow","hidden");
				jQuery("#TB_ajaxContent").css("padding-right","15px");
				jQuery("#TB_ajaxContent").css("padding-bottom","25px");
			}

			if (jQuery.browser.msie)
			{
				jQuery("#TB_ltitle").css("background","white");
				jQuery("#TB_footer").css("background","white");
				jQuery("#TB_footer_right_corner").css("background","white");
				jQuery("#TB_window").find("#TB_closeAjaxWindow").css("background","");
			}
					
			jQuery("#TB_closeWindowButton").click(tb_remove);
			
				if(url.indexOf('TB_inline') != -1){	
					jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
					jQuery("#TB_window").unload(function () {
						jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
					});
					tb_position();
					jQuery("#TB_load").remove();
					jQuery("#TB_window").css({display:"block"}); 
				}else if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($.browser.safari){//safari needs help because it will not fire iframe onload
						jQuery("#TB_load").remove();
						jQuery("#TB_window").css({display:"block"});
					}
				}else{
					jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
						tb_position();
						jQuery("#TB_load").remove();
						tb_init("#TB_ajaxContent a.thickbox");
						jQuery("#TB_window").css({display:"block"});
					});
				}
			
		}

		if(!params['modal']){
			document.onkeyup = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				}	
			};
		}
		
	} catch(e) {
		//nothing here
	}
}

//helper functions below
function tb_showIframe(){
	jQuery("#TB_load").remove();
	jQuery("#TB_window").css({display:"block"});
}

function tb_remove() {
 	jQuery("#TB_imageOff").unbind("click");
	jQuery("#TB_closeWindowButton").unbind("click");
	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	jQuery("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		jQuery("body","html").css({height: "auto", width: "auto"});
		jQuery("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position() {
jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}

function tb_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}


