﻿// email this window opener
function openEmailThis(sURL)
{
    newwindow=open(sURL, "emailthis", "scrollbars=yes,toolbar=no,directories=no,location=no,menubar=no,resizable=no,status=no,width=540,height=650");
}

function isValidZip (strZip)
{
    reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/); 
    if(!reZip.test(strZip)) 
        return false;
    return true;
}

function isValidEmail(strAddress)
{
    var exclude = /[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@] \1/;
	var check = /@[\w\-]+\./;
	var checkend = /\.[a-zA-Z]{2,5}$/;
	if (((strAddress.search(exclude) != -1) || (strAddress.search(check)) == -1) || (strAddress.search(checkend) == -1)){
        return false;
    } 
    return true;
} 

// this function fill the given div element by id
function FillDivById(id, data)
{
    //alert('id: ' + id + ', data: ' + data);
    if (document.getElementById(id)) {
        //alert('id found');
        document.getElementById(id).innerHTML = data;
    }
}

// this function shows or hides the given div element by id
function ShowDivById(id, show)
{
    var showOption = "none";
    if (show) {
        showOption = "block";
    }
    //alert('id: ' + id + ', show: ' + showOption);
    document.getElementById(id).style.display = showOption;
}

function DbAppsGotoURL(urlFormat, listControl) {
  // get the state from the listControl value
  var State = document.getElementById(listControl).value;

  // Create url by replacing placeholder with state value
  sUrlFormat = new String(urlFormat);
  var url= sUrlFormat.replace("{0}", State);
 
 // go To Url!
 if (url != "") {
        if ((parseInt(navigator.appVersion) == 2) && (navigator.appName == "Microsoft Internet Explorer"))
                top.location = url;
        else top.document.location = url;
        }
}

// this function is used to open a new window using the given args
function windowOpener(url, name, args)
{
    if (typeof(popupWin) != "object") {
        popupWin = window.open(url, name, args);
    } else {
        if (!popupWin.closed) {
            popupWin.location.href = url;
        } else {
            popupWin = window.open(url, name,args);
        }
    }

    popupWin.focus();
}
 
function goToThunderstoneSearch(keywordId, prId)
{   
    if(document.getElementById(keywordId).value.replace(/^\s+|\s+$/g, '')=='')
    {
        alert("Please enter what you want to search.");
        return false;
     }
    window.document.location = 'http://websearch.entrepreneur.com/cgi-bin/texis/webinator/search/?query=' + document.getElementById(keywordId).value + '&pr=' +document.getElementById(prId).value; return false;
}

function goToAOLSearch(keywordId, invocationTypeId)
{
    window.document.location = 'http://aolsearch.aol.com/aol/search?query=' + document.getElementById(keywordId).value + '&invocationType=' +document.getElementById(invocationTypeId).value; return true;
}


/*******************************************
BEGIN CODE FOR QUIZZES added 07/25/06
*******************************************/

function gradeLeadershipQuiz()
{ 
    var score = 0
    for(i=1; i <21; i++)//16
    {
        if(!document.getElementsByName('q'+i).item(0).checked && !document.getElementsByName('q'+i).item(1).checked &&
         !document.getElementsByName('q'+i).item(2).checked && !document.getElementsByName('q'+i).item(3).checked
         && !document.getElementsByName('q'+i).item(4).checked)
        {
            alert ('Please answer question ' + i +'.')  
            return false; 
        }
        for(j=0; j<5; j++)
        {
            if(document.getElementsByName('q'+i).item(j).checked)
            {
                score =  parseInt(score, 10) +  parseInt(document.getElementsByName('q'+i).item(j).value, 10);
                break;
            }
        }   
    }
    document.getElementById("score").value = score; 
    return true;
}

