function _AdSidebar(sh) {
   if (sh) {
      if ($('adsidebar')) $('adsidebar').style.display = 'block';
      if ($('cont_data')) $('cont_data').style.width = '710px';
   } else {
      if ($('adsidebar')) $('adsidebar').style.display = 'none';
      if ($('cont_data')) $('cont_data').style.width = '100%';
   }
}

function rawurlencode(str){var histogram={},unicodeStr='',hexEscStr='';var ret=str.toString();var replacer=function(search,replace,str){var tmp_arr=[];tmp_arr=str.split(search);return tmp_arr.join(replace);};histogram["'"]='%27';histogram['(']='%28';histogram[')']='%29';histogram['*']='%2A';histogram['~']='%7E';histogram['!']='%21';histogram['\u20AC']='%80';histogram['\u0081']='%81';histogram['\u201A']='%82';histogram['\u0192']='%83';histogram['\u201E']='%84';histogram['\u2026']='%85';histogram['\u2020']='%86';histogram['\u2021']='%87';histogram['\u02C6']='%88';histogram['\u2030']='%89';histogram['\u0160']='%8A';histogram['\u2039']='%8B';histogram['\u0152']='%8C';histogram['\u008D']='%8D';histogram['\u017D']='%8E';histogram['\u008F']='%8F';histogram['\u0090']='%90';histogram['\u2018']='%91';histogram['\u2019']='%92';histogram['\u201C']='%93';histogram['\u201D']='%94';histogram['\u2022']='%95';histogram['\u2013']='%96';histogram['\u2014']='%97';histogram['\u02DC']='%98';histogram['\u2122']='%99';histogram['\u0161']='%9A';histogram['\u203A']='%9B';histogram['\u0153']='%9C';histogram['\u009D']='%9D';histogram['\u017E']='%9E';histogram['\u0178']='%9F';ret=encodeURIComponent(ret);for(unicodeStr in histogram){hexEscStr=histogram[unicodeStr];ret=replacer(unicodeStr,hexEscStr,ret);}return ret.replace(/(\%([a-z0-9]{2}))/g,function(full,m1,m2){return"%"+m2.toUpperCase();});}

