function abreSesamo(theurl, thewin, hasscroll, hasstatus, hastoolbar, hasmenubar, isresizable, winwidth, winheight, leftpos, toppos)
{





if((theurl.length > 2) && (theurl.indexOf(".") !=-1)){

    var URL = theurl;
	var randStr = createRandomString(6)
 	if(theurl.indexOf("?") >= 0) {
    theurl += "&rt=" + randStr;
	} else {
    theurl += "?rt=" + randStr;
	}
		
     var windowName = thewin;


if(winwidth > 5) {
    var features =
        'width='        + winwidth +
        ',height='      + winheight +
        ',menubar='     + hasmenubar +
        ',scrollbars='  + hasscroll +
        ',status='      + hasstatus +
        ',toolbar='     + hastoolbar +
        ',left='        + leftpos +
        ',top='         + toppos +
        ',screenX='     + leftpos +
        ',screenY='     + toppos +
        ',resizable='   + isresizable + 
        ',modal=yes';

		} else {
     var features =
        'width='        + screen.width + 
        ',height='      + screen.height +  
        ',menubar=yes'     + 
        ',scrollbars=yes'  + 
        ',status=yes'      + 
        ',toolbar=yes'     + 
        ',left=3'        + 
        ',top=3'         + 
        ',screenX=3'     + 
        ',screenY=3'     + 
        ',resizable=yes';

		}
 

// if(window.showModalDialog) { 
if(window.AAAAAshowModalDialog) { 
	 window.showModalDialog(URL, randStr, "dialogwidth:" + winwidth + "px; dialogheight:" + winheight + "px; resizable: yes");
	  } else {
 
	  window.open(URL, randStr, features);
 
	  }
} // end of theurl validation
}



function getStaticCollectionByTagName(tag, node) {
  //just like getElementsByTagName, we want to open up and optional context node 
  if (node==undefined) {
  //if it's not passed in as an argument, we set it to be document 
  node=document
  }
  //we build a variable with the original collection 
  var temp_array = node.getElementsByTagName(tag);
  //and a new array to hold them 
  var static_results = new Array;
  //then we just loop through and copy each into the new array 
  for (i=0; i<temp_array.length;i++) {
  static_results.push(temp_array[i]);
  }
  //and return it 
  return static_results;
}


function doNada() {
return false;
}

function explodeArray(item,delimiter)
{
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0)
{
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+4,tempString.length-tempString.indexOf(delimiter)+4);
Count=Count+1
}
tempArray[Count]=tempString;
return tempArray;
}

function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}


