function strpos( haystack, needle, offset){
var i = (haystack+'').indexOf( needle, offset ); 
 return i===-1 ? false : i;
}
function so_clearInnerHTML(obj){while(obj.firstChild)obj.removeChild(obj.firstChild);}
function strip_tags(content){stripped=content.replace(/(<([^>]+)>)/ig,"");return stripped;}
function createCookie(name,value,days)
{if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";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);}
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,true);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{return false;}}
function inputfocus(obj){obj.style.backgroundColor='lightyellow';}
function inputblur(obj){obj.style.backgroundColor='#ffffff';}
function popUp(URL,title){if(strpos(URL,'msg.php')!=false) { if(typeof(title)==="undefined") { var title = 'Private Message'; } popup_ajax('<h1>'+title+'</h1><iframe src="'+URL+'" width="400" height="280" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>'); } else { {day=new Date();id=day.getTime();eval("page"+id+" = window.open(URL, '"+id+"', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=400,height=320,left = 312,top = 234');");} } }
function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}
else if(xHeight("layout")&&xHeight("layout")>document.body.offsetHeight){xScroll=document.body.offsetWidth;yScroll=xHeight("layout");}
else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;}
function getPageScroll(){var yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;}else if(document.body){yScroll=document.body.scrollTop;}
arrayPageScroll=new Array('',yScroll)
return arrayPageScroll;}
function selectBoxDefault(selectbox_id,searched_value){var obj=xGetElementById(selectbox_id);var i=0;var im=obj.length;searched_value=searched_value.toLowerCase();while(i<im){if(obj.options[i].value.toLowerCase()==searched_value){obj.selectedIndex=i;break;}
i++;}}

function banner_howto(groupname) {
	popup_ajax("Copy/paste this piece of HTML: <br/><br /> <textarea cols=\"50\" rows=\"7\"><a href=\"http://grou.ps/"+groupname+"/join\"><img src=\"http://grou.ps/images/newbutton.png\" alt=\"Join This Group\" border=\"0\" width=\"120\" height=\"33\" border=\"0\" /></a></textarea>");
}
function banner_howto2(groupname) {
	popup_ajax("Copy/paste this piece of HTML: <br/><br /> <textarea cols=\"50\" rows=\"7\"><a href=\"http://grou.ps/"+groupname+"/join\"><img src=\"http://grou.ps/images/joinourgroup.gif\" alt=\"Join Our Grou.p\" border=\"0\" width=\"94\" height=\"15\" border=\"0\" /></a></textarea>");
}
function reportIssue(cpLink) {
	popup_ajax("<h1>Report an Issue</h1><p><textarea id='ri_concern' cols=\"50\" rows=\"7\" onfocus=\"if(this.value==this.defaultValue)this.value='';\">Your message goes here...</textarea></p><p><input type='button' value='Send' onclick='send_reportIssue()' /> <input type='button' value='Cancel' onclick='groups.modalBox.hide()' /><a href=\""+cpLink+"\" style=\"float: right; text-decoration: none\">Report Copyright</a></p>");
}
function send_reportIssue() {
	var x = document.getElementById('ri_concern').value;
	make_busy();
	x_reportIssue(x,issue_reported)
}
function issue_reported(res) {
	close_ajax_popup();
	alert("Reported to the admin, thanks!");
}
function getStyle(el,styleProp)
{
	if(document.getElementById(el)!="undefined")
		var x = document.getElementById(el);
	else
		var x = e1;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
function focusAfter(e,focusto){
	//console.log("here it is",e,e.charCode);
var evtobj=window.event? event : e;
var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode;
if(unicode==9)	{
	//console.log("ucalim denizlere");
	window.setTimeout(function() { document.getElementById(focusto).focus();}, 100);
}/*
else {
	console.log(unicode);
}*/
}

// http://snippets.dzone.com/posts/show/5369
function str_replace(f, r, s){
     	var ra = r instanceof Array, sa = s instanceof Array, l = (f = [].concat(f)).length, r = [].concat(r), i = (s = [].concat(s)).length;
     	while(j = 0, i--)
     		while(s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j < l);
     	return sa ? s : s[0];
    }

    function groups_signout(addr) {
    	if(FB!="undefined") {
    		window.setTimeout(function() {window.location.href=addr;}, 3000);
    		FB.Connect.ifUserConnected(function() { FB.Connect.logoutAndRedirect(addr); }, function() {window.location.href=addr;} );
    	}
    	else {
    		window.location.href=addr;
    	}
    }
function jsGet(type){
if(location.href.match(type)){
return location.href.split(type+'=')[1].split('&')[0];
}}

function no_link_during_wizard() {
	alert("Some links are disabled while this wizard is running. Check back after you finish!");
}