﻿// JScript File
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

matchColumns=function(){ 
     var divs,contDivs,maxHeight,divHeight,d; 
     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

     // initialize maximum height value 
     maxHeight=0; 

     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++){ 

          // make collection with <div> elements with class attribute 'container' 
          if(/\bcolumn\b/.test(divs[i].className)){ 
                d=divs[i]; 
                contDivs[contDivs.length]=d; 

                // determine height for <div> element 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                } 
                
                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     } 
} 

// Runs the script when page loads 

window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchColumns();			 
     } 
} 

function loadSlideShow(sPath) {
    var objSlideShow = document.getElementById('slideshowFrame');
    objSlideShow.src = sPath;
    objSlideShow.style.display = "block";
}

function PopWind(url, wwidth, wheight) {
	var positionX = (screen.width-wwidth)/2;
	var positionY = (screen.height-wheight)/2;	
	
	objWin = window.open(url,'SlideShow','top='+ positionY +', left='+ positionX +', width=' + wwidth + ', height=' + wheight + ', scrollbars=0,resizable=0,statue=0');
    objWin.focus();
}

function getVideo(videoPath) {
    document.write('<OBJECT ID="myVideo" style="z-index:-1000;" width="340" height="320" type="application/x-mplayer2">\n');
    document.write('<PARAM NAME="FileName" VALUE="' + videoPath + '">\n');
    document.write('<PARAM NAME="ShowControls" VALUE="True">\n');
    document.write('<PARAM NAME="ShowStatusBar" VALUE="True">\n');
    document.write('<PARAM NAME="TransparentAtStart" Value="True">\n');
    document.write('<PARAM NAME="AutoStart" Value="True">\n');
    document.write('<PARAM NAME="SendPlayStateChangeEvents" VALUE=True>\n');
    document.write('<PARAM NAME="AnimationatStart" Value="True">\n');
    document.write('<PARAM NAME="autoSize" Value="false">\n');
    document.write('<PARAM NAME="Wmode" Value="transparent">\n');
    document.write('<PARAM NAME="displaySize" Value="True">\n');
    document.write('<PARAM NAME="enableContextMenu" Value="False">\n');
    document.write('<PARAM NAME="uiMode" Value="invisible">\n');
    document.write('</OBJECT>');
}

function popVideo(videoPath) {
	var positionX = (screen.width - 340) / 2;
	var positionY = (screen.height - 340) / 2;	
	
    if (is_ie6up) {
    grayOut(true);
    var retValue = window.showModalDialog("/videos.aspx?videoPath=" + videoPath,"","dialogHeight: 340px; dialogWidth: 340px; dialogTop: " + positionY + " ; dialogLeft: " + positionX + "; edge: Raisen; center: Yes; resizable: No; status: No; scroll: no");
    grayOut(false);
    }
    else {
        winP = window.open("/videos.aspx?videoPath=" + videoPath,'Video','top=' + positionY + ', left=' + positionX + ', width=340, height=340,scrollbars=0,resizable=0');
        winP.focus();

        grayOut(true);
        var objP = parent.document.getElementById('mainContainer');
    }
//var retValue = window.showModalDialog("/videos.aspx?videoPath=" + videoPath,"","dialogHeight: 340px; dialogWidth: 340px; dialogTop: " + positionY + " ; dialogLeft: " + positionX + "; edge: Raisen; center: Yes; resizable: No; status: No; scroll: no");
}


function grayOut(vis, options) {
// Pass true to gray out screen, false to ungray
// options are optional. This is a JSON object with the following (optional) properties
// opacity:0-100 // Lower number = less grayout higher = more of a blackout 
// zindex: # // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx) // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order. Pass only the properties you need to set.
var options = options || {}; 
var zindex = options.zindex || 1;
var opacity = options.opacity || 50;
var opaque = (opacity / 100);
var bgcolor = options.bgcolor || '#000000';
var dark=document.getElementById('darkenScreenObject');
if (!dark) {
// The dark layer doesn't exist, it's never been created. So we'll
// create it here and apply some basic styles.
// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
var tbody = document.getElementsByTagName("body")[0];
var tnode = document.createElement('div'); // Create the layer.
tnode.style.position='absolute'; // Position absolutely
tnode.style.top='0px'; // In the top
tnode.style.left='0px'; // Left corner of the page
tnode.style.overflow='hidden'; // Try to avoid making scroll bars 
tnode.style.display='none'; // Start out Hidden
tnode.id='darkenScreenObject'; // Name it so we can find it later

tbody.appendChild(tnode); // Add it to the web page
dark=document.getElementById('darkenScreenObject'); // Get the object.
}
if (vis) {
// Calculate the page width and height 
if( document.body && ( document.body.scrollWidth || document.body.scrollHeight )) {
var pageWidth = document.body.scrollWidth+'px';
var pageHeight = document.body.scrollHeight + 1000 +'px';
} else if( document.body.offsetWidth ) {
var pageWidth = document.body.offsetWidth+'px';
var pageHeight = document.body.offsetHeight+'px';
} else {
var pageWidth='100%';
var pageHeight='100%';
} 
//set the shader to cover the entire page and make it visible.
dark.style.opacity=opaque; 
dark.style.MozOpacity=opaque; 
dark.style.filter='alpha(opacity='+opacity+')'; 
dark.style.zIndex=zindex; 
dark.style.backgroundColor=bgcolor; 
dark.style.width= pageWidth;
dark.style.height= pageHeight;
dark.style.display='block'; 
} else {
dark.style.display='none';
}
}

