SITEURL = "http://"+window.location.hostname;


// BASIC AJAX HANDLER
function GetXmlHttpObject(handler){ 
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0){
		xmlHttp=new XMLHttpRequest();
		xmlHttp.onload=handler
		xmlHttp.onerror=handler
		return xmlHttp;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP"
		} try	{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} catch(e) { 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



var smilies_area = "";
function smilies_list(textarea) {
	//alert("here");
	smilies_area = textarea;
	//alert(document.getElementById("smilies_list_"+smilies_area).innerHTML.replace(" ","").length);
	if(document.getElementById("smilies_list_"+smilies_area).innerHTML=="") {
		var url=SITEURL+"/libs/ajax/ajax_smilies_list.php?field="+textarea;
		xmlHttp=GetXmlHttpObject(display_smilies_list);//fails on safari 1
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	}
	else {
		document.getElementById("smilies_list_"+smilies_area).innerHTML = "";
	}
}
function display_smilies_list() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		var return_text = xmlHttp.responseText;
		document.getElementById("smilies_list_"+smilies_area).innerHTML = return_text;
	} 
}

function edit_comment(comment_id,comment_status){
	var link = document.getElementById("edit_"+comment_id).innerHTML;
	document.getElementById("delete_comment_"+comment_id).innerHTML = "";
	if(link == "Edit"){
		document.getElementById("edit_"+comment_id).innerHTML = "Hide";
		document.getElementById("edit_comment_"+comment_id).style.display='block';
		if(comment_status == 0){
			document.getElementById("delete_"+comment_id).innerHTML = "Un-Delete";
		}	
		else{
			document.getElementById("delete_"+comment_id).innerHTML = "Delete";
		}
	}
	else if(comment_status == 0){
		document.getElementById("delete_"+comment_id).innerHTML = "Un-Delete";
		document.getElementById("edit_"+comment_id).innerHTML = "Edit";
		document.getElementById("edit_comment_"+comment_id).style.display='none';
	}
	else{
		document.getElementById("edit_"+comment_id).innerHTML = "Edit";
		document.getElementById("delete_"+comment_id).innerHTML = "Delete";
		document.getElementById("edit_comment_"+comment_id).style.display='none';
	}	
}

function delete_comment(comment_id,comment_status){
	var link = document.getElementById("delete_"+comment_id).innerHTML;
	document.getElementById("edit_comment_"+comment_id).style.display='none';
	if(link == "Delete"){
		document.getElementById("delete_"+comment_id).innerHTML = "Hide";
		document.getElementById("edit_"+comment_id).innerHTML = "Edit";
		document.getElementById("delete_comment_"+comment_id).innerHTML = '<div style="margin-top: 10px;"><form action="" method="POST"><strong>Delete Comment</strong><p>Are you sure you wish to delete this comment?</p><input type="button" value="No Thanks" name="action" onclick="delete_comment('+comment_id+');" ><input type="submit" value="Delete Comment" name="action"><input type="hidden" value="'+comment_id+'" name="comment_id"></form></div>';
		
	}
	else if(link == "Un-Delete"){
	
		document.getElementById("delete_"+comment_id).innerHTML = "Hide";
		document.getElementById("edit_"+comment_id).innerHTML = "Edit";
		document.getElementById("delete_comment_"+comment_id).innerHTML = '<div style="margin-top: 10px;"><form action="" method="POST"><strong>Un-Delete Comment</strong><p>Are you sure you wish to un-delete this comment?</p><input type="button" value="No Thanks" name="action" onclick="delete_comment('+comment_id+','+comment_status+');" ><input type="submit" value="Un-Delete Comment" name="action"><input type="hidden" value="'+comment_id+'" name="comment_id"></form></div>';
	}
	else if(comment_status == 0){
		document.getElementById("delete_"+comment_id).innerHTML = "Un-Delete";
		document.getElementById("edit_"+comment_id).innerHTML = "Edit";
		document.getElementById("delete_comment_"+comment_id).innerHTML = "";
	}
	else{
		document.getElementById("delete_"+comment_id).innerHTML = "Delete";
		document.getElementById("edit_"+comment_id).innerHTML = "Edit";
		document.getElementById("delete_comment_"+comment_id).innerHTML = "";
	}	
}

