// JavaScript Document
var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_validateContactForm() { //v4.0
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateContactForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; if (nm == "cFirstName" && val.value == 'First Name') { val.value = "";} else { if (nm == "cLastName" && val.value == 'Last Name') { val.value = "";}  else { if (nm == "cPhone" && val.value == 'Phone') { val.value = "";}}}if ((vVal=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=vVal.indexOf('@');
        if (p<1 || p==(vVal.length-1)) errors+='- '+nd+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(vVal);
        if (isNaN(vVal)) errors+='- '+nd+' 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+='- '+nd+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nd+' is required.\n'; 
	if ( nm == "cFirstName" && val.value == '') {val.value = "First Name";} if (nm == "cLastName" && val.value == '') { val.value = "Last Name";} if (nm == "cPhone" && val.value == '') { val.value = "Phone";} }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
 	document.MM_returnValue = (errors == '');
  	document.cForm.action = "contact-us.cfm?sID=1";
}

function MM_validateOfferForm() { //v4.0
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateOfferForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; if (nm == "cFirstName" && val.value == 'First Name') { val.value = "";} else { if (nm == "cLastName" && val.value == 'Last Name') { val.value = "";}  else { if (nm == "cPhone" && val.value == 'Phone') { val.value = "";}}}if ((vVal=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=vVal.indexOf('@');
        if (p<1 || p==(vVal.length-1)) errors+='- '+nd+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(vVal);
        if (isNaN(vVal)) errors+='- '+nd+' 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+='- '+nd+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nd+' is required.\n'; 
	if ( nm == "cFirstName" && val.value == '') {val.value = "First Name";} if (nm == "cLastName" && val.value == '') { val.value = "Last Name";} if (nm == "cPhone" && val.value == '') { val.value = "Phone";} }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
 	document.MM_returnValue = (errors == '');
  	document.oForm.action = "offer.cfm?sID=1";
}

function MM_validateRecoveryForm() { //v4.0
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateRecoveryForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; if (nm == "cFirstName" && val.value == 'First Name') { val.value = "";} else { if (nm == "cLastName" && val.value == 'Last Name') { val.value = "";}  else { if (nm == "cPhone" && val.value == 'Phone') { val.value = "";}}}if ((vVal=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=vVal.indexOf('@');
        if (p<1 || p==(vVal.length-1)) errors+='- '+nd+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(vVal);
        if (isNaN(vVal)) errors+='- '+nd+' 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+='- '+nd+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nd+' is required.\n'; 
	if ( nm == "cFirstName" && val.value == '') {val.value = "First Name";} if (nm == "cLastName" && val.value == '') { val.value = "Last Name";} if (nm == "cPhone" && val.value == '') { val.value = "Phone";} }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
 	document.MM_returnValue = (errors == '');
  	document.rForm.action = "backup-disaster-recovery.cfm?sID=1";
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nd+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nd+' 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+='- '+nd+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nd+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function testCreditCard () {
  var myCardNo = MM_findObj('ccNumber').value;
  var myCardType = MM_findObj('ccType').value;
  if (checkCreditCard(myCardNo,myCardType)) {
    $(MM_findObj('ccNumber')).removeClass("error");
  } 
  else {
	 alert (ccErrors[ccErrorNo]);
  	$(MM_findObj('ccNumber')).addClass("error");
  }
}

var topmenu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

var thisPage = document.URL.substring(document.URL.lastIndexOf("/")+1 ,document.URL.length);
thisPage = thisPage.substring(0 ,thisPage.lastIndexOf("."));

$(document).ready(function(){
	//Nifty("div#fsbtLeft,div#fsbtRight", "none same-height");
	
	

	if(thisPage  == "index" || thisPage == '') {
		
		$(".tTabs:first").tabs("#tContent:first > div", { effect: 'fade', fadeOutSpeed: "slow", rotate: true }).slideshow({ autoplay: true, interval: 6000  });
		$(".offerBox").colorbox({iframe:true, innerWidth:550, innerHeight:550});
	}
	

	if(thisPage == "contact") {
		setTimeout("initialize()",500);
	}
	
	
	$(".dellBox").colorbox({iframe:true, innerWidth:750, innerHeight:570});
	
	
});

