/****************************************
* Copyright 2006 Ex-designz.net
* JavaScript written by: Dexter Zafra
* Location: Norwalk, CA., USA
****************************************/
//Check browser version
function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();
//Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

//Handle onchange clear fields in the Homepage Freeware and Link Directory search fields
function clearDefault(el) 
{
  if (el.defaultValue==el.value) el.value = ""
}

// Handle Today in History remote Form submit open in popup window
function popup() 
{
  var NewWind = window.open( '','remote', 'width=900,height=700,scrollbars=yes,resizable=yes');
   if (NewWind.opener == null) 
  {
   NewWind.opener = window;
  }
}

// Handle Today in History open link in pop-up window
function openWin3(url) 
{
popupWin = window.open(url,'new_page','width=600,height=560,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,left=260,top=120')
}

function openWinVid(url) 
{
popupWin = window.open(url,'new_page','width=540,height=490,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,left=260,top=120')
}

//Open member profile
function Start(page) {
OpenWin = this.open(page,'CtrlWindow', 'width=800,height=600,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes')
}

// Handle HD2 Radio Stations pop-up window player
function win1() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:45849.asx?bkup=45850&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win2() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:46078.asx?bkup=46079&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win3() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:45887.asx?bkup=45888&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win4() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://a1401.l2187555833.c21875.n.lm.akamaistream.net/D/1401/21875/v0001/reflector:55833','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win5() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:46491.asx?bkup=46492&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win6() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:46017.asx?bkup=46018&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win7() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:46065.asx?bkup=46067&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win8() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:46007.asx?bkup=46008&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win9() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:45885.asx?bkup=45886&prop=n','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win10() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:45933.asx?bkup=45935&prop=n&currPos=43','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}
function win11() 
{
window.open('http://www.clearchannelmusic.com/cc-common/hdradio/player1.html?thestation=http://mfile.akamai.com/21875/live/reflector:45845.asx?bkup=45846&prop=n&currPos=53','playerWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=416,height=264');
return false;
}

//Handle Homepage login and logout window
function getposOffset(overlay, offsettype) 
  {
    var totaloffset=(offsettype=="right")? overlay.offsetLeft : overlay.offsetTop;
    var parentEl=overlay.offsetParent;
    while (parentEl!=null)
     {
       totaloffset=(offsettype=="right")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
       parentEl=parentEl.offsetParent;
    }
      return totaloffset;
}
function overlay(curobj, subobj)
  {
    if (document.getElementById)
        {
          var subobj=document.getElementById(subobj)
          subobj.style.left=getposOffset(curobj, "left")+"px"
          subobj.style.top=getposOffset(curobj, "top")+"px"
          subobj.style.display="block"
          return false
       }
   else
         return true
}
function overlayclose(subobj)
  {
    document.getElementById(subobj).style.display="none"
}

//Create XMLHTTP object
 var http = createRequestObject();
 function createRequestObject() 
     {           
           var xmlhttp;
	 try 
                 { 
                    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
                 }
	  catch(e) 
                 {
	    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	    catch(f) { xmlhttp=null; }
	    }
	        if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
                        {
	  	   xmlhttp=new XMLHttpRequest();
	           }
		  return  xmlhttp;
 }

//Handle XMLHTTP request lost password
function sendRequestTextPost() 
  {  
    var rnd = Math.random();
    var email = escape(document.getElementById("email").value);
       if ((email =="") || (!(email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)))
          {        
             document.getElementById('email').style.backgroundColor='#FFF4F4';
             document.getElementById('email').style.border = '1px solid #CC0000';
             document.getElementById('empass').innerHTML = 'Invalid:';
             document.getElementById('empass').style.color = '#cc0000';
             document.getElementById('email').focus();
             return false;
          }
     else
         {
            try
              {
                 http.open('POST',  'getpasswordhp.asp');
                 http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                 http.onreadystatechange = handleResponseText;
	    http.send('email='+email+'&rnd='+rnd);
	 }
	    catch(e){}
	    finally{}
        }
  }