/*function insertsmiley(tag,text_field){
	// our textfiaseeld
	
	var textarea = document.getElementById(text_field);
	var scrollPos = textarea.scrollTop;
	if(!textarea.setSelectionRange) {
		var selected="";
		if (window.getSelection) {
			selected = window.getSelection();
		}
		else if (document.getSelection) {
			selected = document.getSelection();
		}
		else if (document.selection) {
			selected = document.selection.createRange().text;
			
		}

		if(selected.length <= 0)    {
				// no text was selected so prompt the user for some text
				textarea.value += tag;
		}
		else {
			// put the code around the selected text
			var text_box_text=document.getElementById(text_field).value;
			if(selected!=null)
			{
					if(text_box_text.indexOf(selected)!=-1)
					{	    
						document.selection.createRange().text = tag;		 
					}
			}
		}
	}
	else {
			// the text before the selection
			var pretext = textarea.value.substring(0, textarea.selectionStart);
			// the selected text with tags before and after
			var codetext = tag;
			// the text after the selection
			var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
			// check if there was a selection
			if(codetext == tag) {
					//prompt the user
					codetext = tag;
			}
			// update the text field
			textarea.value = pretext + tag + posttext;
	}
	// set the focus on the text field

	var textarea = document.getElementById(text_field);
	caretPos(textarea,scrollPos);
	textarea.focus();
	
}*/

	
function caretPos(textEl,scrollPos) {
	var i=textEl.value.length+1;
	if (!textEl.setSelectionRange){
		theCaret = document.selection.createRange().duplicate();
			while (theCaret.parentElement()==textEl && 
theCaret.move("character",1)==1) --i;
			return i;
	}
	else {
		textEl.focus();
		//var scrollPos = textEl.scrollTop;
		textEl.scrollTop = scrollPos;
	}
	return -1;
}

function checkbox_control(div,status){
	var inputs = document.getElementById(div).getElementsByTagName('input');
	for(var i=0; i < inputs.length; i++){
		inputs[i].checked = status;
	}
}

function pm_select_username(pm_selected_username){
	opener.document.forms['pm'].to_username.value = pm_selected_username;
	opener.focus();
	window.close();
}

function faq_mark_helpful(faq_id) {
	//alert("here");
	var url=SITEURL+"/libs/ajax/ajax_faq_helpful.php?faq_question_id="+faq_id;
	xmlHttp=GetXmlHttpObject(change_faq_mark_helpful);//fails on safari 1
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function change_faq_mark_helpful() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		
		var return_text = xmlHttp.responseText;
		
		var return_text2 = return_text.split(",");
		comm_id = return_text2[0];
		the_div = document.getElementById("vote_as_helpful"+comm_id);
		the_div.innerHTML = return_text2[1];
		the_div.onclick=function() {return false};
		the_div.style.textDecoration="none";
		the_div.style.cursor="default";
	} 
}



