﻿function findFormElementByValue(elemName, elemValue) {
    var elemArray = document.getElementsByName(elemName);
    var i;
    
    for( i = 0; i < elemArray.length; i++ ) {
        if( elemArray[i].value == elemValue ) {
            return elemArray[i];
        }
    }
    return null;
}

function getQueryVar(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return null;
}

function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function window_onLoad() {
    if( (window.onLoadQueue != null) ) {
        var fnHandle;
        while( window.onLoadQueue.length > 0 ) {
            fnHandle = window.onLoadQueue.pop();
            fnHandle();
        }
    }
}

function defaultButtonFix() {
    __defaultFired = false;
}

function winOpen700(thisItem){
    thisURL = thisItem;
    window.open(thisURL,"email_friend",'width=650, height=500, scrollbars=false, resizable, menubar=false, location=false, toolbar=false, status=false');
}
function winOpen500(thisItem){
    thisURL = thisItem;
    window.open(thisURL,"email_friend",'width=500, height=500, scrollbars=false, resizable, menubar=false, location=false, toolbar=false, status=false');
}

window.addOnLoad = function(fnHandle) {
    if( window.onLoadQueue == null ) {
        window.onLoadQueue = new Array();
    }
    window.onLoadQueue.push(fnHandle);
}

function popupWindow(url, width, height, showScrollBars)
{
	var popupWin = null;
	var top = (screen.availHeight - height)/2;
	var left = (screen.availWidth - width)/2;
	
	showScrollBars = (showScrollBars ? "yes" : "no");
	
	popupWin = open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + showScrollBars + ",resizable=yes,copyhistory=no,width="+width+",height="+height+",left="+left+", top="+top+",screenX="+left+",screenY="+top);
}
