﻿
function gup( name )
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

function getURLParameters() 
{
	var sURL = window.document.URL.toString();
	
	if (sURL.indexOf("?") > 0)
	{
		var arrParams = sURL.split("?");
			
		var arrURLParams = arrParams[1].split("&");
		
		var arrParamNames = new Array(arrURLParams.length);
		var arrParamValues = new Array(arrURLParams.length);
		
		var i = 0;
		for (i=0;i<arrURLParams.length;i++)
		{
			var sParam =  arrURLParams[i].split("=");
			arrParamNames[i] = sParam[0];
			if (sParam[1] != "")
				arrParamValues[i] = unescape(sParam[1]);
			else
				arrParamValues[i] = "No Value";
		}
		
		for (i=0;i<arrURLParams.length;i++)
		{
			alert(arrParamNames[i]+" = "+ arrParamValues[i]);
		}
	}
	else
	{
		alert("No parameters.");
	}
}

function getViewportSize()
{
    var size = [0, 0];

    if (typeof window.innerWidth != 'undefined')
    {
    size = [
       window.innerWidth,
       window.innerHeight
    ];
    }
    else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
    {
    size = [
       document.documentElement.clientWidth,
       document.documentElement.clientHeight
    ];
    }
    else
    {
    size = [
       document.getElementsByTagName('body')[0].clientWidth,
       document.getElementsByTagName('body')[0].clientHeight
    ];
    }

    return size;
}


function getScrollingPosition()
{
 var position = [0, 0];

 if (typeof window.pageYOffset != 'undefined')
 {
   position = [
       window.pageXOffset,
       window.pageYOffset
   ];
 }

 else if (typeof document.documentElement.scrollTop
     != 'undefined' && document.documentElement.scrollTop > 0)
 {
   position = [
       document.documentElement.scrollLeft,
       document.documentElement.scrollTop
   ];
 }

 else if (typeof document.body.scrollTop != 'undefined')
 {
   position = [
       document.body.scrollLeft,
       document.body.scrollTop
   ];
 }

 return position;
}

function getPosition(theElement)
{
    var positionX = 0;
    var positionY = 0;
    
//    while (theElement != null)
//    {
//    positionX += theElement.offsetLeft;
//    positionY += theElement.offsetTop;
//    theElement = theElement.offsetParent;
//    }


    positionX += theElement.offsetLeft;
    positionY += theElement.offsetTop;
    //return [positionX, positionY];
    alert('element positioned at ' + positionX + ',' + positionY);
}


function MoveFloatDropDownToClickPoint(e) {
    var xcoord, ycoord;
    
    if (typeof e == "undefined")
     {
       e = window.event;
     }

     var scrollingPosition = getScrollingPosition();
     var cursorPosition = [0, 0];

     if (typeof e.pageX != "undefined" &&
         typeof e.x != "undefined")
     {
       xcoord = e.pageX;
       ycoord = e.pageY;
     }
     else
     {
       xcoord = e.clientX + scrollingPosition[0];
       ycoord = e.clientY + scrollingPosition[1];
     } 
      
      //window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
      
      //----------------- set location of div---------------------------
      // (some browsers need "px" on the coordinate value!)
      
      
      // Custom Adjustment of coordinates
      
      xcoord = (xcoord/2)+40;
      ycoord = ycoord - 40;
      
       if (document.layers)
       {
          xcoord = xcoord ;
          ycoord = ycoord ;
        }
        else 
        {
          xcoord = xcoord + "px";
          ycoord = ycoord + "px";
        }
        
       //window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
        
        //document.getElementById('div_MfrListDropdownFloating').style.visibility = 'visible';
        document.getElementById('div_MfrListDropdownFloating').style.left = xcoord;
        document.getElementById('div_MfrListDropdownFloating').style.top = ycoord;
        show('div_MfrListDropdownFloating');
        
        //alert(getViewportSize());
        //MoveRightAdPanelToScrollPoint(e);
}

function MoveRightAdPanelToScrollPoint(e) {
    var xcoord, ycoord;
    
    if (typeof e == "undefined")
     {
       e = window.event;
     }

     var scrollingPosition = getScrollingPosition();

      ycoord = scrollingPosition[1];
      
       if (document.layers)
       {
          ycoord = ycoord ;
        }
        else 
        {
          ycoord = ycoord + "px";
        }
        
       //window.alert('Scroll coordinates are ' + ycoord);
        document.getElementById('AdWrap').style.top = ycoord;
        
}