function ShowHide(){
  // CROSS-BROWSER, GENERIC
  // Hide or show the object - the method used depends on the user's browser.

  // First parameter: name of object to show/hide
  // Second parameter: whether to hide, show or reverse the current status of the object.
  //   Values are: 'hidden', 'visible', 'reverse'
  //   Second param is optional if a third parameter is not supplied. When left out, the
  //   second param defaults to 'reverse'
  // Third parameter: if to affect surrounding content - 'reflow' or 'fixed'
  //   Defaults to 'reflow'
  //   When 'reflow', content below the object moves up or down depending on whether
  //   the object is visible or not. This uses (for W3C) the display style property.
  //   When 'fixed', showing or hiding the object does not affect other parts of the
  //   page. This uses (for W3C) the visibility style propery.
  
  // E.g. ShowHide('divLayer1') or ShowHide('divLayer1','visible') or
  // ShowHide('divLayer1','reverse','chkBox1')

  // Get arguments
  Args = ShowHide.arguments;

  // If the first argument doesn't exist, leave function
  if(Args.length>0) Args = new Array(Args[0], Args[1], Args[2]);
  else return false;

	//alert(Args[0]+","+Args[1]+","+Args[2]);
  switch (Args[1])
  {
    case 'hidden':
      // If the second argument is 'hidden', hide the object using the method appropriate to the browser
      if(Args[2] == 'fixed')
      {
      // Use the visibility property
        if(document.getElementById) document.getElementById(Args[0]).style.visibility = 'hidden';
        else if(document.all[Args[0]]) document.all[Args[0]].style.visibility = "hidden";
        else if(document.layers) document.layers[Args[0]].visibility = "hide";
        else return false;
				
				return true;
      }
      else
      {  
        // Use the display property 
        if(document.getElementById) {document.getElementById(Args[0]).style.display = 'none';}
        else if(document.all[Args[0]]) document.all[Args[0]].style.display = "none";
        else if(document.layers) document.layers[Args[0]].visibility = "hide";
        else return false;
				
				return true;
      }
      break;
    case 'visible':
      // If the second argument is 'visible', hide the object using the method appropriate to the browser
      if(Args[2] == 'fixed')
      {  
        if(document.getElementById) document.getElementById(Args[0]).style.visibility = 'visible';
        else if(document.all[Args[0]]) document.all[Args[0]].style.visibility = "visible";
        else if(document.layers) document.layers[Args[0]].visibility = "show";
        else return false;
				
				return true;
      }
      else
      {
        if(document.getElementById) document.getElementById(Args[0]).style.display = 'block';
        else if(document.all[Args[0]]) document.all[Args[0]].style.display = "block";
        else if(document.layers) document.layers[Args[0]].visibility = "show";
        else return false;    
				
				return true;
      }
      break;
    default:
      // Else if the object is current visible set to hidden else set to visible
   
      if(document.getElementById)
      {
        // Use getElementByID method for IE5+ and NS6+ (W3C standard)
        if(Args[2] == 'fixed')
        {
          if(document.getElementById(Args[0]).style.visibility == 'visible') document.getElementById(Args[0]).style.visibility = 'hidden';
          else document.getElementById(Args[0]).style.visibility = 'visible';
					
					return true;
        }
        else
        {
          if(document.getElementById(Args[0]).style.display == 'block') document.getElementById(Args[0]).style.display = 'none';
          else document.getElementById(Args[0]).style.display = 'block';
        
					return true;
				}

      }
      else 
      {
        if(document.all[Args[0]])
        {
          if(Args[2] == 'fixed')
          {
            // Use document.all method for older IE
            if(document.all[Args[0]].style.visibility == 'visible') document.all[Args[0]].style.visibility = 'hidden';
            else document.all[Args[0]].style.visibility = 'visible';
						return true;
          }
          else
          {
            if(document.all[Args[0]].style.display == 'block') document.all[Args[0]].style.display = 'none';
            else document.all[Args[0]].style.display = 'block';    
						return true;
          }
        }
        else 
        {
          // Try to use NS4 layers
          if(document.layers[Args[0]])
          {
            if(document.layers[Args[0]].visibility = "show") document.layers[Args[0]].visibility = "hide";
            else document.layers[Args[0]].visibility = "show";
						return true;
          }
          else
          {
            // Give up
            return false;
          }  // give up
        }  // NS
      }  // IE4
    }
		return 654654654654;// end of Switch
}