function gradeBadBossQuiz()
{ 
    var score = 0
    for(i=1; i < 16; i++)//16
    {
        if(!document.getElementsByName('q'+i).item(0).checked && !document.getElementsByName('q'+i).item(1).checked && !document.getElementsByName('q'+i).item(2).checked)
        {
            alert ('Please answer question ' + i +'.')  
            return false; 
        }
    if(document.getElementsByName('q'+i).item(0).checked)
        score =  parseInt(score, 10) +  parseInt(document.getElementsByName('q'+i).item(0).value, 10)
    if(document.getElementsByName('q'+i).item(1).checked)
        score = parseInt(score, 10) + parseInt(document.getElementsByName('q'+i).item(1).value, 10)
    if(document.getElementsByName('q'+i).item(2).checked)
        score =  parseInt(score, 10) + parseInt(document.getElementsByName('q'+i).item(2).value, 10)
    }
    document.getElementById("score").value = score; 
    return true;
}

function gradeMarketingIQ() 
{
    var ans="";
    var score = 0;
    for(i=1; i < 11; i++)
    { 
        if(!document.getElementsByName('q'+i).item(0).checked && !document.getElementsByName('q'+i).item(1).checked && !document.getElementsByName('q'+i).item(2).checked && !document.getElementsByName('q'+i).item(3).checked)
        { 
            document.getElementById("complete").value="f";
            alert ('Please complete all questions!');  
            return false; 
        }  
        for(j=0; j<4; j++)
        {
            if(document.getElementsByName('q'+i).item(j).checked) 
                {  
                          score = parseInt(score, 10) + parseInt(document.getElementsByName('q'+i).item(j).value, 10);                }               
        } 
        if(document.getElementsByName('q'+i).item(0).checked) 
            document.getElementById("answer"+i).value = 'A';  
        if(document.getElementsByName('q'+i).item(1).checked) 
            document.getElementById("answer"+i).value = 'B';
        if(document.getElementsByName('q'+i).item(2).checked) 
            document.getElementById("answer"+i).value = 'C';
        if(document.getElementsByName('q'+i).item(3).checked) 
            document.getElementById("answer"+i).value = 'D';            
    }
    document.getElementById("score").value= score;
    return true;
}  

function gradeYourOfficeQuiz() 
{
    var ans="";
    var scoreStr=""; // = 0; 
//    int numQ;
//    numQ = parseInt(document.getElementById("numQ").value, 10);
    for(i=1; i <= 10; i++)
    { 
        if(!document.getElementsByName('q'+i).item(0).checked && !document.getElementsByName('q'+i).item(1).checked && !document.getElementsByName('q'+i).item(2).checked)
        { 
            alert ('Please complete all questions!');  
            return false; 
        }  
        for(j=0; j<3; j++)
        {
            if(document.getElementsByName('q'+i).item(j).checked) 
            {  
               // score = parseInt(score, 10) + parseInt(document.getElementsByName('q'+i).item(j).value, 10);
                scoreStr =scoreStr + document.getElementsByName('q'+i).item(j).value;
            }               
        } 
    } 
    document.getElementById("ansStr").value= scoreStr;   
    return true;
}   



/*******************************************
BEGIN CODE FOR NEWSLETTERS
*******************************************/

function newsLettersFormCheck(){	
	var status = false;
	document.getElementById("listname").value = '';

	for( var i = 0; i < document.getElementsByName("listname").length; i++){
		if(document.getElementsByName("listname").item(i).checked){
		   document.getElementById("listname").value +=  'listname='+ document.getElementsByName("listname").item(i).value + '&';
		   status = true;
		}
	}

	if(status)
	    return true;
	else 
	{
            alert("Please select at least one interest area.");
	    return false;
	}	
}

/******************************************
MODIFIED gotoUrl() added gotoUrl2()
******************************************/
function gotoUrl(url)
{
    if(url =="" || url==null || url.toLowerCase() == 'select state'){
	return false;
    }
    if (url != "") {
        if ((parseInt(navigator.appVersion) == 2) && (navigator.appName == "Microsoft Internet Explorer")) {
            top.location = url;
        } else {
            top.document.location = url;
        }
    }
}

function gotoUrl2(url, opt)
{
    if(url =="" || url==null || opt.selectedIndex==0){
	return false;
    }
    gotoUrl(url);
}