function grayOutFalse(vis) {
if (!is_ie6up) {
// Pass true to gray out screen, false to ungray
// options are optional. This is a JSON object with the following (optional) properties
// opacity:0-100 // Lower number = less grayout higher = more of a blackout 
// zindex: # // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx) // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order. Pass only the properties you need to set.
var options = options || {}; 
var zindex = options.zindex || 1;
var opacity = options.opacity || 50;
var opaque = (opacity / 100);
var bgcolor = options.bgcolor || '#000000';
var dark=window.opener.document.getElementById('darkenScreenObject');
if (!dark) {
// The dark layer doesn't exist, it's never been created. So we'll
// create it here and apply some basic styles.
// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
var tbody = window.opener.document.getElementsByTagName("body")[0];
var tnode = window.opener.document.createElement('div'); // Create the layer.
tnode.style.position='absolute'; // Position absolutely
tnode.style.top='0px'; // In the top
tnode.style.left='0px'; // Left corner of the page
tnode.style.overflow='hidden'; // Try to avoid making scroll bars 
tnode.style.display='none'; // Start out Hidden
tnode.id='darkenScreenObject'; // Name it so we can find it later
tbody.appendChild(tnode); // Add it to the web page
dark=window.opener.document.getElementById('darkenScreenObject'); // Get the object.
}
if (vis) {
// Calculate the page width and height 
if( window.opener.document.body && ( window.opener.document.body.scrollWidth || window.opener.document.body.scrollHeight ) ) {
var pageWidth = window.opener.document.body.scrollWidth+'px';
var pageHeight = window.opener.document.body.scrollHeight+'px';
} else if( window.opener.document.body.offsetWidth ) {
var pageWidth = window.opener.document.body.offsetWidth+'px';
var pageHeight = window.opener.document.body.offsetHeight+'px';
} else {
var pageWidth='100%';
var pageHeight='100%';
} 
//set the shader to cover the entire page and make it visible.
dark.style.opacity=opaque; 
dark.style.MozOpacity=opaque; 
dark.style.filter='alpha(opacity='+opacity+')'; 
dark.style.zIndex=zindex; 
dark.style.backgroundColor=bgcolor; 
dark.style.width= pageWidth;
dark.style.height= pageHeight;
dark.style.display='block'; 
} else {
dark.style.display='none';
}
}}

function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 5;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

	if (document.getElementById) {
	    div_obj = document.getElementById(this.div_name);
	    
	    if (div_obj) {
	        this.div_obj = div_obj;
	        /* alert(this.div_obj.offsetHeight);*/
	        /*if (this.div_obj.offsetHeight > 532) {
	         var nObj =	document.getElementById("scrollLong");
	         nObj.style.display = 'block';
	        }*/
	        
	        
	        this.div_obj.style.height = "526px";
	        this.div_obj.style.overflow = 'hidden'; 
	    }
	    
	    div_up_obj = document.getElementById(this.up_name);
	    div_dn_obj = document.getElementById(this.dn_name);
	    
	    if (div_up_obj && div_dn_obj) {
	        //div_up_obj.setAttribute("onmouseover", scrollname + ".scrollUp();")
	        //div_up_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
	
			//div_dn_obj.setAttribute("onmouseover", scrollname + ".scrollDown();")
	        //div_dn_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
	        div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
			div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
			div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
			div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
	    }
	}

	this.stopScroll = function() {
	        clearTimeout(this.timeoutID);
	    }
	
	this.scrollUp = function() {
	        if (this.div_obj) {
	           this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
	           
	            this.div_obj.scrollTop = this.scrollCursor;
	            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
	        }
	        
	    }
	
	this.scrollDown = function() {
		if (this.div_obj) {
			this.scrollCursor += this.speed;
			this.div_obj.scrollTop = this.scrollCursor;
		   
		    if (this.div_obj.scrollTop == this.scrollCursor) {
				this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
			} 
			else {
				this.scrollCursor = this.div_obj.scrollTop;
			}
		}
	}

	this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
	}
}

function openWin() {
	var positionX = (screen.width - 340) / 2;
	var positionY = (screen.height - 340) / 2;	
	
    winP = window.open("http://ediamondselect.com/ConsumerSearch.aspx?UserID=533",'Video','top=' + positionY + ', left=' + positionX + ', width=900, height=900,scrollbars=1,resizable=0');
    winP.focus();
}