function insertquote(code,commentbox_id) {
//alert(commentbox_id);


 var textarea = document.getElementById(commentbox_id);
 var scrollPos = textarea.scrollTop;
 
 var items = insertquote.arguments.length;
 if(items>1) {
	//there is a 3rd arg
	var username = insertquote.arguments[2];
	//leave numbers to fit in with other bbcode
	var open = "[quote:3496ace15f=\""+username+"\"]";
 }
 else {
	var open = "[quote]";
 }

 
	// our close tag
 var close = "[/quote]";
 
 var text = open+code+close;

		if(document.selection) { 
				textarea.focus(); 
				var orig = textarea.value.replace(/\r\n/g, "\n"); 
				var range = document.selection.createRange(); 
 
				if(range.parentElement() != textarea) { 
						return false; 
				} 
 
				range.text = text; 
				 
				var actual = tmp = textarea.value.replace(/\r\n/g, "\n"); 

				for(var diff = 0; diff < orig.length; diff++) { 
						if(orig.charAt(diff) != actual.charAt(diff)) break; 
				} 
 
				for(var index = 0, start = 0;  
						tmp.match(text)  
								&& (tmp = tmp.replace(text, ""))  
								&& index <= diff;  
						index = start + text.length 
				) { 
						start = actual.indexOf(text, index); 
				} 
		} 
		else if(textarea.selectionStart) { 
				var start = textarea.selectionStart; 
				var end   = textarea.selectionEnd; 
 
				textarea.value = textarea.value.substr(0, start)  
						+ text  
						+ textarea.value.substr(end, textarea.value.length); 
		} 
		 
	if(start != null) { 
			 setCaretTo(textarea, start + text.length); 
	} 
	else { 
		 textarea.value += text; 
	}
	var textarea = document.getElementById(commentbox_id);
	caretPos(textarea,scrollPos);
	parent.location='#addcomment';		
}

function insertcode(tag,text_field) {
    	var txt = document.getElementById(text_field);


        	if(document.selection) {
        		txt.focus();
        		sel = document.selection.createRange();
        		sel.text = '[' + tag + ']' + sel.text + '[/' + tag + ']';
        	} else if(txt.selectionStart || txt.selectionStart == '0') {	
        		txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"]" + (txt.value).substring(txt.selectionStart, txt.selectionEnd) + "[/"+tag+"]" + (txt.value).substring(txt.selectionEnd, txt.textLength);


            	} else {
            		txt.value = '[' + tag + '][/' + tag + ']';
            	}
            	return;
        }

function insertsmiley(tag,text_field){
		var txt = document.getElementById(text_field);


        	if(document.selection) {
        		txt.focus();
        		sel = document.selection.createRange();
        		sel.text = '' + tag + '' + sel.text;
        	} else if(txt.selectionStart || txt.selectionStart == '0') {	
        		txt.value = (txt.value).substring(0, txt.selectionStart) + ""+tag+"" + (txt.value).substring(txt.selectionStart, txt.selectionEnd) +  (txt.value).substring(txt.selectionEnd, txt.textLength);


            	} else {
            		txt.value =  tag;
            	}
            	return;
}
 
/*function insertcode(tag,text_field) {
	// our textfiaseeld
	var textarea = document.getElementById(text_field);
	var scrollPos = textarea.scrollTop;
 // our open tag
	var open = "[" + tag + "]";
	// our close tag
	var close = "[/" + tag + "]";
	if(!textarea.setSelectionRange) {
		var selected="";
		if (window.getSelection) {
			selected = window.getSelection();
		}
		else if (document.getSelection) {
			selected = document.getSelection();
		}
		else if (document.selection) {
			selected = document.selection.createRange().text;
			
		}

		if(selected.length <= 0)    {
				// no text was selected so prompt the user for some text
				textarea.value += open + close;
		}
		else {
				// put the code around the selected text
			var text_box_text=document.getElementById(text_field).value;
			if(selected!=null)
			{
					if(text_box_text.indexOf(selected)!=-1)
					{	    
						document.selection.createRange().text = open + selected + close;		 
					}
			}
		}
	}
	else {
			// the text before the selection
			var pretext = textarea.value.substring(0, textarea.selectionStart);
			// the selected text with tags before and after
			var codetext = open + textarea.value.substring(textarea.selectionStart, textarea.selectionEnd) + close;
			// the text after the selection
			var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
			// check if there was a selection
			if(codetext == open + close) {
					//prompt the user
					codetext = open + close;
			}
			// update the text field
			textarea.value = pretext + codetext + posttext;
	}
	// set the focus on the text field

	var textarea = document.getElementById(text_field);
	caretPos(textarea,scrollPos);
	textarea.focus();
}*/