function openShoutcastPlayer() {
   window.open("playerShoutcastCompact.html", null, "height=160,width=365,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
   document.getElementById("flashcontent").innerHTML = '<table width=340 height=89><tr><td width=20>&nbsp;</td><td>Player was opened in a separate window<br>'+
   '<a href="javascript:void(returnShoutcastPlayer());">Click to open player here</a></table>';
}
function returnShoutcastPlayer() {
   var so = new SWFObject('playerShoutcast.swf', 'main', '349', '260', '8', '#FFFFFF', true);
   so.addParam('allowScriptAccess', 'sameDomain')
   so.write('flashcontent');
   $('flashcontent_title').style.display = 'none';
   initialize();
}

function startArchivePlayer(playid, playtitle) {
   var so = new SWFObject('playerArchive.swf?xmlPath=http://www.itntradio.com/playerArchive.php?xspf='+playid+'&playid='+playid+'&playtitle='+playtitle, 'main', '349', '260', '8', '#FFFFFF', true);
   so.addVariable("xmlPath","http://www.itntradio.com/playerArchive.php?xspf="+playid);
   so.addVariable("playid",playid);
   so.addVariable("playtitle",playtitle);
   so.write("flashcontent");
   document.getElementById("flashcontent_title").style.display = 'block';
   document.getElementById("flashcontent_title").innerHTML = '<strong>Show:</strong>&nbsp;'+playtitle;
   document.getElementById("flashcontent").innerHTML += '<br /><div style="padding-top:2px;">&nbsp;<a href="javascript:void(returnShoutcastPlayer());" style="color:#ED003D !important; font-weight: bold;">Click here to listen to current show</a></div>';
}

function openArchivePlayer(playid, playtitle) {
   window.open("playerArchive.php?playid="+playid+"&playtitle="+rawurlencode(playtitle),null,"height=345,width=380,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
   document.getElementById("flashcontent_title").innerHTML = '';
   document.getElementById("flashcontent").innerHTML = '<table width=340 height=89><tr><td width=20>&nbsp;</td><td>On-demand player was opened in another window<br>'+
   '<a href="javascript:startArchivePlayer(' + playid + ',\'' + playtitle + '\');">Open Player Here</a></table>';
}

function hideAllArchiveShows() {
   var all = document.getElementsByTagName('*');
   for(i=0; i<all.length; i++){
      if(all[i].className == 'archive_for_dj') all[i].style.display = 'none';
      if(all[i].hasClassName('archives_dj_link_active')) all[i].removeClassName('archives_dj_link_active');
   }
}
function showAllArchiveShows() {
   var all = document.getElementsByTagName('*');
   for(i=0; i<all.length; i++){
      if(all[i].className == 'archive_for_dj') all[i].style.display = 'block';
      if(all[i].hasClassName('archives_dj_link_active')) all[i].removeClassName('archives_dj_link_active');
   }
}

function mencheck()
{
  var el = document.getElementById('yearlist');
  var v = el.options[el.selectedIndex].value;

  var d = new Date();

  if(v<(d.getYear()+1900-25))
  {
      $('schooltr').style.display = "none";
      $('schooltr').value = "";
      $('companytr').style.display = "block";
  } else {
      $('schooltr').style.display = "block";
      $('companytr').style.display = "none";
      $('companytr').value = "";
    }
}

function goto2(el)
{
    var url = "index.php?mode=blog&do=changecat&catid="+el.options[el.selectedIndex].value;
    goto(url,'cont_data','');
}


function goto(url,divid,formid)
{
      _AdSidebar(true);
      if(formid!=null && formid!='')
      {
          new Ajax.Request('/'+url,
          {
            parameters: $(formid).serialize(),
            onSuccess: function(transport)
            {

               if(transport.responseText!="")
               {

                   if(transport.responseText.match(/You must be logged in/) || transport.responseText.match(/You can only/))
                   {
                       alert(transport.responseText);
                   } else if(transport.responseText.match(/Thank you for joining iTNT. Your account is not active yet. Please check your mailbox, and confirm your email address./))
                   {
                      $('cont_d2').update("<div style='color:#EB003F;font-weight:bold;text-align:center;padding:50px 0 200px;'>"+transport.responseText+"</div>");
                   } else {

                       $(divid).update(transport.responseText);

                     }

               } else { show_error_msg(1); }

            },
            onFailure: function(){show_error_msg(1);}
          }

         );

      } else {

          new Ajax.Request('/'+url,
          {
            onSuccess: function(transport)
            {

               if(transport.responseText!="")
               {

                   if(transport.responseText.match(/You must be logged in/) || transport.responseText.match(/You can only/))
                   {
                       alert(transport.responseText);
                   } else {

                       if(divid!=null && divid!='')
                       {
                          $(divid).update(transport.responseText);
                       } else {
                            $('cont_data').update(transport.responseText);
                         }

                     }

               } else { show_error_msg(1); }

            },
            onFailure: function(){show_error_msg(1);}
          }

         );
        }
}

function show_error_msg()
{
   alert("Server connection lost.");
}

function openvix() {
	window.open('http://www.vixlist.com', '_blank');
}

function check_reg_frm(frm)
{

	for (i = 0; i < frm.elements.length; i++) {
		oElem = frm.elements[i];
		if (oElem.type != "submit") {
			oElem.style.borderColor='';
		}
	}
	var error_field=document.getElementById('error');

	if (frm.username.value=='')
	{
		frm.username.style.borderColor='red';
		frm.username.focus();
		error_field.innerHTML = 'User Name is required.';
		return false;
	}

	if (frm.password.value=='')
	{
		frm.password.style.borderColor='red';
		frm.password.focus();
		error_field.innerHTML = 'Password is required.';
		return false;
	}

	if (frm.password.value!=frm.cpassword.value)
	{
		frm.password.style.borderColor='red';
		frm.password.focus();
		error_field.innerHTML = 'Password and Confirm Password must be the same.';
		return false;
	}

	if (frm.email.value!='')
	{
		var pattern = '^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$';
		if (!frm.email.value.match(new RegExp(pattern)))
		{
			frm.email.style.borderColor='red';
			frm.email.focus();
			error_field.innerHTML = "Invalid E-mail address format.";
			return false;
		}
	 }
	 else
	 {
			frm.email.style.borderColor='red';
			frm.email.focus();
			error_field.innerHTML = 'E-mail address is required.';
			return false;
	 }


	if (frm.firstname.value=='')
	{
		frm.firstname.style.borderColor='red';
		frm.firstname.focus();
		error_field.innerHTML = 'First Name is required.';
		return false;
	}

	if (frm.lastname.value=='')
	{
		frm.lastname.style.borderColor='red';
		frm.lastname.focus();
		error_field.innerHTML = 'Last Name is required.';
		return false;
	}

	if (frm.city.value=='')
	{
		frm.city.style.borderColor='red';
		frm.city.focus();
		error_field.innerHTML = 'City is required.';
		return false;
	}

	if (frm.phone.value=='')
	{
		frm.phone.style.borderColor='red';
		frm.phone.focus();
		error_field.innerHTML = 'Phone number is required.';
		return false;
	}

	if (!frm.agree.checked)
	{
		error_field.innerHTML = 'You must agree to the terms and conditions outlined in the Community Guideline.';
		return false;
	}

	return true;
}


function check_upd_frm1(frm)
{

	for (i = 0; i < frm.elements.length; i++) {
		oElem = frm.elements[i];
		if (oElem.type != "submit") {
			oElem.style.borderColor='';
		}
	}
	var error_field=document.getElementById('error');

	if (frm.password.value=='')
	{
		frm.password.style.borderColor='red';
		frm.password.focus();
		error_field.innerHTML = 'Password is required.';
		return false;
	}

	if (frm.password.value!=frm.cpassword.value)
	{
		frm.password.style.borderColor='red';
		frm.password.focus();
		error_field.innerHTML = 'Password and Confirm Password must be the same.';
		return false;
	}


	return true;
}


function check_upd_frm2(frm)
{

	for (i = 0; i < frm.elements.length; i++) {
		oElem = frm.elements[i];
		if (oElem.type != "submit") {
			oElem.style.borderColor='';
		}
	}
	var error_field=document.getElementById('error2');

	if (frm.firstname.value=='')
	{
		frm.firstname.style.borderColor='red';
		frm.firstname.focus();
		error_field.innerHTML = 'First Name is required.';
		return false;
	}

	if (frm.lastname.value=='')
	{
		frm.lastname.style.borderColor='red';
		frm.lastname.focus();
		error_field.innerHTML = 'Last Name is required.';
		return false;
	}

	if (frm.email.value!='')
	{
		var pattern = '^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$';
		if (!frm.email.value.match(new RegExp(pattern)))
		{
			frm.email.style.borderColor='red';
			frm.email.focus();
			error_field.innerHTML = "Invalid E-mail address format.";
			return false;
		}
	 }
	 else
	 {
			frm.email.style.borderColor='red';
			frm.email.focus();
			error_field.innerHTML = 'E-mail address is required.';
			return false;
	 }


	if (frm.city.value=='')
	{
		frm.city.style.borderColor='red';
		frm.city.focus();
		error_field.innerHTML = 'City is required.';
		return false;
	}

	if (frm.phone.value=='')
	{
		frm.phone.style.borderColor='red';
		frm.phone.focus();
		error_field.innerHTML = 'Phone number is required.';
		return false;
	}

	return true;
}

function check_com_frm(frm)
{


	for (i = 0; i < frm.elements.length; i++) {
		oElem = frm.elements[i];
		if (oElem.type != "submit") {
			oElem.style.borderColor='';
		}
	}
	var error_field=document.getElementById('error3');

	if (frm.elm1.value=='')
	{
		frm.elm1.style.borderColor='red';
		frm.elm1.focus();
		error_field.innerHTML = 'Comment is required.';
		return false;
	}


	return true;

}