<!--
function jsOpenWindow(filename, width, height)
{
        window.open(filename, "Window_" + Math.floor(Math.random()*110),
        "toolbar=no,width=" + width + ",height=" + height + ",directories=no,status=yes,location=no,scrollbars=yes,resizable=yes,menubar=no");
}

function jsOpenWindow2(filename, width, height)
{
        window.open(filename,"Window2",
        "toolbar=no,width=" + width + ",height=" + height + ",directories=no,status=yes,location=no,scrollbars=yes,resizable=yes,menubar=no");
}

function Link(s)
{
  window.self.location.href = s.options[s.selectedIndex].value;
}

function GetSelectedListBox(sListBoxName)
{
    return(document.getElementById(sListBoxName).options[document.getElementById(sListBoxName).options.selectedIndex].value);
}

function GetSelectedListBoxValue(sListBoxName)
{
    return(document.getElementById(sListBoxName).options[document.getElementById(sListBoxName).options.selectedIndex].text);
}

function AlertFocus(sMessage, sControl)
{
	alert(sMessage);
	document.getElementById(sControl).focus();
	return(false);
}


function Disable()
{
  if (event.button == 2)
		alert('What ... ?');
}

function GetVal(divName)
{
	return(document.getElementById(divName).value);
}

function HideDiv(divName)
{
    document.getElementById(divName).style.display = 'NONE';
}

function ShowDiv(divName)
{
    document.getElementById(divName).style.display = 'BLOCK';
}

function ShowHideDiv(divName)
{
    document.getElementById(divName).style.display = (document.getElementById(divName).style.display == 'block') ? 'none' : 'block';
}

function CloseWindow()
{
    window.close();
    window.opener.location = window.opener.location.pathname + window.opener.location.search.replace("action", "noaction");
}

function CloseWindow2()
{
    window.close();
    window.opener.location=window.opener.location.pathname;
}


// Function for Expanding and Contracting the Messenger Groups

function displaySubs(the_sub)
{
  if (document.getElementById(the_sub).style.display=="")
  {
    document.getElementById(the_sub).style.display = "none";
	document.getElementById("img" + the_sub).src = "../images/expand.gif";
	return
  }
  else
    document.getElementById("img" + the_sub).src = "../images/contract.gif";

  document.getElementById(the_sub).style.display = "";
}


function MM_swapImgRestore()
{ //v3.0
  var i,x,a=document.MM_sr;

  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
    x.src=x.oSrc;
}

function MM_preloadImages()
{ //v3.0
  var d=document;
  if(d.images)
  {
    if(!d.MM_p)
      d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0)
      {
        d.MM_p[j]=new Image;
        d.MM_p[j++].src=a[i];
      }
  }
}

function MM_findObj(n, d)
{ //v4.0
  var p,i,x;
  if(!d)
    d=document;

  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document;
    n=n.substring(0,p);
  }

  if(!(x=d[n])&&d.all)
    x=d.all[n];

  for (i=0;!x&&i<d.forms.length;i++)
    x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
    x=MM_findObj(n,d.layers[i].document);

  if(!x && document.getElementById)
    x=document.getElementById(n);

  return x;
}

function MM_swapImage()
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array;
  
  for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null)
    {
      document.MM_sr[j++]=x;
      if(!x.oSrc)
        x.oSrc=x.src;
      x.src=a[i+2];
    }
}

// Credit Card Functions
function mod10( cardNumber )
{ // LUHN Formula for validation of credit card numbers.
	var ar = new Array( cardNumber.length );
	var i = 0,sum = 0;

	for( i = 0; i < cardNumber.length; ++i ) {
		ar[i] = parseInt(cardNumber.charAt(i));
	}

	for( i = ar.length -2; i >= 0; i-=2 ) { // you have to start from the right, and work back.
		ar[i] *= 2;							 // every second digit starting with the right most (check digit)
		if( ar[i] > 9 ) ar[i]-=9;			 // will be doubled, and summed with the skipped digits.
	}										 // if the double digit is > 9, add those individual digits together

	for( i = 0; i < ar.length; ++i ) {
		sum += ar[i];						 // if the sum is divisible by 10 mod10 succeeds
	}
	return (((sum%10)==0)?true:false);
}