// inserts a link by prompting the user for a url
function insertlink(text_field)
{
    // our textfield
    var textarea = document.getElementById(text_field);
		var scrollPos = textarea.scrollTop;
   // our open tag
   

    if(!textarea.setSelectionRange)
    {
        //var selected = document.selection.createRange().text;
				var selected="";
				if (window.getSelection)
				{
					selected = window.getSelection();
					
				}
				else if (document.getSelection)
				{
					selected = document.getSelection();
				
				}
				else if (document.selection)
				{
					selected = document.selection.createRange().text;
					
				}
				
				
				
				
        if(selected.length <= 0)
        {
            // no text was selected so prompt the user for some text
						var url = prompt("Please enter the url", "http://");
						if(url!=null) {
   
							var open = "[link=" + url + "]";

				    // our close tag
							var close = "[/link]";
						
						
							textarea.value += open + "link"+ close;
						}
						//alert(textarea.value+"here");
        }
        else
        {
				    var text_box_text=document.getElementById(text_field).value;
				    if(selected!=null)
						{
								if(text_box_text.indexOf(selected)!=-1)
								{	    
            // put the code around the selected text
										var url = prompt("Please enter the url", "http://");
										
										if(url!=null) {
   
									    var open = "[link=" + url + "]";

									    // our close tag
									    var close = "[/link]";
							
							
											document.selection.createRange().text = open + selected + close;
										}
										//alert(document.selection.createRange().text+"here1");
								}
						}
        }

    }
    else
    {
       
        var url = prompt("Please enter the url", "http://");
				if(url!=null) {
   
			    var open = "[link=" + url + "]";

			    // our close tag
			    var close = "[/link]";


				 // the text before the selection
	        var pretext = textarea.value.substring(0, textarea.selectionStart);

	        // the selected text with tags before and after
	        var codetext = open + textarea.value.substring(textarea.selectionStart, textarea.selectionEnd) + close;

	        // the text after the selection
	        var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);

	        // check if there was a selection
	        if(codetext == open + close)
	        {
	            //prompt the user
	            codetext = open + "link"+ close;
	        }
					//alert(codetext);
	        // update the text field
	        if(codetext == "") {
						codetext = "link";
					}
					textarea.value = pretext + codetext + posttext;
				}
				
				
				//alert(textarea.value+"here2");
    }
		var textarea = document.getElementById(text_field);
		caretPos(textarea,scrollPos);
    // set the focus on the text field
    textarea.focus();
}


function mark_helpful(comment_id,style){
	document.getElementById('comment_'+comment_id).className = style;
	
	if(style == '#b6efb4'){
		
		//alert(document.getElementById('comment_help_'+comment_id).innerHTML);
		var url=SITEURL+"/libs/ajax/ajax_mark_helpful.php?helpful=1&forum_comment_id="+comment_id;
		//alert(url);
		//font = '#fff';
		document.getElementById('comment_help_'+comment_id).innerHTML = '<strong><img src="'+SITEURL+'/images/site/thumb_up.gif" style="vertical-align:middle;margin-right:2px;">Helpful</strong>  <a href="javascript:;" onclick="mark_helpful('+comment_id+',\'#E5E5E5\');" >Unmark Helpful</a> |';
		
	}
	else{
		var url=SITEURL+"/libs/ajax/ajax_mark_helpful.php?helpful=0&forum_comment_id="+comment_id;
		document.getElementById('comment_help_'+comment_id).innerHTML = '<a href="javascript:;" onclick="mark_helpful('+comment_id+',\'#b6efb4\')">Mark as Helpful</a> | ';
		font = '#000';
	}

	document.getElementById('upper_comment_'+comment_id).style.backgroundColor = style;
	document.getElementById('lower_comment_'+comment_id).style.backgroundColor = style;
	document.getElementById('comment_'+comment_id).style.backgroundColor = style;
	
	//document.getElementById('comment_'+comment_id).style.color = font;
	//alert(document.getElementById('comment_'+comment_id).style.backgroundColor);
	
	//alert(url);
	xmlHttp=GetXmlHttpObject(nothing);//fails on safari 1
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	
}
function nothing() {}
function input_control(action,id,stringval){
	if(action == 'fill'){
		if (document.getElementById(id).value == ''){
			document.getElementById(id).value = stringval;
			document.getElementById(id).className = 'searchbox_off';
		}
	}
	else if(action == 'empty'){
		if (document.getElementById(id).value == stringval){
			document.getElementById(id).value = '';
			document.getElementById(id).className = 'searchbox_on';
		}
	}
}
function forum_search_hide_control() {
	
	if(document.getElementById('forum_search_link').innerHTML != "Hide Options") {
		document.getElementById('forum_search_link').innerHTML = "Hide Options";
		ShowHide('search_forum_form','visible');
	}
	else {
		document.getElementById('forum_search_link').innerHTML = "Show Options";
		ShowHide('search_forum_form','hidden');
	}
}

