
//Various form stuff alot of which found in tutorials from the web, thanks to all!

function unpip(){pipDiv=$('pipDiv');if(pipDiv){pipDiv.parentNode.removeChild(pipDiv);pipDiv=false;}}
function pip(id,text,text2,type){unpip();$('content-'+id).innerHTML+='<div id="pipDiv" class="inline-warning" style="width:480px;"><div><p><strong>'+text+'</strong> To '+text2+type+', <a href="/icLogin.php?return='+document.location.pathname+document.location.search+'">login</a> or <a href="/icRegister.php">register to join the fun</a>.</p><a href="javascript:unpip()"><img src="/img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}
function pipVote(id){return(pip(id,'Like this? Vote it IN and help it grow!','vote ','it IN'));}
function pipBury(id){return(pip(id,'Not sure you like it? Vote it OUT!','vote ','it OUT'));}
function pipweb(id){return(pip(id,'ext link ','ideas'));}
function pipEmail(id){return(pip(id,'Support this and email it to your friends!','email',''));}
function pipReview(id){return(pip(id,'attachment ','ideas'));}
function pipJoin(id){return(pip(id,'join ',''));}
function pipListen(id){return(pip(id,'listen ',''));}

function untieoff(){tieoffDiv=$('tieoffDiv');if(tieoffDiv){tieoffDiv.parentNode.removeChild(tieoffDiv);tieoffDiv=false;}}
function tieoff(id,text,layout){untieoff();$('alpha-'+id).innerHTML+='<div id="tieoffDiv" class="inline-warning"><div><p><strong>'+text+' version feature.</strong>'+layout+' Thank you for your patience.</p><a href="javascript:untieoff()"><img src="/img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}
function tieoffGeneral(id){return(tieoff(id,'Beta',''));}
function tieoffGeneral2(id){return(tieoff(id,'Beta','<br><br>'));}

function unturnedoff(){turnedoffDiv=$('turnedoffDiv');if(turnedoffDiv){turnedoffDiv.parentNode.removeChild(turnedoffDiv);turnedoffDiv=false;}}
function turnedoff(id,text){unturnedoff();$('content-'+id).innerHTML+='<div id="turnedoffDiv" class="inline-warning"><div><p>No '+text+' was uploaded for this Thought/Idea.</p><a href="javascript:unturnedoff()"><img src="img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}
function turnedoffPosts(id){return(turnedoff(id,'Comments'));}
function turnedoffFanBase(id){return(turnedoff(id,'FanBase'));}
function turnedoffweb(id){return(turnedoff(id,'Ext Link'));}
function turnedoffEmail(id){return(turnedoff(id,'Email'));}
function turnedoffReview(id){return(turnedoff(id,'Attachment'));}
function turnedoffCategories(id){return(turnedoff(id,'Categories'));}
function turnedoffTopics(id){return(turnedoff(id,'Tags'));}
function turnedoffCity(id){return(turnedoff(id,'City'));}

function unprofileoff(){profileoffDiv=$('profileoffDiv');if(profileoffDiv){profileoffDiv.parentNode.removeChild(profileoffDiv);profileoffDiv=false;}}
function profileoff(id,text){unprofileoff();$('content-'+id).innerHTML+='<div id="profileoffDiv" class="inline-warning"><div><p><strong>Tell us about your Band...</strong><br><br> As soon as your band profile is fully completed at <a href="EditMyBand">edit my band</a>,<br> the '+text+' feature will be turned on.<br><br> Make sure to fill out all the areas and invite your friends, to help raise<br> your buzz rating, grow your fan base and let fans catch a buzz from our<br> zippy fast servers<br><br> Thank you.<br></p><a href="javascript:unprofileoff()"><img src="img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}
function profileoffAddTrack(id){return(profileoff(id,'Submit Music'));}

function profileoff2(text){unprofileoff();$('top_menu').innerHTML+='<div id="profileoffDiv" class="inline-warning" style="left:190px;top:140px;"><div><p><strong>Tell us about your Band...</strong><br><br> As soon as your band profile is fully completed at <a href="EditMyBand">edit my band</a>,<br> the '+text+' feature will be turned on.<br><br> Make sure to fill out all the areas and invite your friends, to help raise<br> your buzz rating, grow your fan base and let fans catch a buzz from our<br> zippy fast servers<br><br> Thank you.<br></p><a href="javascript:unprofileoff()"><img src="img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}
function profileoffAddTrack2(){return(profileoff2('Submit Music'));}

function categoriesoff(){categoriesonDiv=$('categoriesonDiv');if(categoriesonDiv){categoriesonDiv.parentNode.removeChild(categoriesonDiv);categoriesonDiv=false;}}
function categorieson(){categoriesoff();$('content-'+id).innerHTML+='<div id="tieoffDiv" class="inline-warning"><div><p><strong>'+text+' feature currently unavailable.</strong> Thank you for your patience.</p><a href="javascript:untieoff()"><img src="img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}

function toggleShowDiv(id){var div=document.getElementById(id);if(div.className=='slidey-show'){div.className='slidey-hide';}else{div.className='slidey-show';}
return(false);}
function tsd(id){return(toggleShowDiv(id));}

function unselectoff(){tieoffDiv=$('tieoffDiv');if(tieoffDiv){tieoffDiv.parentNode.removeChild(tieoffDiv);tieoffDiv=false;}}
function selectoff(id,text){untieoff();$('content-'+id).innerHTML+='<div id="tieoffDiv" class="inline-warning"><div><p><strong>'+text+' feature currently unavailable.</strong> Thank you for your patience.</p><a href="javascript:untieoff()"><img src="img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}

function featureoff(id,text){untieoff();$(id).innerHTML+='<div id="tieoffDiv" class="inline-warning" style="width:250px;"><div><p><strong>'+text+' feature currently unavailable.</strong> Thank you for your patience.</p><a href="javascript:untieoff()"><img src="img/shared/pip_close.gif" class="close" width="22" height="22" alt="Close"></a></div></div>';return(false);}

function toggleOff(id){var div=document.getElementById(id);div.className='slidey-hide';}
function toggleOn(id){var div=document.getElementById(id);div.className='slidey-show';}

function loggleOn(id){var div=document.getElementById(id);if(div.className=='slidey-show'){div.className='slidey-hide';}else{div.className='slidey-show';}}
function loggleOn2(id,level){var div=document.getElementById(id);if((div.className=='slidey-hide') && (level!=3)){div.className='slidey-show';}else{div.className='slidey-hide';}}

function toggle2Div(rbtn, id1, id2) {
   if ( rbtn.value == "upload" ) {
      document.getElementById(id1).style.display = "none";
	  document.getElementById(id2).style.display = "block";
} else {
      document.getElementById(id2).style.display = "none";
	  document.getElementById(id1).style.display = "block";
   }
  document.getElementById('rbgrouptxt').value=rbtn.value;
}

function toggle2Msg(id1, id2) {
   if ( document.getElementById('rbgrouptxt').value == "upload" ) {
	toggleOff(id1)
	toggleOn(id2)
   }
}

function enablebutton (button, button2, target)
{
	var string = target.value;
	if (button2 != null) {
		button2.disabled = false;
	}
	if (string.length > 0) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
}

function checkfield (type, form, field, text, spacing, visual)
{
	url = base_url + 'func/func_validate.php?type='+type+'&name=' + field.value;
	checkRequest = new getXMLRequest ();
	checkRequest.open ("GET", url, true);
 	checkRequest.send("");
	checkRequest.onreadystatechange = function () {
		if (checkRequest.readyState == 4) {
		ResponseStr = checkRequest.responseText;
			if (ResponseStr == 'validated') {
				document.getElementById (type+'checkitvalue').innerHTML = '<span class="checked_good"><img src="/img/visuals/'+visual+'/votes/alertGreenSuccess.gif">Good Choice, '+ text +' "' + field.value + 
						'" is available.'+spacing+'</span>';
				form.submit.disabled = '';
			} else {
				document.getElementById (type+'checkitvalue').innerHTML = '<span class="checked_bad"><img src="/img/visuals/'+visual+'/votes/alertRedError.gif">'+ text +' "' + field.value + '" '+ResponseStr+spacing+'</span>';
				form.submit.disabled = 'disabled';
			}
		}
	}
  return false;
}

function reportProblem(frm, user, id, md5 /*id, code*/) {
	if (frm.ratings.value == 0)
		return;
	if (! confirm("Report Problem?") ) {
		frm.ratings.selectedIndex=0;
		return false;
	}
	content = "id=" + id + "&user=" + user + "&md5=" + md5 + '&value=' +frm.ratings.value;
	url=base_url + "func/func_error.php?" + content;
	reportRequest = new getXMLRequest ();
	reportRequest.open("GET",url,true);
	reportRequest.send("");	
	reportRequest.onreadystatechange=function() {
		if (reportRequest.readyState==4) {
			error_topic = new RegExp ("^ERROR:");
			response = reportRequest.responseText;
			if (response.match(error_topic)) {
				response = response.substring (6, response.length);
				alert (response);
			} else {
				disableVote(id, "Problem reported.");
				displayVoters(id);
			}
		}
  	}
	return false;
}

function CheckFieldLength(fn,rn,mc) {
  var len = fn.value.length;
  if (len > mc) {
    fn.value = fn.value.substring(0,mc);
    len = mc;
  }
  document.getElementById(rn).innerHTML = mc - len;
}

function fixedSize(url,name,features) {
	win = window.open(url,name,features);
}