function strip_quotes(str){
return (str=str.replace(/["']{1}/gi,""));
} 


function createRandomString(varLength) {
var sourceArr = new Array("2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z");
var randomKey;
var randomCode = "";

for (i=0; i<varLength; i++) {
randomKey = Math.floor(Math.random()*sourceArr.length);
randomCode = randomCode + sourceArr[randomKey];
}

/*
Possibly update some div as well?
document.getElementById('someDiv').innerHTML = randomCode;
*/

return randomCode;
}


function toggleVisibility(rowname) {
    var theRow = document.getElementById(rowname);
    if (theRow.style.display=="none") {
        theRow.style.display = "block";
       theRow.style.visibility = "visible";
    } else {
        theRow.style.display = "none";
       theRow.style.visibility = "hidden";
    }
}




function showall(theDiv) {
	var ptags = document.getElementById(theDiv).getElementsByTagName("div");
	var expandlink = document.getElementById("expandlink");
	var textDivArray = new Array(0);
	var imgDivArray = new Array(0);

	for (var i = 0; i < ptags.length; i++) {
		if (ptags[i].getAttribute("name") == "cntntDiv")
			textDivArray.push(ptags[i]);
	}
	
	for (var i = 0; i < textDivArray.length; i++) {
			textDivArray[i].style.display = "block";
			textDivArray[i].style.visibility = "visible";
			// imgtags[i].src=eval("imgin.src");
	}
	
	expanded = true;
	// updatelink();
	
	expandlink.href="javascript:collapseall('" + theDiv + "')";
	expandlink.innerHTML="Hide Descriptions";
}

function collapseall(theDiv) {
	var ptags = document.getElementById(theDiv).getElementsByTagName("div");
	var expandlink = document.getElementById("expandlink");
	var textDivArray = new Array(0);
	var imgDivArray = new Array(0);

	for (var i = 0; i < ptags.length; i++) {
		if (ptags[i].getAttribute("name") == "cntntDiv")
			textDivArray.push(ptags[i]);
	}
	
	for (var i = 0; i < textDivArray.length; i++) {
			textDivArray[i].style.display = "none";
			textDivArray[i].style.visibility = "hidden";
			// imgtags[i].src=eval("imgin.src");
	}
	
	expanded = false;
	// updatelink();
	
	expandlink.href="javascript:showall('" + theDiv + "')";
	expandlink.innerHTML="Show Descriptions";
}


function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                             
    var histogram = {}, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}




/*
* Start and stop threads that will output either error or success to a given element ID
*/

function startEventTimer(tdIDstring, fEventString, fErrorSting) {
document.getElementById(tdIDstring).innerHTML = fEventString;

fEvErrorTimer = setTimeout('showTimerError(\'' + tdIDstring + '\', \'' + fErrorSting + '\')',30000); 
}

function showTimerError(tdIDstring, fErrorSting) {
// <font color=red>Sorry, try later...</font>
alert(tdIDstring + "::" + fErrorSting);
document.getElementById(tdIDstring).innerHTML = fErrorSting;
}

function stopEventTimer(tdIDstring, fEventString) {
clearTimeout(fEvErrorTimer);
document.getElementById(tdIDstring).innerHTML = fEventString;
}




function getObjbyID(strId){ 
return document.getElementById(strId); 
}


 	
function setCurrListIndex(theObj, indexVal)
	{

	var selection = theObj;
	if(selection)
		{
		for(var i = 0; i < selection.length; i++)
			{
			var currIndexVal = selection.options[i].value;
			if(currIndexVal == indexVal)
				{
				selection.selectedIndex = i;
				break;
				}
			}		
		}
	}


function getCurrListVal(theObj)
   {
   var theSelIndex = theObj.selectedIndex;
   var theString = theObj.options[theSelIndex].text;
   var theVal = theObj.options[theSelIndex].value;
	// alert(theString +  " : " + theVal);
	return theVal;
   }


function getPrefs(thePrefs) {
document.location.href = siteWebDir + "/user/preferences.php#" + thePrefs;
}


/* !!! TO DELETE */
function editPageOld(theObj) {
objPage = getCurrListVal(document.getElementById(theObj));
if(objPage == "noQvalue") {
alert("Please select page to Edit");
} else {
document.location.href = siteWebDir + "/user/editor.php?contentFile=" + objPage;
}
}

function editPageApplyFeed(theObj) {
objPage = getCurrListVal(document.getElementById(theObj));

var sendFromName = document.getElementById("tfield-apply-fromName").value;
var sendFromEmail = document.getElementById("tfield-apply-fromEmail").value;
var sendToName = document.getElementById("tfield-apply-toName").value;
var sendToEmail = document.getElementById("tfield-apply-toEmail").value;
var sendComment = document.getElementById("tAreaApplyComment").value;
var currFeedID = document.getElementById("currFeedID").value; 


var alertMsg = "";
 

if(sendFromName.length > 120) {
alertMsg += "Please enter valid First and Last Name.   Max length: 120\n";
canSend = "no";
} 
if(sendFromEmail.length > 120) {
alertMsg += "Please enter valid email address.   Max length: 120\n";
canSend = "no";
} 

if(sendToName.length > 120) {
alertMsg += "Please enter a valid employers name.   Max length: 120\n";
canSend = "no";
}  

if(sendToEmail.length > 120) {
alertMsg += "Please enter a valid employers email address.   Max length: 120\n";
canSend = "no";
}  
 

if(sendComment.length > 160) {
alertMsg += "Max length on send comment is: 160\n";
canSend = "no";
} else {
thisSendCommentB = strip_tags(sendComment);
thisSendCommentC = thisSendCommentB.replace(/["']{1}/gi,"");
}


document.getElementById("currSendFromName").value = sendFromName;
document.getElementById("currSendFromEmail").value = sendFromEmail;
document.getElementById("currSendToName").value = sendToName;
document.getElementById("currSendToEmail").value = sendToEmail;
document.getElementById("currSendComment").value = thisSendCommentC;

/*
var tdCntstring = "td_feedContent" + feedID;
document.getElementById("currFeedContent").value = document.getElementById(tdCntstring).innerHTML;


document.getElementById("currFeedContent").value = objPage;
*/

if(objPage == "noQvalue") {
alert("Please select page to Edit");
} else {
document.getElementById("currCoverLetter").value = objPage;
document.actionCommForm.target="_top";
document.actionCommForm.action = siteWebDir + "/user/editor.php";
document.actionCommForm.submit();
}
}

/*
* change element inner html
*/
function setTinnerHTML(theElemId, theInnerHtml){
document.getElementById(theElemId).innerHTML = theInnerHtml;
}


/*
* change element background color
*/

function setTcolor(theElemId, theclr) {
// alert(theid + " : " + theclr);
document.getElementById(theElemId).style.backgroundColor =theclr;
}

function setObjBGcolor(theObj, theclr) {
// alert(theid + " : " + theclr);
theObj.style.backgroundColor = theclr;
}




function doColorCellAlert(theElemId, theColor, theAlertColor) {
setTcolor(theElemId, theAlertColor);
dccaTimer = setTimeout('setTcolor(\'' + theElemId + '\', \'' + theColor + '\')',1000);  
}


function loadWaiting(wObj, wWords) {
document.getElementById(wObj).innerHTML = '<img src="' +  siteWebDir + '/images/misc/loading.gif" align="absmiddle"> ' + wWords;
}


/*
* submit the gotologinForm
* html_header.php
*/

function gotoLogin() {
document.forms["gotologinForm"].submit();

// document.gotologinForm.submit();
}


function gotoRegister() {
regApplyUrl = siteWebDir + "/blog/wp-login.php?action=register";
document.forms["gotologinForm"].redirect_to.value = "";
document.forms["gotologinForm"].action = regApplyUrl;
// document.forms["gotologinForm"].submit();
document.location.href = regApplyUrl;
// document.gotologinForm.submit();
}

function gotoRegister() {
regApplyUrl = siteWebDir + "/blog/wp-login.php?action=register";
document.forms["gotologinForm"].redirect_to.value = "";
document.forms["gotologinForm"].action = regApplyUrl;
// document.forms["gotologinForm"].submit();
document.location.href = regApplyUrl;
// document.gotologinForm.submit();
}


function gotoPrefs() {
prefsApplyUrl = siteWebDir + "/user";
document.forms["gotologinForm"].redirect_to.value = "";
document.forms["gotologinForm"].action = prefsApplyUrl;
// document.forms["gotologinForm"].submit();
document.location.href = prefsApplyUrl;
// document.gotologinForm.submit();
}

function getMainSearch(searchWords, searchType){
document.mainSearchForm.sw.value = searchWords;
document.mainSearchForm.searchType.value = searchType;
document.mainSearchForm.submit();
}

function getMainSearchT(searchWords, searchType, searchTarget){
document.mainSearchForm.sw.value = searchWords;
document.mainSearchForm.searchType.value = searchType;
document.mainSearchForm.target=searchTarget;
document.mainSearchForm.submit();
} 

/*
* scroll to top of page
*/

function scrollTop() {
scroll(0,0);
}