/*******************************************
BEGIN CODE FOR CONFERENCE REGISTRATION
*******************************************/
/*
function onload(){
   if( document.getElementsByName("fax").item(0).checked)
        document.getElementById("q5Text").style.display="";
	else
		document.getElementById("contry").value ="";
   if( document.getElementsByName("title").item(0).checked)
        document.getElementById("q6Text").style.display="";
	else
		document.getElementById("address2").value ="";
}   
*/


function show5(){ 
	document.getElementById("q5Text").style.display="";
	return true; 
}
function hide5(){ 
	document.getElementById("country").value ="";
	document.getElementById("q5Text").style.display="none"; 
	return true; 
}

function show6(){
	document.getElementById("q6Text").style.display="";
	return true; 
}
function hide6(){
	document.getElementById("address2").value ="";
	document.getElementById("q6Text").style.display="none"; 
	return true;  
}
function isEmpty(strng) {
	if (strng.length == 0) {
		return true;
	}
	return false;  
}

function isEmail (strng) {
	if (strng == "") {
	   return false;
	}
    var emailFilter=/^.+@.+..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       return false;
    }
   
	return true;   
}
function isZipcode (zip)
{
    reZip = new RegExp(/(^d{5}$)|(^d{5}-d{4}$)/); 
    if(!reZip.test(document.getElementById("zip").value)) 
        return false;
    return true;
} 
 
function validateConference()
{  
 	if (isEmpty(document.getElementById("fName").value))
	{
		alert('Please tell us your first name.');
		return false;
	}
	if (isEmpty(document.getElementById("lName").value))
	{
		alert('Please tell us your last name.');
		return false;
	} 
	if (isEmpty(document.getElementById("companyName").value))
	{
		alert('Please tell us your company name.');
		return false;
	}
	if (isEmpty(document.getElementById("address1").value))
	{
		alert('Please tell us your company address.');
		return false;
	}
	if (isEmpty(document.getElementById("city").value))
	{
		alert('Please enter city.');
		return false;
	}
	if (isEmpty(document.getElementById("state").value))
	{
		alert('Please select state.');
		return false;
	} 
	if (isEmpty(document.getElementById("zip").value))
	{
		alert('Please enter a valid zip code.');
		return false;
	} 
	if ( isEmpty (document.getElementById("email").value)) 
	{
		alert('Please provide us with your email address.')
		return false;
	}
	if ( isEmpty (document.getElementById("phone").value)) 
	{
		alert('Please provide us with your telephone number.')
		return false;
	}	


	var myOption = -1;
	for (i=0; i<document.getElementsByName("businessOwner").length; i++) {
		if (document.getElementsByName("businessOwner").item(i).checked) {
			myOption = i;
		}
	}
	if (myOption == -1) {
		alert("Please tell us whether or not you own a business.");
		return false;
	}
	myOption = -1;
	for (i=0; i<document.getElementsByName("fax").length; i++) {
		if (document.getElementsByName("fax").item(i).checked) {
			myOption = i;
		}
	}
	if (myOption == -1) {
		alert("Please tell us if you have a State Farm agent.");
		return false;
	}
	
	if(document.getElementsByName("fax").item(0).checked && isEmpty(document.getElementById("country").value)) {
		alert ("Please tell us your State Farm agent's name.");
		return false;
	}

	myOption = -1;
	for (i=0; i<document.getElementsByName("title").length; i++) {
		if (document.getElementsByName("title").item(i).checked) {
			myOption = i;
		}
	}
	if (myOption == -1) {
		alert("Please tell us if you were invited to the seminar by a State Farm agent.");
		return false;
	}
	if(document.getElementsByName("title").item(0).checked && isEmpty(document.getElementById("address2").value)) {
		alert ("Please tell us the State Farm agent who invited you.");
		return false;
	}
		myOption = -1;
	for (i=0; i<document.getElementsByName("grossSales").length; i++) {
		if (document.getElementsByName("grossSales").item(i).checked) { 
			myOption=i; 
		}
	}
	if (myOption == -1) {
		alert("Please tell us if your business is primarily located in your home.");
		return false;
	}	
			
	
	if (document.getElementById("age").selectedIndex == 0){  
  		alert("Please indicate how many years you've been in business");
		return false;
	}
	if (document.getElementById("purchaseDecisions").selectedIndex == 0){  
  		alert("Please indicate how many employees you have");
		return false;
	} 
	if (document.getElementById("gender").selectedIndex == 0){  
  		alert("Please tell us what industry best describes your business");
		return false;
	}    
	if (document.getElementById("promoCode").selectedIndex == 0) 
	{
		alert('Please tell us how you heard about these seminars.')
		return false;
	}   
 	return true;
} 
/*******************************************
END CODE FOR CONFERENCE REGISTRATION
*******************************************/

 /******************************************
Comercial vehicle center popup
******************************************/
function openit(sURL)
{
    newwindow=open(sURL,"newwin","scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes,left=300,top=154,status=yes,width=615,height=550");
}

function openFeaturePopup(sURL)
{
    newwindow=open(sURL,"","status=no,resizable=no,scrollbars=no,location=no,directories=no,menubar=no,width=742,height=550");
}
 
/*****************************************
NEWSLETTERS SIGNUP
*****************************************/
function gotoNewsletterForm(urlFormat)
{    
    var selValue = getNewslettersSelection();     
    gotoUrl(urlFormat +selValue);
}
 
function getNewslettersSelection()
{
    var selection = 0;    
    if (getCheckboxSelection("chkLeftSAB"))
        selection +=1;    
    if (getCheckboxSelection("chkLeftSAM"))
        selection +=2;        
    if (getCheckboxSelection("chkLeftGAB"))
        selection +=4;        
    if (getCheckboxSelection("chkLeftEBZ"))
        selection +=8;        
    if (getCheckboxSelection("chkLeftFZN"))
        selection +=16;        
    if (getCheckboxSelection("chkLeftBKS"))
        selection +=32;        
    return selection;        
}
 
function getCheckboxSelection(id)
{
    var checkbox = document.getElementById(id);    
    if (checkbox != null && checkbox.checked)
    {
        return true;
    }
    else
        return false;    
}

function fran1()
{
 document.getElementById('list').style.display="";
 document.getElementById('opps').style.display="none";
}
function fran2()
{
 document.getElementById('list').style.display="none";
 document.getElementById('opps').style.display="";
}

// open popup for setting preview date taken from value of give input control
function setPreviewDate(textBoxId)
{
    var date = document.getElementById(textBoxId);    
    if(date != null)
    {
        ecmPopUpWindow("/admin/setPreviewDate.aspx?preview_date=" +date.value, "SetPreviewDate", 1, 1, 1, 1);return false;
    }
}

 function showFeatured()
{
	document.getElementById('featuredBox').style.display="";
	document.getElementById('oppBox').style.display="none";
	document.getElementById('catBox').style.display="none";
}
function showOpp()
{
	document.getElementById('featuredBox').style.display="none";
	document.getElementById('oppBox').style.display="";
}
function openCatBox()
{
    document.getElementById('catBox').style.display = ""; 
    return false;
}
function closeCatBox()
{
    document.getElementById('catBox').style.display = "none"; 
    return false;
}

// function that takes the windows event and if it is an enter key
// will fire the default given button
function fireDefaultButton(e, button)
{
    var keychar = '';
    
    if(window.event) // IE
    {
        keychar = e.keyCode
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keychar = e.which
    }

    if (e == null)
        e = windows.event;
        
    if (keychar == '13')
    {
        var ctl = document.getElementById(button);
        if (ctl != null)
        {
            ctl.focus();
            ctl.click();
            
            return false;
        }
    }
}

function validateAlias(e)
{
    var keychar = '';
    
    if(window.event) // IE
    {
        keychar = e.keyCode
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keychar = e.which
    }
    
    //alert( keychar );
    
    if (e == null)
        e = window.event;
        
    /*if (keychar == '46' || keychar == '32' || keychar == '47' || keychar == '63' || keychar == '38' || keychar == '58' ) //period, space, /, ?, 
    {
        alert( 'The alias can only contain A through Z, 0 through 9, and a hyphen (-). If you are entering an extension, stop and please use the menu on the right.' );
        return false;
    }*/

    var keyint = parseInt(keychar);
    
    if( (keyint >= 48 && keyint <= 57) ||   //0-9
        (keyint >= 97 && keyint <= 122)||   //a-z
        (keyint >= 65 && keyint <= 90) ||   //a-z
        keyint == 47 ||                     // /
        keyint == 45 ||                     // -
        keyint <= 27 ||                       // any control character is allowed
        keyint == 127  ||                     // DEL
        keyint > 255                       // any other non visual character is allowed
        ){                      
        //do nothing for valid characters    
        
        return true;
    }
    else{
        alert( 'The alias can only contain A through Z, 0 through 9, and a hyphen (-). If you are entering an extension, stop and please use the menu on the right.' );
        return false;
    }
    
}

function checkAliasSelectedForDeletion()
{
    var table  = document.getElementById("tableResults");
    
    var foundCheck = false;
    if (table != null)
    {
        var inputControls = table.getElementsByTagName("input");
        
        if (inputControls != null && inputControls.length >0)
        {    
            var i;
            for(i=0; i< inputControls.length; i++)
            {
                if (inputControls[i].type == "checkbox" && inputControls[i].checked)
                {
                    foundCheck = true;
                }
            }
            
        }
    }
    
    if (!foundCheck)
    {
        alert("No alias has been marked for deletion. Please select one.");
    }
    return foundCheck;
}




//added 12/21 for sub categories boxes
function ShowMenu(ulDiv)
{ 
    HideAllMenus();
    var ulElem = document.getElementById(ulDiv);
	document.getElementById(ulDiv).style.display ="";
	ulElem.style.zIndex = "100";
}
function HideMenu(ulDiv){
    document.getElementById(ulDiv).style.display="none";
} 

function HideAllMenus(){
 var i;
    for( i= 1; i < 14; i++)
    {
        var s= "Div" + i.toString();
        HideMenu(s); 
    }
}
function DeselectAll()
{
    for( var i= 1; i < 14; i++)
    {
        var s2="img" + i.toString();
        document.getElementById(s2).src ="/i/images/ch/franchises/button_default.gif";
        document.getElementById(s2).setAttribute("rel","close");
    }
}
function Toggle(img, div)
{
    var ulElem = document.getElementById(div);    
    HideAllMenus();  
    if(img.getAttribute("rel")=="open" ){
        img.setAttribute("rel", "close");
        ulElem.style.display="none";
        img.src="/i/images/ch/franchises/button_default.gif";
    }
    else if(img.getAttribute("rel")=="close")
    {
        DeselectAll();
        img.setAttribute("rel", "open");
        ulElem.style.display="block";
        img.src="/i/images/ch/franchises/button_selected.gif";    
    }
}

function mouseOver(img)
{
    if(img.getAttribute("rel")!="open") 
        img.src='/i/images/ch/franchises/button_hover.gif';
}
function mouseOut()
{  
    for( var i= 1; i < 14; i++)
    {
        var s2="img" + i.toString();
        if(document.getElementById(s2).getAttribute("rel")=="open")
        {    
            document.getElementById(s2).src='/i/images/ch/franchises/button_selected.gif';
        }
        else
        document.getElementById(s2).src='/i/images/ch/franchises/button_default.gif';
    }
}



function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}



/* Text Sizer */
var tgs = new Array( 'div','td','tr');

var szs = new Array( 'small','medium' );
var startSz = 1;

function textsizer( trgt,inc ) {
	if (!document.getElementById) return
	var doc = document,text = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 1 ) sz = 1;
	startSz = sz;
		
	if ( !( text = doc.getElementById( trgt ) ) ) text = doc.getElementsByTagName( trgt )[ 0 ];

	text.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = text.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

function GSearch2(q ,site) //google search text box.  Dependency: UrlEnc
{
    var srchStr="q="+UrlEnc(q) + "&client=pub-1914278930181225&cof="+UrlEnc("GALT:#009900;GL:1;DIV:#C0C0C0;VLC:003399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:003399;LC:003399;T:000000;GFNT:666666;GIMP:003399;FORID:9")+ "&sitesearch="+ site;    
    goSearch('/searchresults.html?{0}',srchStr);     
}

function GSearch() //google search text box.  Dependency: UrlEnc
{
    var site= (document.getElementsByName('site').item(1).checked)?"":"www.womenentrepreneur.com";
    var srchStr="q="+UrlEnc( document.getElementById('q').value) + "&client=" + UrlEnc(document.getElementById('cx').value) + "&cof="+UrlEnc(document.getElementById('cof').value )+ "&sitesearch="+ site;
    goSearch('/searchresults.html?{0}',srchStr);      
}


function UrlEnc(str) //url encode a string for google search
{ 
	var SAFECHARS = "0123456789" +
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";
	var HEX = "0123456789ABCDEF";

	var plaintext = str;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} 
	return encoded;
}

function getmetaContents(mn){ 
  var m = document.getElementsByTagName('meta'); 
  for(var i in m){ 
   if(m[i].name == mn){ 
     return m[i].content; 
   } 
  } 
}

//toggle and toggle images for various controls. 
//imgminus = new Image(); 
//imgminus.src = "/graphics/minus.gif"; 
//imgplus = new Image(); 
//imgplus.src = "/graphics/plus.gif";
function ToolToggle(divId, imgname) {
	var d = document.getElementById(divId);
	if (d.style.display != 'block') {
		 //document [imgname].src = imgminus.src; 
		 d.style.display = 'block';
		 
	} else {
		 d.style.display = 'none';
		//document [imgname].src = imgplus.src;
	}
}


/*****************************************
GLOBAL NAV DROPDOWN MENU
*****************************************/

//** AnyLink JS Drop Down Menu v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm
//** January 29th, 2009: Script Creation date

var anylinkmenu={

menusmap: {},
effects: {delayhide: 200, shadow:{enabled:true, opacity:0.3, depth: [5, 5]}, fade:{enabled:false, duration:500}}, //customize menu effects

dimensions: {},

getoffset:function(what, offsettype){
	return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
},

getoffsetof:function(el){
	el._offsets={left:this.getoffset(el, "offsetLeft"), top:this.getoffset(el, "offsetTop"), h: el.offsetHeight}
},

getdimensions:function(menu){
	this.dimensions={anchorw:menu.anchorobj.offsetWidth, anchorh:menu.anchorobj.offsetHeight,
		docwidth:(window.innerWidth ||this.standardbody.clientWidth)-20,
		docheight:(window.innerHeight ||this.standardbody.clientHeight)-15,
		docscrollx:window.pageXOffset || this.standardbody.scrollLeft,
		docscrolly:window.pageYOffset || this.standardbody.scrollTop
	}
	if (!this.dimensions.dropmenuw){
		this.dimensions.dropmenuw=menu.dropmenu.offsetWidth
		this.dimensions.dropmenuh=menu.dropmenu.offsetHeight
	}
},

isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},

setopacity:function(el, value){
	el.style.opacity=value
	if (typeof el.style.opacity!="string"){ //if it's not a string (ie: number instead), it means property not supported
		el.style.MozOpacity=value
		if (el.filters){
			el.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity="+ value*100 +")"
		}
	}
},

showmenu:function(menuid){
	var menu=anylinkmenu.menusmap[menuid]
	clearTimeout(menu.hidetimer)
	this.getoffsetof(menu.anchorobj)
	this.getdimensions(menu)
	var posx=menu.anchorobj._offsets.left + (menu.orientation=="lr"? this.dimensions.anchorw : 0) //base x pos
	var posy=menu.anchorobj._offsets.top+this.dimensions.anchorh - (menu.orientation=="lr"? this.dimensions.anchorh : 0)//base y pos
	if (posx+this.dimensions.dropmenuw+this.effects.shadow.depth[0]>this.dimensions.docscrollx+this.dimensions.docwidth){ //drop left instead?
		posx=posx-this.dimensions.dropmenuw + (menu.orientation=="lr"? -this.dimensions.anchorw : this.dimensions.anchorw)
	}
	if (posy+this.dimensions.dropmenuh>this.dimensions.docscrolly+this.dimensions.docheight){  //drop up instead?
		posy=Math.max(posy-this.dimensions.dropmenuh - (menu.orientation=="lr"? -this.dimensions.anchorh : this.dimensions.anchorh), this.dimensions.docscrolly) //position above anchor or window's top edge
	}
	if (this.effects.fade.enabled){
		this.setopacity(menu.dropmenu, 0) //set opacity to 0 so menu appears hidden initially
		if (this.effects.shadow.enabled)
			this.setopacity(menu.shadow, 0) //set opacity to 0 so shadow appears hidden initially
	}
	menu.dropmenu.setcss({left:posx+'px', top:posy+'px', visibility:'visible'})
	if (this.effects.shadow.enabled){
		//menu.shadow.setcss({width: menu.dropmenu.offsetWidth+"px", height:menu.dropmenu.offsetHeight+"px"})
		menu.shadow.setcss({left:posx+anylinkmenu.effects.shadow.depth[0]+'px', top:posy+anylinkmenu.effects.shadow.depth[1]+'px', visibility:'visible'})
	}
	if (this.effects.fade.enabled){
		clearInterval(menu.animatetimer)
		menu.curanimatedegree=0
		menu.starttime=new Date().getTime() //get time just before animation is run
		menu.animatetimer=setInterval(function(){anylinkmenu.revealmenu(menuid)}, 20)
	}
},

revealmenu:function(menuid){
	var menu=anylinkmenu.menusmap[menuid]
	var elapsed=new Date().getTime()-menu.starttime //get time animation has run
	if (elapsed<this.effects.fade.duration){
		this.setopacity(menu.dropmenu, menu.curanimatedegree)
		if (this.effects.shadow.enabled)
			this.setopacity(menu.shadow, menu.curanimatedegree*this.effects.shadow.opacity)
	}
	else{
		clearInterval(menu.animatetimer)
		this.setopacity(menu.dropmenu, 1)
		menu.dropmenu.style.filter=""
	}
	menu.curanimatedegree=(1-Math.cos((elapsed/this.effects.fade.duration)*Math.PI)) / 2
},

setcss:function(param){
	for (prop in param){
		this.style[prop]=param[prop]
	}
},

hidemenu:function(menuid){
	var menu=anylinkmenu.menusmap[menuid]
	clearInterval(menu.animatetimer)
	menu.dropmenu.setcss({visibility:'hidden', left:0, top:0})
	menu.shadow.setcss({visibility:'hidden', left:0, top:0})
},

getElementsByClass:function(targetclass){
	if (document.querySelectorAll)
		return document.querySelectorAll("."+targetclass)
	else{
		var classnameRE=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "i") //regular expression to screen for classname
		var pieces=[]
		var alltags=document.all? document.all : document.getElementsByTagName("*")
		for (var i=0; i<alltags.length; i++){
			if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1)
				pieces[pieces.length]=alltags[i]
		}
		return pieces
	}
},

addDiv:function(divid, divclass, inlinestyle){
	var el=document.createElement("div")
	if (divid)
		el.id=divid
	el.className=divclass
	if (inlinestyle!="" && typeof el.style.cssText=="string")
		el.style.cssText=inlinestyle
	else if (inlinestyle!="")
		el.setAttribute('style', inlinestyle)
	document.body.appendChild(el)
	return el
},

getmenuHTML:function(menuobj){
	var menucontent=[]
	var frag=""
	for (var i=0; i<menuobj.items.length; i++){
		frag+='<li><a href="' + menuobj.items[i][1] + '" target="' + menuobj.linktarget + '">' + menuobj.items[i][0] + '</a></li>\n'
		if (menuobj.items[i][2]=="efc" || i==menuobj.items.length-1){
			menucontent.push(frag)
			frag=""
		}
	}
	if (typeof menuobj.cols=="undefined")
		return '<ul>\n' + menucontent.join('') + '\n</ul>'
	else{
		frag=""
		for (var i=0; i<menucontent.length; i++){
			frag+='<div class="' + menuobj.cols.divclass + '" style="' + menuobj.cols.inlinestyle + '">\n<ul>\n' + menucontent[i] + '</ul>\n</div>\n'
		}
		return frag
	}
},