function handleResponseText() 
  {  
     document.getElementById('prog').innerHTML="<br><img src='loadingemail.gif'> Loading..."; 
     try
         {
             if((http.readyState == 4)&& (http.status == 200))
                 {                
    	        var response = http.responseText;
                     document.getElementById("idforresults").innerHTML = response;                                    
                     document.getElementById("resultcont").style.display='block';
                     document.getElementById('showemail').style.display='none';
                     document.getElementById('prog').innerHTML="";
	    }
        }
	catch(e){alert("an error occured");}
	finally{}
}
function UNameFocus()
   {
      document.getElementById('Name').style.backgroundColor = '#FFF9EC';
      document.getElementById('showemail').style.display='none';
}
function EmailKeyDown()
   {
      document.getElementById('email').style.backgroundColor='#FFF9EC';
      document.getElementById('email').style.border = '1px solid #B9CFE1';
      document.getElementById('empass').innerHTML = 'Email:';
      document.getElementById('empass').style.color = '#000000';
}
function UnameonBlur()
  {
     document.getElementById('Name').style.backgroundColor = '#FFF9EC';
     document.getElementById('Name').style.backgroundColor = '#FFFFFF';  
     document.getElementById('Name').style.border = '1px solid #B9CFE1';
     document.getElementById('lblname').style.color = '#005EBB';
     document.getElementById('lblname').innerHTML = 'Username:';
 }
function PasswordonBlur()
  {
     document.getElementById('Password').style.backgroundColor = '#FFF9EC';
     document.getElementById('Password').style.backgroundColor = '#FFFFFF';  
     document.getElementById('Password').style.border = '1px solid #B9CFE1';
     document.getElementById('lblpass').style.color = '#005EBB';
     document.getElementById('lblpass').innerHTML = 'Password:';
 }
//Handle login validation
function LoginValidate()
   {    
         var Uname = document.getElementById('Name').value;
         var Upass = document.getElementById('Password').value;
        if (Uname =="" && Upass =="")
           {
             document.getElementById('showemail').style.display='block';
             document.getElementById('Name').style.backgroundColor='#FFF4F4';
             document.getElementById('Name').style.border = '1px solid #CC0000';
             document.getElementById('lblname').innerHTML = 'Empty:';
             document.getElementById('lblname').style.color = '#cc0000';
             document.getElementById('Password').style.backgroundColor='#FFF4F4';
             document.getElementById('Password').style.border = '1px solid #CC0000';
             document.getElementById('lblpass').innerHTML = 'Empty:';
             document.getElementById('lblpass').style.color = '#cc0000';
             return false;
           }
        if (Uname =="")
            {
              document.getElementById('Name').style.backgroundColor='#FFF4F4';
              document.getElementById('Name').style.border = '1px solid #CC0000';
              document.getElementById('lblname').innerHTML = 'Empty:';
              document.getElementById('lblname').style.color = '#cc0000';
              return false;
            }
        if (Upass =="")
            {
              document.getElementById('Password').style.backgroundColor='#FFF4F4';
              document.getElementById('Password').style.border = '1px solid #CC0000';
              document.getElementById('lblpass').innerHTML = 'Empty:';
              document.getElementById('lblpass').style.color = '#cc0000';
              return false;
            }
              return true;        
 }

// Handle email password form hide and unhide
window.onload = function()
 {
  if(document.getElementById)
   {
     document.getElementById('showemail').style.display='none';
     var linkContainer = document.getElementById('pshow');
     //var linebreak = linkContainer.appendChild(document.createElement('br'));
     var toggle = linkContainer.appendChild(document.createElement('a'));
     toggle.href = '#';
     toggle.appendChild(document.createTextNode(' Forgot password?'));

   toggle.onclick = function()
    {
      var linkText = this.firstChild.nodeValue;
      this.firstChild.nodeValue = (linkText == ' Forgot password?') ? ' Forgot password?' : ' Forgot password?';

      var tmp = document.getElementsByTagName('div');
      document.getElementById('email').style.backgroundColor='#FFF9EC';
      document.getElementById('email').style.border = '1px solid #B9CFE1';
      document.getElementById('empass').innerHTML = 'Email:';
      document.getElementById('empass').style.color = '#000000';
      document.getElementById('showemail').style.display='block';
      document.getElementById('resultcont').style.display='none';
      document.getElementById('email').value="";
     return false;
    }
  }
}

//Handle newest article tabs XMLHTTP request
function sndTabsContent(url,num) 
  {         
            if (num == 1)
                {
                     document.getElementById('tab3').className ='atabs';
                     document.getElementById('tab7').className ='atabs';
                     document.getElementById('tab1').className ='atabsel';
                }

           else if (num == 3)
                  {
                   document.getElementById('tab1').className ='atabs';
                   document.getElementById('tab7').className ='atabs';
                   document.getElementById('tab3').className ='atabsel';
                 }
           else if (num == 7)
                  {
                   document.getElementById('tab1').className ='atabs';
                   document.getElementById('tab3').className ='atabs';
                   document.getElementById('tab7').className ='atabsel';
                 }
	   
                var gettabs = document.getElementById('tabscon');
                gettabs.innerHTML = "<img src='loadingemail.gif'> Loading...";

               try
                  {
                     http.open('GET', url, true);
                     http.onreadystatechange = getTabsConResponse;
	        http.send(null);
	    }
	    catch(e){}
	    finally{}
 }
