/*
 
This JS makes my site work!!!!

*/


<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
//  End -->


<!--

 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 
 fadeThisBoxes = viewportwidth / 10;
//-->


$(document).ready(function(){
  
 /*Start jQuery Code*/

 
 var chjPortfolio = new ModernAccordion('portfolioContent');
                chjPortfolio.showItem(0);

$('#aboutCHJContainer').hide();
$('#contactCHJContainer').hide();
$('#thankYouMessage').hide();
$('#thankYouPayPalMessage').hide();
$('#portfolioContainer').hide();
$('#preLoad').hide();

$(".fadeThis").animate({ height: fadeThisBoxes }, 0);

$(".fadeThis").hover(function(){
$(this).fadeTo("slow", 0);
},function(){
$(this).fadeTo("slow", 1);
});


$('.chjLogo').click(function(){
$('#aboutCHJContainer').slideUp('slow');
$('#contactCHJContainer').slideUp('slow');
$('#portfolioContainer').fadeOut('slow');
})

$('.aboutMe').click(function(){
$('#aboutCHJContainer').slideDown('slow');
$('#contactCHJContainer').slideUp('slow');
$('#portfolioContainer').fadeOut('slow');
})
$('.portfolio').click(function(){
$('#aboutCHJContainer').slideUp('slow');
$('#contactCHJContainer').slideUp('slow');
$('#portfolioContainer').fadeIn('slow');
})
$('.contactMe').click(function(){
$('#contactCHJContainer').slideDown('slow');
$('#aboutCHJContainer').slideUp('slow');
$('#portfolioContainer').fadeOut('slow');
})


$(function() {
  $(".menu img").hover(function() {
    $(this).attr("src", $(this).attr("src").split(".").join("-hover."));
  }, function() {
    $(this).attr("src", $(this).attr("src").split("-hover.").join("."));
  });
});

/*End jQuery Code*/
});

function externalLinks() {

if (!document.getElementsByTagName) return;

var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
var relvalue = anchor.getAttribute("rel");

if (anchor.getAttribute("href")) {
var external = /external/;
var relvalue = anchor.getAttribute("rel");
if (external.test(relvalue)) { anchor.target = "_blank"; }
}
}
}
window.onload = externalLinks; 

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }