﻿// Month Array
var months = new Array(13);
months[0]  = "January";
months[1]  = "February";
months[2]  = "March";
months[3]  = "April";
months[4]  = "May";
months[5]  = "June";
months[6]  = "July";
months[7]  = "August";
months[8]  = "September";
months[9]  = "October";
months[10] = "November";
months[11] = "December";

// Drop-down menu
function ddMenu(parent, control, showhide) {

    var moveextra = 10;
    
    if (showhide == 'show') {
    
        var picheight = Sys.UI.DomElement.getBounds(document.getElementById('ctl00_img_' + parent));
        Sys.UI.DomElement.setLocation(document.getElementById('ctl00_' + control), 10, picheight.y + document.getElementById('ctl00_img_' + parent).clientHeight);
    
        document.getElementById('ctl00_img_' + parent).src = "images/btn_" + parent + "_ro.jpg";
        document.getElementById('ctl00_' + control).style.display = "block";

    } else {
    
        document.getElementById('ctl00_' + control).style.display = "none";
        
        if (document.getElementById('ctl00_img_' + parent).onmouseover != null) {
            document.getElementById('ctl00_img_' + parent).src = "images/btn_" + parent + ".jpg";
        }

    }

}

// Check height of page content for side shadows
function checkheight() {
    var contentheight = document.getElementById("content").clientHeight + "px";
    
    if (document.getElementById("leftshadow") != null) {
        document.getElementById("leftshadow").style.height = contentheight;
    }

    if (document.getElementById("rightshadow") != null) {
        document.getElementById("rightshadow").style.height = contentheight;
    }
    
    checkcandyheight();
    renderdone();
}

// Check height of some candy pieces content for height of left/right sides
function checkcandyheight() {

    var contentheight = "0px";
    
    // Results
    if (document.getElementById("results_midtext") != null) {
        contentheight = document.getElementById("results_midtext").clientHeight + "px";
        document.getElementById("results_left").style.height = contentheight;
        document.getElementById("results_right").style.height = contentheight;
    }

    // Testimonials
    if (document.getElementById("testies_mid") != null) {
        contentheight = document.getElementById("testies_mid").clientHeight + "px";
        document.getElementById("testies_left").style.height = contentheight;
        document.getElementById("testies_right").style.height = contentheight;
    }
    
    // Now Hiring
    if (document.getElementById("hiring_midtext") != null) {
        contentheight = document.getElementById("hiring_midtext").clientHeight + "px";
        document.getElementById("hiring_left").style.height = contentheight;
        document.getElementById("hiring_right").style.height = contentheight;
    }
    
    // News
    if (document.getElementById("news_midtext") != null) {
        contentheight = document.getElementById("news_midtext").clientHeight + "px";
        document.getElementById("news_left").style.height = contentheight;
        document.getElementById("news_right").style.height = contentheight;
    }

}

// Track clicks for candy/main events/links/testimonials/results/news/careers
function trackclick(poo, stain, pid, ctype, cid) {

	if (window.XMLHttpRequest) {
		xmlHttp=new XMLHttpRequest();		
	} else if (window.ActiveXObject) {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");		
	}
			
	var dt = new Date();
	var ms = dt.getMilliseconds();
	var dtms = dt + ":" + ms;
	var openpage = "clicks.aspx?t88ky@32n=" + poo + "&uw81nh=" + stain + "&pid=" + pid + "&ctype=" + ctype + "&cid=" + cid + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	xmlHttp.send(null);
	
}		

// Track the video if watched or finished
function trackvideo(poo, stain, pid, vid, vtype, nvid) {

	if (window.XMLHttpRequest) {
		xmlHttp=new XMLHttpRequest();		
	} else if (window.ActiveXObject) {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");		
	}
			
	var dt = new Date();
	var ms = dt.getMilliseconds();
	var dtms = dt + ":" + ms;
	var openpage = "videos.aspx?t88ky@32n=" + poo + "&uw81nh=" + stain + "&pid=" + pid + "&vid=" + vid + "&vtype=" + vtype + "&nvid=" + nvid + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	
	if (vtype == "watch") {
        xmlHttp.onreadystatechange = onSumResponse;
    }
        
	xmlHttp.send(null);
	
}

function onSumResponse() {

    if (xmlHttp.readyState == 4) {
        var serverResponse = xmlHttp.responseText;
      	var flash = window.document.vid
        flash.setvidid_js(serverResponse);  
    }
    
}

// Switch video when button is clicked
function switchvid(vidname, vid_id) {
    //alert(window.document.vid);
	//if (navigator.appName.indexOf("Microsoft") != -1) {
    	//var flash = window.vid;
    //} else {
      	var flash = window.document.vid
    //}
    flash.switchvid_js(vidname, vid_id);
}

// Pop new window
function popit(url, name, w, h) {
	var winl = (screen.width-w)/2;
	if (winl < 0) winl = 0;
	
	popwin = window.open(url, name, "width=" + w + ",height=" + h + ",toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,top=0,left=" + winl);
	popwin.focus();
}

function poplink(url,name) {
  
	popwin = window.open(url,name);
	popwin.focus();
}

// Start video on main event (if applicable) when page is fully rendered. This should help out with page load lag
function renderdone() {
    //alert(window.document.MainEvent);
   	var flash = window.document.MainEvent
   	
   	if (flash != null) {
        flash.renderdone_js();
    }
}