function getTabsConResponse() 
  {
     try
         {
             if((http.readyState == 4)&& (http.status == 200))
                {
    	          var responsetabscon = http.responseText;
                       document.getElementById('tabscon').innerHTML = responsetabscon;
                       document.getElementById('tabscon').style.display='block';                 
	        }
        }
	catch(e){alert("an error occured");}
	finally{}
}

//Handle news tabs XMLHTTP request
function sndTabsNews(addr,numtab) 
  {         
           if (numtab == 4)
                {
                    document.getElementById('tab5').className ='ntabs';
                    document.getElementById('tab6').className ='ntabs';
                    document.getElementById('tab4').className ='ntabsel'; 
                }
           else if (numtab == 5)
                {
                   document.getElementById('tab4').className ='ntabs';
                   document.getElementById('tab6').className ='ntabs';
                   document.getElementById('tab5').className ='ntabsel';
                 }
           else if (numtab == 6)
                  {
                   document.getElementById('tab5').className ='ntabs';
                   document.getElementById('tab4').className ='ntabs';
                   document.getElementById('tab6').className ='ntabsel'; 
                 }
	var getnewstab = document.getElementById('newscont');
             getnewstab.innerHTML = "<img src='loadingemail.gif'> Loading...";

            try
              {
                 http.open('GET', addr, true);
                 http.onreadystatechange = getTabsNewsResponse;
	    http.send(null);
	 }
	    catch(e){}
	    finally{}
 }
function getTabsNewsResponse() 
  {
     try
         {
             if((http.readyState == 4)&& (http.status == 200))
                {
    	          var responsenewstabs = http.responseText;
                       document.getElementById('newscont').innerHTML = responsenewstabs;
                       document.getElementById('newscont').style.display='block';                 
	        }
        }
	catch(e){alert("an error occured");}
	finally{}
}

//Handle switch view member profile XMLHTTP request
function sndMostActivepro() 
  {         
             document.getElementById('spro').style.display='none';
             document.getElementById('mostactive').style.display='block';
            	var getmostactive = document.getElementById('mostactive');
             getmostactive.innerHTML = "<img src='loadingemail.gif'> Loading...";
            try
              {
                 http.open('GET', 'hpmostactiveprofiles.asp');
                 http.onreadystatechange = getMactiveResponse;
	    http.send(null);
	 }
	    catch(e){}
	    finally{}
 }
function getMactiveResponse() 
  {
     try
         {
             if((http.readyState == 4)&& (http.status == 200))
                {
    	          var responsemactive = http.responseText;
                       document.getElementById('mostactive').innerHTML = responsemactive;
                       document.getElementById('mostactive').style.display='block'; 
                       document.getElementById('sw2').style.display='block';
                       document.getElementById('sw1').style.display='none';              
	        }
        }
	catch(e){alert("an error occured");}
	finally{}
}

//Handle show video
function sndShowVideo(vidid) 
  {         
             document.getElementById('vidcat').style.display='none';
             document.getElementById('vidshow').style.display='block';
            	var getvideo = document.getElementById('vidshow');
             getvideo.innerHTML = "<img src='loadingemail.gif'> Please wait video is loading...";
            try
              {
                 http.open('GET', 'hpvideodisplay.asp?id='+vidid);
                 http.onreadystatechange = getVideoResponse;
	    http.send(null);
	 }
	    catch(e){}
	    finally{}
 }
function getVideoResponse() 
  {
     try
         {
             if((http.readyState == 4)&& (http.status == 200))
                {
    	          var responsevideoshow = http.responseText;
                       document.getElementById('vidshow').innerHTML = responsevideoshow;
                       document.getElementById('vidshow').style.display='block';               
	        }
        }
	catch(e){alert("an error occured");}
	finally{}
}

function switchmprofile()
 {
             document.getElementById('spro').style.display='block';
             document.getElementById('mostactive').style.display='none';
             document.getElementById('sw1').style.display='block';
             document.getElementById('sw2').style.display='none';
}

function vidclose()
 {
             document.getElementById('vidcat').style.display='block';
             document.getElementById('vidshow').style.display='none';
}