function test(){
    alert('hi there');
}

function CloseListWindow(){
    alert('closeclick');
}
function ShowListDropdownAtClickPoint(){
    alert('close clicked');
}

/*---------------------------------------------------------------------------------------------------*/
// NOTE: using "object.style.visibility" only hides the element...reserves space for it.
//       using "object.style.display" will remove space for the element..not just hide it.."collapsing" the display in browser
// "inline" inserts in-flow, no new line generated
// "block"  often generates a new line...not desired
/*---------------------------------------------------------------------------------------------------*/
function show(object) {
	if (document.getElementById)
	{
		var ele = document.getElementById(object); 
		if(ele != null){
				//ele.style.display = 'block';
				ele.style.display = 'inline-block';
			}
	}
	else if (document.all)
	{
		var ele = document.all[object]; 
		if(ele != null){
			//ele.style.display = 'block';
			ele.style.display = 'inline-block';
		}
	}
}

/*------------------------------------------------*/

function hide(object) {
	if (document.getElementById)
	{
		var ele = document.getElementById(object); 
		if(ele != null){
			ele.style.display = 'none';
		}
	}
	else if (document.all)
	{
		var ele = document.all[object]; 
		if(ele != null){
			ele.style.display = 'none';
		}
	}
}

	


function ReverseContentDisplay(sender,object) {
	if (document.getElementById)
	{
		 if(document.getElementById(object).style.display == 'none' || document.getElementById(object).style.display == '' )
		 {
		    sender.innerText = "[HIDE Mfr. comments...]";
		    sender.innerHTML = "[HIDE Mfr. comments...]";
		    hide_showObj(object);
		 }
		 else 
		 {
		    sender.innerText = "[Mfr comments...]";
		    sender.innerHTML = "[Mfr comments...]";
		    hide_showObj(object);
		 }
	}
	else if (document.all)
	{
		 if(document.all[object].style.visibility == 'hidden') 
		 { 
		    sender.innerHTML = "[HIDE Mfr. comments...]";
		    hide_showObj(object); 
		 }
		 else 
		 {
		    sender.innerHTML = "[Mfr comments...]";
		    hide_showObj(object); 
		 }
	}
}


function hide_showObj(obj) {
   if(document.getElementById) {
      var id_table = document.getElementById(obj).style;
      //Set the object to table-cell if the browser is
      //Firefox and block if it's anything else.
      if(navigator.userAgent.indexOf("Firefox") != -1){
         if(id_table.display == "table-cell") {
            id_table.display = "none";
         }
         else {
            id_table.display = "table-cell";
         }
      }
      else {
         if(id_table.display == "block") {
            id_table.display = "none";
         }
         else {
            id_table.display = "block";
         }
      }
      return false;
   }
   else {
      return true;
   }
}

// Examines checkboxes of specified ASP ID in form, returning bool if any are checked
function AreAnyCheckBoxXChecked(aspCheckBoxID) {
	//re = new RegExp(':' + aspCheckBoxID + '$')  //asp-generated control name starts with a colon and ends with $ (old)
	re = new RegExp(aspCheckBoxID)
	for(i = 0; i < document.forms[0].elements.length; i++) {
		elm = document.forms[0].elements[i]
		if (elm.type == 'checkbox') {
			if (re.test(elm.name)) {
				if (elm.checked == true){ return true; }
			}
		}
	}
}

// Examines checkboxes of specified ASP ID in form, returning bool if any are unchecked
function AreAnyCheckBoxXUnChecked(aspCheckBoxID) {
	//re = new RegExp(':' + aspCheckBoxID + '$')  //asp-generated control name starts with a colon and ends with $ (old)
	re = new RegExp(aspCheckBoxID)
	for(i = 0; i < document.forms[0].elements.length; i++) {
		elm = document.forms[0].elements[i]
		if (elm.type == 'checkbox') {
			if (re.test(elm.name)) {
				if (elm.checked == false){ return true; }
			}
		}
	}
}