function gallery_filter_expand(parent_id){
	var current_display = document.getElementById('filter_children_'+parent_id).style.display;

	ShowHide('filter_children_'+parent_id,'reverse');

	if (current_display == 'none'){
		document.getElementById('filter_button_'+parent_id).innerHTML = '<img src="'+SITEURL+'/images/site/control_play_down.gif" title="hide" alt="hide" style="float:right;" border="0"/>';
	}
	else{
		document.getElementById('filter_button_'+parent_id).innerHTML = '<img src="'+SITEURL+'/images/site/control_play.gif" title="expand" alt="expand" style="float:right;" border="0"/>';
	}
}

function gallery_filter_tick_children(parent_id,status){
	if(status == true){
		checkbox_control('filter_children_'+parent_id,status);
	}
	else{
		checkbox_control('filter_children_'+parent_id,status);
	}
}

function checkbox_control(div,status){
	var inputs = document.getElementById(div).getElementsByTagName('input');
	for(var i=0; i < inputs.length; i++){
		inputs[i].checked = status;
	}
}
function input_control(action,id,stringval){
	if(action == 'fill'){
		if (document.getElementById(id).value == ''){
			document.getElementById(id).value = stringval;
			document.getElementById(id).className = 'searchbox_off';
		}
	}
	else if(action == 'empty'){
		if (document.getElementById(id).value == stringval){
			document.getElementById(id).value = '';
			document.getElementById(id).className = 'searchbox_on';
		}
	}
}
function add_remove_notify(object_type,object_id,return_off) {
	if(document.getElementById(return_off).innerHTML == "Add Notification") {
		add_notify(object_type,object_id,return_off);
	}
	else {
		remove_notify(object_type,object_id,return_off);
	}
}

var notification_return_off;
function add_notify(object_type,object_id,return_off) {
	notification_return_off = return_off;
	var url=SITEURL+"/libs/ajax/ajax_add_notify.php?object_type="+object_type+"&object_id="+object_id;
	xmlHttp=GetXmlHttpObject(add_notify_helper);//fails on safari 1
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function add_notify_helper() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		var return_text = xmlHttp.responseText;
		//ok got the text back
		return_obj = document.getElementById(notification_return_off);
		return_obj.innerHTML = return_text;
	} 
}
function remove_notify(object_type,object_id,return_off) {
	notification_return_off = return_off;
	var url=SITEURL+"/libs/ajax/ajax_remove_notify.php?object_type="+object_type+"&object_id="+object_id;
	xmlHttp=GetXmlHttpObject(add_notify_helper);//fails on safari 1
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function remove_notify_helper() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		var return_text = xmlHttp.responseText;
		//ok got the text back
		return_obj = document.getElementById(notification_return_off);
		return_obj.innerHTML = return_text;
		
		
	} 
}