function expired( month, year )
{
	var now = new Date();							// this function is designed to be Y2K compliant.
	var expiresIn = new Date(year,month,0,0,0);		// create an expired on date object with valid thru expiration date
	expiresIn.setMonth(expiresIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second of expired month
	if( now.getTime() < expiresIn.getTime() ) return false;
	return true;									// then we get the miliseconds, and do a long integer comparison
}

function fnVisible(varElement,value)
{
	if(value=='')
		value=0;

	if(value==-1) //Toggle
	{
		if(varElement.style.display=='none')
			varElement.style.display='';
		else
			varElement.style.display='none';
	}
	else if(value==1) //Visible
		varElement.style.display='';
	else if(value==0) //not Visible
		varElement.style.display='none';
}

function insertNewOption(targetcombo,newtext,newval)
{
	myOption=new Option();
	myOption.text=newtext;
	myOption.value=newval;
	if (targetcombo.selectedIndex>0)
		insertIndex=targetcombo.selectedIndex;
	else
		insertIndex=targetcombo.options.length;

	targetcombo.options[insertIndex]=myOption;
}

function setFolderName(e, name)
{
	e.value = dirify(name).substr(0,100);
}

function dirify (str)
{
    var s = str.toLowerCase();
    s = s.replace(/&[^;\s]+;/g, '');
    s = s.replace(/[^\w\s]/g, '');
    s = s.replace(/\s+/g, '-');
    return s;
}

function insertNewOptions(targetcombo,sourcecombo)
{
	var cmb1value;
	cmb1value=getCountryId(sourcecombo.value);

	deleteOptions(targetcombo);

	if(arrCat[cmb1value]!=null)
	{
		insertNewOption(targetcombo,'-- Select One --','');
		for(var i=0;i<arrCat[cmb1value].length;i++)
		{
			insertNewOption(targetcombo,arrCat[cmb1value][i][1],arrCat[cmb1value][i][0]+'-'+arrCat[cmb1value][i][1]+'-'+arrCat[cmb1value][i][2]);
		}
	}
	else
	{
		insertNewOption(targetcombo,'-- Select One --','');
	}

}

function deleteOption(targetcombo)
{
	if (targetcombo.selectedIndex>0)
		deleteIndex=targetcombo.selectedIndex;
	else
		deleteIndex=targetcombo.options.length-1;

	targetcombo.options[deleteIndex]=null;
}

function deleteOptions(targetcombo)
{
	while (targetcombo.options.length>0)
	{
 		deleteIndex=targetcombo.options.length-1;
 		targetcombo.options[deleteIndex]=null;
	}
}

function isAlphabetic(val)
{
	if (val.match(/^[a-zA-Z]+$/))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function isValidUserName(val)
{
	if (val.match(/^[a-zA-Z0-9_]+$/))
		return true;
	else
		return false;
}

function isAlphaNumeric(val)
{
	if (val.match(/^[a-zA-Z0-9]+$/))
		return true;
	else
		return false;
}

function isNumeric(val)
{
	if (val.match(/^[0-9]+$/))
	{
		return true;
	}
	else
	{
		return false;
	}

}

function isEmailAddress(val)
{
    val = val.toLowerCase();
	// /^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/
	if (val.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9- ]+)*(\.[a-z]{2,3})+/))
		return true;
	else
		return false;
}


function MultiDimensionalArray(iRows, iCols)
{
		var i;
		var j;
		var a = new Array(iRows);

		for (i=0; i < iRows; i++)
		{
				a[i] = new Array(iCols);
				for (j=0; j < iCols; j++)
					a[i][j] = "";
		}
		return(a);
}

function OptionsList_RemoveSelected(oListName)
{
	if (document.getElementById(oListName).options.selectedIndex >= 0)
		document.getElementById(oListName).options[document.getElementById(oListName).options.selectedIndex] = null;
}

function OptionsList_RemoveAll(oListName)
{
	document.getElementById(oListName).options.length = 0;
}

