// FormChek.js
//
// SUMMARY
//
// This is a set of JavaScript functions for validating input on 
// an HTML form.  Functions are provided to validate:
// p is an abbreviation for "prompt"

var browserok=window.ActiveXObject
if (browserok)
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

var pEntryPrompt = "Please enter a "
var pStateCode = "2 character code (like CA)."
var pZIPCode = "5 or 9 digit U.S. ZIP Code (like 94043)."
var pUSPhone = "10 digit U.S. phone number (like 415 555 1212)."
var pWorldPhone = "international phone number."
var pSSN = "9 digit U.S. social security number (like 123 45 6789)."
var pEmail = "valid email address (like foo@bar.com)."
var pCreditCard = "valid credit card number."
var pDay = "day number between 1 and 31."
var pMonth = "month number between 1 and 12."
var pYear = "2 or 4 digit year number."



// Attempting to make this library run on Navigator 2.0,
// so I'm supplying this array creation routine as per
// JavaScript 1.0 documentation.  If you're using 
// Navigator 3.0 or later, you don't need to do this;
// you can use the Array constructor instead.

function popUPwin(url,width,height,id) {
	javascript:client_window=window.open(url ,'_blank',' width=' + width + ' ,height=' + height + ' ,left=0, top=0, location=no, menubar=no, resizable=yes, scrollbars=no');
	client_window.focus() 
}

function popUPwinScroll(url,width,height,id) {
	javascript:client_window=window.open(url ,'_blank',' width=' + width + ' ,height=' + height + ' ,left=0, top=0, location=no, menubar=no, resizable=yes, scrollbars=yes');
	client_window.focus() 
}

function ShowHideObj(objName)
{
	if (document.getElementById(objName).style.display=='none')
	{
		document.getElementById(objName).style.display='block';
	}
	else
	{
		document.getElementById(objName).style.display='none';
	}
}


function IsCardMatch (cardType, cardNumber)  {
  return isCardMatch (cardType, cardNumber);
}

function loadXML(xmlFile)
{
	xmlDoc.async='false';
	xmlDoc.onreadystatechange=verify;
	xmlDoc.load(xmlFile);
	ticker=xmlDoc.documentElement;
}

function verify()
{ 
	if (xmlDoc.readyState != 4)
	{ 
		return false; 
	}
}

function ShowProductDesc(e,id,AID)
{
var strHTML
strHTML = 'ofer testing';

	if (browserok){
		loadXML('getItemDic.aspx?AID=' + AID );
		strHTML = "<b>" + ticker.childNodes(0).getAttribute('Atitle') + "</b></br>" +  ticker.childNodes(0).getAttribute('AdescS') ;
                   }
                   
ShowToolTip(e,strHTML,id);

}

function ShowDic(e,id,AID)
{
var strHTML
strHTML = 'ofer testing';

	if (browserok){
		loadXML('getItemDic.aspx?AID=' + AID );
		strHTML = "<b>" + ticker.childNodes(0).getAttribute('Atitle') + "</b></br>" +  ticker.childNodes(0).getAttribute('AdescS') ;
                   }
                   
ShowToolTip(e,strHTML,id);

}

function ShowToolTip(e,strHTML,id)
{

var isInit = -1;
  var div,divWidth,divHeight;
  var xincr=10,yincr=10;
  var animateToolTip =false;
  var html;
  
   div = document.getElementById(id);
   if(div==null) return;
   
//   if((div.style.width=="" || div.style.height==""))
//   {alert("Both width and height must be set");
//   return;}
   
   //divWidth = parseInt(div.style.width);
   //divHeight= parseInt(div.style.height);
   divWidth = parseInt(div.offsetHeight);
   divHeight= parseInt(div.offsetHeight);
   
  // alert(div.offsetHeight);
   
   if(div.style.overflow!="hidden")div.style.overflow="hidden";
   if(div.style.display!="none")div.style.display="none";
   if(div.style.position!="absolute")div.style.position="absolute";
   //if(div.style.float!="left")div.style.float="left";
    //if(div.style.z-index!="1")div.style.z-index="1";
    
    
    var newPosx,newPosy,height,width;
    if(typeof( document.documentElement.clientWidth ) == 'number' ){
    width = document.body.clientWidth;
    height = document.body.clientHeight;}
    else
    {
    width = parseInt(window.innerWidth);
    height = parseInt(window.innerHeight);
    
    }
    var curPosx = (e.x)?parseInt(e.x):parseInt(e.clientX);
    var curPosy = (e.y)?parseInt(e.y):parseInt(e.clientY);
    
    if(strHTML!=null)
    {html = strHTML;
     div.innerHTML=html;
    }
    if((curPosx+divWidth+10)< width)
    newPosx= curPosx+10;
    else
    newPosx = curPosx-divWidth;

    if((curPosy+divHeight)< height)
    newPosy= curPosy;
    else
    newPosy = curPosy-divHeight-10;

   if(window.pageYOffset)
   { newPosy= newPosy+ window.pageYOffset;
     newPosx = newPosx + window.pageXOffset;}
   else
   { newPosy= newPosy+ document.body.scrollTop;
     newPosx = newPosx + document.body.scrollLeft;}

    div.style.display='block';
    //debugger;
    //alert(document.body.scrollTop);
    div.style.top= newPosy + "px";
    div.style.left= newPosx+ "px";

    div.focus();
    if(animateToolTip){
    div.style.height= "0px";
    div.style.width= "0px";
    ToolTip.animate(div.id,divHeight,divWidth);}
      
    



}