/* ************************************************************
Created: 20060120
Author:  Steve Moitozo <god at zilla dot us> -- geekwisdom.com
Description: This is a quick and dirty password quality meter 
		 written in JavaScript so that the password does 
		 not pass over the network.
License: MIT License (see below)
Modified: 20060620 - added MIT License
Modified: 20061111 - corrected regex for letters and numbers
                     Thanks to Zack Smith -- zacksmithdesign.com
---------------------------------------------------------------
Copyright (c) 2006 Steve Moitozo <god at zilla dot us>

Permission is hereby granted, free of charge, to any person 
obtaining a copy of this software and associated documentation 
files (the "Software"), to deal in the Software without 
restriction, including without limitation the rights to use, 
copy, modify, merge, publish, distribute, sublicense, and/or 
sell copies of the Software, and to permit persons to whom the 
Software is furnished to do so, subject to the following 
conditions:

************************************************************ */
function testPassword(passwd,area_check)
{
		//alert(passwd);
	if(passwd!="") {
		var intScore   = 0
		var strVerdict = "weak"
		var strLog     = ""
		
		// PASSWORD LENGTH
		if (passwd.length<5)                         // length 4 or less
		{
			intScore = (intScore+3)
			strLog   = strLog + "3 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>4 && passwd.length<8) // length between 5 and 7
		{
			intScore = (intScore+6)
			strLog   = strLog + "6 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>7 && passwd.length<16)// length between 8 and 15
		{
			intScore = (intScore+12)
			strLog   = strLog + "12 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>15)                    // length 16 or more
		{
			intScore = (intScore+18)
			strLog   = strLog + "18 point for length (" + passwd.length + ")\n"
		}
		
		
		// LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
		if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
		{
			intScore = (intScore+1)
			strLog   = strLog + "1 point for at least one lower case char\n"
		}
		
		if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one upper case char\n"
		}
		
		// NUMBERS
		if (passwd.match(/\d+/))                                 // [verified] at least one number
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one number\n"
		}
		
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least three numbers\n"
		}
		
		
		// SPECIAL CHAR
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one special char\n"
		}
		
									 // [verified] at least two special characters
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least two special chars\n"
		}
	
		
		// COMBOS
		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))        // [verified] both upper and lower case
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for upper and lower letters\n"
		}

		if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for letters and numbers\n"
		}
 
									// [verified] letters, numbers, and special characters
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for letters, numbers and special chars\n"
		}
	
	
		if(intScore < 5)
		{
			 strVerdict = "very weak"
		}
		else if (intScore > 4 && intScore < 14)
		{
			 strVerdict = "weak"
		}
		else if (intScore > 13 && intScore < 20)
		{
			 strVerdict = "mediocre"
		}
		else if (intScore > 19 && intScore < 30)
		{
			 strVerdict = "strong"
		}
		else
		{
			 strVerdict = "stronger"
		}
	
		document.getElementById(area_check).innerHTML = strVerdict;
	}
	
}

function check_username(){
	var username = document.getElementById('username').value;
	var url=SITEURL+"/libs/ajax/ajax_check_username.php?username="+username;
	xmlHttp=GetXmlHttpObject(check_username_helper);//fails on safari 1
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function check_username_helper() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		var return_text = xmlHttp.responseText;
		//ok got the text back
		return_obj = document.getElementById('username_check');
		return_obj.innerHTML = return_text;
		
		
	} 
}

function search_tab(id){
	
	
	if(document.getElementById('news_tab')!=null){
		ShowHide('news_results','hidden');
		document.getElementById('news_tab').className='';
		
	}
	if(document.getElementById('gallery_tab')!=null) {
		ShowHide('gallery_results','hidden');
		document.getElementById('gallery_tab').className='';
	}
	if(document.getElementById('forum_tab')!=null) {
		ShowHide('forum_results','hidden');
		document.getElementById('forum_tab').className='';
	}
	if(document.getElementById('members_tab')!=null) {
			ShowHide('members_results','hidden');
			document.getElementById('members_tab').className='';
	}
	if(document.getElementById('price_list_tab')!=null) {
			ShowHide('price_list_results','hidden');
			document.getElementById('price_list_tab').className='';
	}
	
	ShowHide(id+'_results','visible');
	document.getElementById(id+'_tab').className = 'active';
	
}


