//this is to convert hex to rgb if the skin configuration is run
function HexToR(h) { return parseInt((cutHex(h)).substring(0, 2), 16) }
function HexToG(h) { return parseInt((cutHex(h)).substring(2, 4), 16) }
function HexToB(h) { return parseInt((cutHex(h)).substring(4, 6), 16) }
function cutHex(h) { return (h.charAt(0) == "#") ? h.substring(1, 7) : h }



 function includeCSS(p_file) {
        var v_css = document.createElement('link');
        v_css.rel = 'stylesheet'
        v_css.type = 'text/css';
        v_css.href = p_file;
        document.getElementsByTagName('head')[0].appendChild(v_css);
}


$(document).ready(function () {

         $(".tagcloud a").hover(function(){
          normal = $(this).css("background");
          $(this).css({
            'padding' : '4px 6px',
            'margin-bottom' : '-3px',
            'margin-top' : '-3px',
            'background' : 'rgba(54, 136, 175, 1)'
          })
        }, function(){
          $(this).css({
            'padding' : '1px 6px',
            'margin' : '4px 1px',
            'background' : normal
          })
        });
  $("a[rel^='prettyPhoto']").prettyPhoto({show_title:false});
$('#featuredHeaders').cycle({ 
    fx:     'fade', 
    speed:  'slow',
    next:   '#nextButtonClick', 
    prev:   '#prevButtonClick',
timeout: 6000
});
 

          // was using :before psuedo selectors but IE9 decided it didn't want to apply border-radius pseudo elements :(
        $("li.current").append("<span class=\"marker\"></span>");

});

function subscribe() {
 fname = document.getElementById("fName").value;
  lname = document.getElementById("lName").value;
  email = document.getElementById("email").value;

  $('#signupMessage').fadeOut('slow', function() {
    
  if (fname == ""  || email == "") {
    document.getElementById("signupMessage").innerHTML =  "<p>Please provide a name and email address before proceeding.</p>";
    $('#signupMessage').fadeIn('slow', function() {
        // Animation complete.
       });
   // alert("Please complete both fields before proceeding.");
  } else {
    if (validateEmail(email)) {
     document.getElementById("signupMessage").innerHTML = "<p><img src='prettyPhoto/images/prettyPhoto/dark_square/loader.gif' /></p>";
   $('#signupElements').fadeOut('slow', function() {
    // Animation complete.
      });
      document.getElementById("signUp").innerHTML = "<h3 style='margin-top:7px;margin-bottom:10px;'>Thank you for Subscribing</h3>";
     
      xmlhttp.send();
    } else {
      document.getElementById("signupMessage").innerHTML =  "<p>Please provide a valid email address before proceeding.</p>";
      $('#signupMessage').fadeIn('slow', function() {
        // Animation complete.
       });
         }
  }
      });
 
     
  if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
  } else {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
       if (xmlhttp.responseText == "success") {
    
     
    } else {
        document.getElementById("signupElements").innerHTML = "";
    $('#signupElements').fadeIn('slow', function() {
    // Animation complete.
      });
    }
     // document.getElementById("newsLetterResult").innerHTML = xmlhttp.responseText;
      //$("a[rel^='prettyPhoto']").prettyPhoto();
    }
  }
      
      xmlhttp.open("GET","/scripts/subscribe.php?fName="+fname+"&lName="+lname+"&email="+email,true);
}
function contestSignup() {
  fname = document.getElementById("cFName").value;
  lname = document.getElementById("cLName").value;
  email = document.getElementById("cEmail").value;
  phone = document.getElementById("cPhone").value;
  cID = document.getElementById("cID").value;
  
  $('#warningMessage').fadeOut('slow', function() {
    
  if (fname == ""  || email == "") {
    document.getElementById("warningMessage").innerHTML =  "<p>Please provide a name and email address before proceeding.</p>";
    $('#warningMessage').fadeIn('slow', function() {
        // Animation complete.
       });
   // alert("Please complete both fields before proceeding.");
  } else {
    if (validateEmail(email)) {
     document.getElementById("warningMessage").innerHTML = "<p><img src='prettyPhoto/images/prettyPhoto/dark_square/loader.gif' /></p>";
   $('#warningMessage').fadeOut('slow', function() {
    // Animation complete.
      });
      document.getElementById("warningMessage").innerHTML = "<p class='newsItemTitle'>Thank you for Signing up!</p>";
     
      xmlhttp.send();
    } else {
      document.getElementById("warningMessage").innerHTML =  "<p>Please provide a valid email address before proceeding.</p>";
      $('#warningMessage').fadeIn('slow', function() {
        // Animation complete.
       });
         }
  }
      });
 
     
  if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
  } else {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    
    if (xmlhttp.responseText == "success") {
    $('#warningMessage').fadeIn('slow', function() {
    // Animation complete.
      });
     document.getElementById("enterButton").style.display="none";
    } else {
        document.getElementById("warningMessage").innerHTML = "Your entry could not be processed at this time. Please try again later.";
    $('#warningMessage').fadeIn('slow', function() {
    // Animation complete.
      });
    }
     // document.getElementById("newsLetterResult").innerHTML = xmlhttp.responseText;
      //$("a[rel^='prettyPhoto']").prettyPhoto();
    }
  }
      
      xmlhttp.open("GET","/scripts/contestsignup.php?fName="+fname+"&lName="+lname+"&email="+email+"&phone="+phone+"&cID="+cID,true);
}
function validateEmail(elementValue){  
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
    return emailPattern.test(elementValue);  
 }

function menuControl(who) {
  position = who.split("_")[1];
 $('#featuredHeaders').cycle('pause'); 
  for (i=1;i<8;i++) {
     document.getElementById("header_"+i).style.display = "none";
     document.getElementById("header_"+i).style.opacity = "0";
  }
  document.getElementById("header_"+position).style.display = "block";
  document.getElementById("header_"+position).style.opacity = "1";
}
function menuControlOff() {
    $('#featuredHeaders').cycle('resume'); 
}







