// create pop-up window by giving your anchor tag class="popup" - no other action needed
function createPopupOpener(width,height) {
  return function() {
    window.open(this.href, "", "top=40,left=40,width="+width+",height="+height+",resizable=yes,scrollbars=yes,toolbar=yes");
    return false;
  } 
}


function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  linkRE = new RegExp(/popup(?:(\d+)x(\d+))?/);
  for (var i=0; i < links.length; i++) {   
    if (match = linkRE.exec(links[i].className)) {
      var width  = match[1] ? isNaN(match[1]) ? 650 : match[1] : 650
      var height = match[2] ? isNaN(match[2]) ? 625 : match[2] : 625
      var f = createPopupOpener(width,height)
      links[i].click=f
    } 
  } 
} 

// You open the popup by assigning class="popup" to the anchor tag 
// like this:  <a href="http://www.gullbuy.com" class="popup">Search 
// By Name</a></li>
//
// To specify a different size, specify widthxheight after the word popup, e.g.
// class="popup300x200" will open up a popup window with a width of 300 pixels
// and a height of 200 pixels.


$(document).ready (function() {
			// call the popups script on line 2											
			doPopups();	
			
      $(function(){
				$('a.new-window').live("click", function(){
					window.open(this.href);
					return false;
				});
      });			
			
});


//http://pure-essence.net/stuff/webTips/dodosTextCounter/index.html
//Dodo's Text Counter
jQuery.fn.dodosTextCounter=function(a,b){b=$.extend({counterDisplayElement:"span",counterDisplayClass:"dodosTextCounterDisplay",addLineBreak:true},b);$(this).each(function(i){updateCounter(this,a,b,i);$(this).keyup(function(){updateCounter(this,a,b,i);return this})});return this};function updateCounter(a,b,c,d){var e=0;var f=$(a).val();if(f){e=f.length}if(e>b){$(a).val(f.substring(0,b))}else{var g=b-e;var h=c.counterDisplayElement+"."+c.counterDisplayClass+":eq("+d+")";var i=$(h).length==0;if(i){var j=document.createElement(c.counterDisplayElement);if(c.counterDisplayElement=='input'){$(j).val(g.toString())}else{$(j).html(g.toString())}$(j).addClass(c.counterDisplayClass).insertAfter($(a));if(c.addLineBreak){$(a).after("<br />")}}else{if(c.counterDisplayElement=='input'){$(h).val(g.toString())}else{$(h).html(g.toString())}}}}

function createCookie(name,value,days) {
	var expires = "";
    if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