addEvent:function(targetarr, functionref, tasktype){
	if (targetarr.length>0){
		var target=targetarr.shift()
		if (target.addEventListener)
			target.addEventListener(tasktype, functionref, false)
		else if (target.attachEvent)
			target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)})
		this.addEvent(targetarr, functionref, tasktype)
	}
},

setupmenu:function(targetclass, anchorobj, pos){
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	var relattr=anchorobj.getAttribute("rel")
	dropmenuid=relattr.replace(/\[(\w+)\]/, '')
	var dropmenuvar=window[dropmenuid]
	var dropmenu=this.addDiv(null, dropmenuvar.divclass, dropmenuvar.inlinestyle) //create and add main sub menu DIV
	dropmenu.innerHTML=this.getmenuHTML(dropmenuvar)
	var menu=this.menusmap[targetclass+pos]={
		id: targetclass+pos,
		anchorobj: anchorobj,	
		dropmenu: dropmenu,
		revealtype: (relattr.length!=dropmenuid.length && RegExp.$1=="click")? "click" : "mouseover",
		orientation: anchorobj.getAttribute("rev")=="lr"? "lr" : "ud",
		shadow: this.addDiv(null, "anylinkshadow", null) //create and add corresponding shadow
	}
	menu.anchorobj._internalID=targetclass+pos
	menu.anchorobj._isanchor=true
	menu.dropmenu._internalID=targetclass+pos
	menu.shadow._internalID=targetclass+pos
	menu.dropmenu.setcss=this.setcss
	menu.shadow.setcss=this.setcss
	menu.shadow.setcss({width: menu.dropmenu.offsetWidth+"px", height:menu.dropmenu.offsetHeight+"px"})
	this.setopacity(menu.shadow, this.effects.shadow.opacity)
	this.addEvent([menu.anchorobj, menu.dropmenu, menu.shadow], function(e){ //MOUSEOVER event for anchor, dropmenu, shadow
		var menu=anylinkmenu.menusmap[this._internalID]
		if (this._isanchor && menu.revealtype=="mouseover" && !anylinkmenu.isContained(this, e)){ //event for anchor
			anylinkmenu.showmenu(menu.id)
		}
		else if (typeof this._isanchor=="undefined"){ //event for drop down menu and shadow
			clearTimeout(menu.hidetimer)
		}
	}, "mouseover")
	this.addEvent([menu.anchorobj, menu.dropmenu, menu.shadow], function(e){ //MOUSEOUT event for anchor, dropmenu, shadow
		if (!anylinkmenu.isContained(this, e)){
			var menu=anylinkmenu.menusmap[this._internalID]
			menu.hidetimer=setTimeout(function(){anylinkmenu.hidemenu(menu.id)}, anylinkmenu.effects.delayhide)
		}
	}, "mouseout")
	this.addEvent([menu.anchorobj, menu.dropmenu], function(e){ //CLICK event for anchor, dropmenu
		var menu=anylinkmenu.menusmap[this._internalID]
		if ( this._isanchor && menu.revealtype=="click"){
			if (menu.dropmenu.style.visibility=="visible")
				anylinkmenu.hidemenu(menu.id)
			else
				anylinkmenu.showmenu(menu.id)
			if (e.preventDefault)
				e.preventDefault()
			return false
		}
		else
			menu.hidetimer=setTimeout(function(){anylinkmenu.hidemenu(menu.id)}, anylinkmenu.effects.delayhide)
	}, "click")
},

init:function(targetclass){
	var anchors=this.getElementsByClass(targetclass)
	for (var i=0; i<anchors.length; i++){
		this.setupmenu(targetclass, anchors[i], i)
	}
}

}


//////

var anylinkmenu1={divclass:'anylinkmenu', inlinestyle:'', linktarget:''} //First menu variable. Make sure "anylinkmenu1" is a unique name!
anylinkmenu1.items=[
	["Librería", "http://www.entrepreneurpress.com/"],
	["Suscripciones", "https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=ENT&cds_page_id=55992&cds_response_key=I1IPGE"],
	["Ayuda", "http://assist.entrepreneur.com/"],
	["Conectar", "http://econnect.entrepreneur.com"] //no comma following last entry!
]