//function for "Popup Window"

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function LoadNewWindowFull(link,windowName,vWinWidth,vWinHeight){
	var vScreenWidth = screen.width;
	var vScreenHeight= screen.height;
	var vSetLeft;
	var vSetTop;
	if(vWinWidth == "100%"){
		vWinWidth = vScreenWidth -16;
		vSetLeft= 0;
	}else{
		vWinWidth 
		vSetLeft= (vScreenWidth/2) - (vWinWidth/2);
	}
	if(vWinHeight == "100%"){
		vSetTop = 0;
		vWinHeight= vScreenHeight-60;
	}
	else{
		//vWinHeight = vScreenHeight - vOffsetStatMenu;
		//vSetTop = vOffsetMenuBar;
		vSetTop = (vScreenHeight/2) - (vWinHeight/2);
	}
	newWindow = window.open(link,windowName,"location=no,menubar=no,toolbar=no,status=no,width="+ vWinWidth +",height="+ vWinHeight+", top="+ vSetTop + ", left=" + vSetLeft +"resizable=no,scrollbars=no");
	return newWindow;
	
}

function LoadNewWindowFullWithoutStatusBar(link,windowName,vWinWidth,vWinHeight)
{
	var vScreenWidth = screen.width;
	var vScreenHeight= screen.height;
	var vSetLeft;
	var vSetTop;
	if(vWinWidth == "100%"){
		vWinWidth = vScreenWidth -16;
		vSetLeft= 0;
	}else{
		vWinWidth 
		vSetLeft= (vScreenWidth/2) - (vWinWidth/2);
	}
	if(vWinHeight == "100%"){
		vSetTop = 0;
		vWinHeight= vScreenHeight-60;
	}
	else{
		//vWinHeight = vScreenHeight - vOffsetStatMenu;
		//vSetTop = vOffsetMenuBar;
		vSetTop = (vScreenHeight/2) - (vWinHeight/2);
	}
	newWindow = window.open(link,windowName,"location=no,menubar=no,toolbar=no,status=no,width="+ vWinWidth +",height="+ vWinHeight+", top="+ vSetTop + ", left=" + vSetLeft +"resizable=no,scrollbars=no");
	return newWindow;
	
}

function LoadNewWindowResize(link,windowName,vWinWidth,vWinHeight){
	var vScreenWidth = screen.width;
	var vScreenHeight= screen.height;
	var vSetLeft;
	var vSetTop;
	if(vWinWidth == "100%"){
		vWinWidth = vScreenWidth -16;
		vSetLeft= 0;
	}else{
		vWinWidth 
		vSetLeft= (vScreenWidth/2) - (vWinWidth/2);
	}
	if(vWinHeight == "100%"){
		vSetTop = 0;
		vWinHeight= vScreenHeight-60;
	}
	else{
		//vWinHeight = vScreenHeight - vOffsetStatMenu;
		//vSetTop = vOffsetMenuBar;
		vSetTop = (vScreenHeight/2) - (vWinHeight/2);
	}
	newWindow = window.open(link,windowName,"location=no,menubar=no,toolbar=no,status=no,width="+ vWinWidth +",height="+ vWinHeight+", top="+ vSetTop + ", left=" + vSetLeft +" resizable=yes, scrollbars=yes");
	return newWindow;
	
}

function LoadNewWindow(link,windowName,vWinWidth,vWinHeight,vScroll){
	var vScreenWidth = screen.width;
	var vScreenHeight= screen.height;
	var vSetLeft;
	var vSetTop;
	if(vWinWidth == "100%"){
		vWinWidth = vScreenWidth -16;
		vSetLeft= 0;
	}else{
		vWinWidth 
		vSetLeft= (vScreenWidth/2) - (vWinWidth/2);
	}
	if(vWinHeight == "100%"){
		vWinHeight = vScreenHeight - vOffsetMenuBar - vOffsetStatMenu;
		vSetTop = vOffsetMenuBar;
	}else if(vWinHeight < 600){
//		vWinHeight;
		vSetTop = vOffsetMenuBar;
		//vSetTop = (vScreenHeight/2) - (vWinHeight/2);
	}else{
		vWinHeight = vScreenHeight - vOffsetStatMenu;
		vSetTop = vOffsetMenuBar;
		//vSetTop = (vScreenHeight/2) - (vWinHeight/2);
	}
	if(vScroll=="no"){
				newWindow = window.open(link,windowName,"location=no,menubar=no,toolbar=no,status=no,width="+ vWinWidth +",height="+ vWinHeight+", top="+ vSetTop + ", left=" + vSetLeft +"resizable=yes,scrollbars=no");		
	}
	else if(vScroll=="yes"){
		newWindow = window.open(link,windowName,"location=no,menubar=no,toolbar=no,status=no,width="+ vWinWidth +",height="+ vWinHeight+", top="+ vSetTop + ", left=" + vSetLeft +" resizable=yes, scrollbars=yes");
	}
	return newWindow;
	
}