function toggleChecks( cbElem )
{
	var f = cbElem.form;
	for ( var elem, i = 0; ( elem = f.elements[i]); i++ )
		if ( elem.type == 'checkbox' && elem != cbElem )
			if (elem.checked == true)
				elem.checked = false;
			else
				elem.checked = true;
}

function validEmail(email)
{
	email = trim(email)
	invalidChars = " /:,;"
	if (email == "")
		return false

	for (i=0; i<invalidChars.length; i++)
	{
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1)
			return false
	}

	atPos = email.indexOf("@",1)
	if (atPos == -1)
		return false

	if (email.indexOf("@",atPos+1) > -1)
		return false

	periodPos = email.indexOf(".",atPos)

	if (periodPos == -1)
		return false

	if (periodPos+3 > email.length)
		return false

	return true
}

function notemptystring (stringa)
{
	if (stringa == "")
		return false

	return true
}

function trim(stringa)
{
	while (stringa.charAt(0) == " ")
		stringa = stringa.substring (1,stringa.length)

	while (stringa.charAt(stringa.length-1) == " ")
		stringa = stringa.substring (0,(stringa.length-1))

	return stringa
}

function DoCnt(fieldid, counter)
{
   document.getElementById(counter).value = document.getElementById(fieldid).value.length;
}

function OpenClose(oMenu, oImage, sContractImage, sExpandImage)
{
    var Image1 = new Image;
    Image1.src = sContractImage;


    var Image2 = new Image;
    Image2.src = sExpandImage;


    oMenu.style.display = (oMenu.style.display == 'block') ? 'none' : 'block';
    oImage.src = (oImage.src == Image1.src) ? Image2.src : Image1.src;
}

function getQueryString(index)
{
	var paramExpressions;
	var param
	var val
	paramExpressions = window.location.search.substr(1).split("&");
	if (index < paramExpressions.length)
	{
		param = paramExpressions[index];
		if (param.length > 0) {
			return eval(unescape(param));
		}
	}
	return ""
}

// Radio Button Related Functions
function GetCheckedValue(radioObj)
{
	if(!radioObj)
		return "";

	var radioLength = radioObj.length;
	if(radioLength == undefined)
	{
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	}

	for(var i = 0; i < radioLength; i++)
		if(radioObj[i].checked)
			return radioObj[i].value;
	return "";
}

function setCheckedValue(radioObj, newValue)
{
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
	{
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}

	for(var i = 0; i < radioLength; i++)
	{
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString())
		{
			radioObj[i].checked = true;
		}
	}
}
// End of Radio Button Values




// Right Mouse Click - Context Menu
function mouseSelect(e)
{
	var ie	= document.all
	var ns6	= document.getElementById&&!document.all
	var obj = ns6 ? e.target.parentNode : event.srcElement.parentElement;
	if( isMenu )
	{
		if( overpopupmenu == false )
		{
			isMenu = false ;
			overpopupmenu = false;
			document.getElementById('divContextMenu').style.display = "none" ;
			return true ;
		}
		return true ;
	}
	return false;
}

// POP UP MENU
function ItemSelMenu(e)
{
	var ie	= document.all
	var ns6	= document.getElementById&&!document.all

	var	obj = ns6 ? e.target.parentNode : event.srcElement.parentElement;	
    menuSelObj = obj;
    
    iSelectedItemId = event.srcElement.parentElement.id;
	
    if (ns6)
	{
		document.getElementById('divContextMenu').style.left = e.clientX+document.body.scrollLeft;
		document.getElementById('divContextMenu').style.top = e.clientY+document.body.scrollTop;
	}
	else
	{
		document.getElementById('divContextMenu').style.pixelLeft = event.clientX+document.body.scrollLeft;
		document.getElementById('divContextMenu').style.pixelTop = event.clientY+document.body.scrollTop;
	}

	document.getElementById('divContextMenu').style.display = "";
	isMenu = true;
	return false;
}

function HideRightClick()
{
	isMenu = false ;
	overpopupmenu = false;
	document.getElementById('divContextMenu').style.display = "none" ;
}

//-->