//function for "ResetPassword.htm"
function hideDiv() {
	if ((document.getElementById('txtDomain').value=='')||(document.getElementById('txtUserName').value=='')||(document.getElementById('txtEmail').value=='' )) { 
		document.getElementById('lblTxtmsg').style.visibility = 'visible';
	}
	else {
		document.getElementById('lblTxtmsg').style.visibility = 'hidden';
		window.close();
		LoadNewWindowFull('resetClose.htm','resetClose', 500,250);
	}
}

// Submit data file Enable 

function checked(){
	document.getElementById('sdiFile').checked=true
}

//function for "Benchmark Wizard"

var ddBenchmarkCalculation;
function selectDateSource(){
	if(document.getElementById('optDataSource1').checked==true){
   		//ddBenchmarkCalculation = 5;
		createCookie(ddBenchmarkCalculation,5,500);
		
		window.close();
		LoadNewWindowFull('bwDefineCalculation.htm','bwDefineCalculation', 740,280);
   }
   else if(document.getElementById('optDataSource2').checked==true){
	   window.close();
	   LoadNewWindowResize('bwEnteringTargetValues.htm','bwEnteringTargetValues', 650,510);
   }
   else if(document.getElementById('optDataSource3').checked==true){
	   window.close();
	   createCookie(ddBenchmarkCalculation,4,500);
	   LoadNewWindowFull('bwDefineCalculation.htm','bwDefineCalculation', 740,280);
   }
}

function defineCalculation(){			
	ddBenchmarkCalculation = readCookie(ddBenchmarkCalculation);
	
	if (ddBenchmarkCalculation == 5){
		document.getElementById('selCalculateSubscriber').style.display="block";
		document.getElementById('selCalculatePPB').style.display="none";
	}
	else if (ddBenchmarkCalculation == 4){
		document.getElementById('selCalculatePPB').style.display="block";
		document.getElementById('selCalculateSubscriber').style.display="none";
	}
}

function selThird(){
 if(document.getElementById('optDataSource3').checked==true){
   document.getElementById('selCorp').disabled=false;
 }
 else if(document.getElementById('optDataSource3').checked==false){
   document.getElementById('selCorp').disabled=true;
 }
 }

// End function for "Benchmark Wizard"
// Cookies 
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

//Called when the mouse pointer is pulled away from the image
//to display the original image back
function MM_swapImgRestore() {
    var i,x,a=document.MM_sr;
    for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
        x.src=x.oSrc;
}

//Used to preload a set of images—typically onmouseover and onmouseout rollovers
function MM_preloadImages() {
    var d=document;
    if(d.images)
    {
        if(!d.MM_p)
            d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
        for(i=0; i<a.length; i++)
            if (a[i].indexOf("#")!=0)
            {
                d.MM_p[j]=new Image;
                d.MM_p[j++].src=a[i];
            }
    }
}

//Used to obtain the image object for swapping
function MM_findObj(n, d) {
    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;
}

//Called when the mouse is placed over the image
//It swaps the image with the over-image
function MM_swapImage() {
    var i,j=0,x,a=MM_swapImage.arguments;
    document.MM_sr=new Array;
    for(i=0;i<(a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null)
        {
            document.MM_sr[j++]=x;
            if(!x.oSrc)
                x.oSrc=x.src;
            x.src=a[i+2];
        }
}
