function checkSearchSetup()
{
  var sSearch = document.getElementById( 'search_right' ).value;
  sSearch = sSearch.replace( / /gi, "" );
  var iManufacturer = document.getElementById( 'where_manufacturer' ).value;
  var rForm = document.getElementById( 'frm_search' );

  if( !sSearch.length && !iManufacturer )
  {
    window.alert("Zadejte hledaný text nebo vyberte výrobce !");
  }
  else
  {
    rForm.submit();
  }
}

function manageNewsletterDependence(clicked)
{
  var newsletterRequired = document.getElementById('newsletterRequired');
  var registerMe = document.getElementById('registerMe');
  
  switch(clicked)
  {
    case 'newsletter':
      if(newsletterRequired.checked)
      {
        registerMe.checked = true;
      }
    break;
    case 'registration':
      if(!registerMe.checked)
      {
        newsletterRequired.checked = false;
      }
    break;
  }
}

function isNotEmpty( checkedVar )
{
	if(checkedVar)
	{
	   return new Array(true, "");
	}
	else
	{
	  return new Array(false, "není vyplněno");
	}
}

function isPostalCode( checkedVar )
{
	if( (parseInt(checkedVar) || parseInt(checkedVar) == 0) && checkedVar.length == 5 )
	{
	   return new Array(true, "");
	}
	else
	{
	  return new Array(false, "není platné PSČ");
	}
}

function isEmail( email )
{
	var regStr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if( !regStr.test(email)){
		return new Array(false, "nemá platný formát");
	}
	return new Array(true, "");
}

function validateUserData(sFormId, aExceptions)
{
  if(aExceptions == undefined) aExceptions = new Array();
  var minPwdLength = 5;
	var maxResultInfoRows = 4;
	var form = document.getElementById(sFormId);
  var requiredFieldsIds = new Array(
		new Array('firstname', 'jméno', 'isNotEmpty'),
		new Array('surname', 'příjmení', 'isNotEmpty'),
		new Array('street', 'ulice, č.p.', 'isNotEmpty'),
		new Array('city', 'město', 'isNotEmpty'),
		new Array('postalCode', 'PSČ', 'isNotEmpty;isPostalCode'),
		new Array('email', 'e-mail', 'isNotEmpty;isEmail'),
		new Array('phone', 'telefon', 'isNotEmpty')
	);
  
	// legal form
  var legalFormCompany = document.getElementById('legalFormCompany');
  if(legalFormCompany.checked)
  {
    legalForm = "company";
    requiredFieldsIds.push(
			new Array('company', 'firma', 'isNotEmpty'),
			new Array('ic', 'IČ', 'isNotEmpty')
		);
	}
	else
	{
	  legalForm = "person";
	}
	// delivery enabled
  var deliveryDisabled = document.getElementById('deliveryDisabled');
  if(deliveryDisabled.checked)
  {
    deliveryDiffers = false;
	}
	else
	{
	  deliveryDiffers = true;
	  requiredFieldsIds.push(
			new Array('daFirstname', 'jméno (dodací adresa)', 'isNotEmpty'),
			new Array('daSurname', 'příjmení (dodací adresa)', 'isNotEmpty'),
			new Array('daStreet', 'ulice, č.p. (dodací adresa)', 'isNotEmpty'),
			new Array('daCity', 'město (dodací adresa)', 'isNotEmpty'),
			new Array('daPostalCode', 'PSČ', 'isNotEmpty;isPostalCode')
		);
	}

	if( deliveryDiffers && legalForm == "company" )
	{
		requiredFieldsIds.push(
			new Array('daCompany', 'firma (dodací adresa)', 'isNotEmpty')
		);
	}
	// kontrola poli
	var result = true;
	var resultInfo = new Array();
	for(i = 0; i < requiredFieldsIds.length; i ++)
	{
	  var fieldId = requiredFieldsIds[i][0];
	  var fieldName = requiredFieldsIds[i][1];
	  var fieldRef = document.getElementById(fieldId);
	  var fieldValue = fieldRef.value;
	  var fieldChecks = (requiredFieldsIds[i][2].indexOf(";") != -1) ? requiredFieldsIds[i][2].split(";") : new Array(requiredFieldsIds[i][2]);

    fieldRef.className = 'rqd'; // reset border color na default

	  for(j = 0; j < fieldChecks.length; j ++) // projede vsechny typy kontrol pro kazde pole
	  {
			aCheckResults = eval(fieldChecks[j] + "(fieldValue);");
			checkResult = aCheckResults[0];
			checkInfo = aCheckResults[1];
	    if( !checkResult )// nalezena chyba pri jedne z def. kontrol pole
			{
				result = false;
				resultInfo.push('Pole <strong>' + fieldName + '</strong> ' + checkInfo + '.');
				fieldRef.className = 'rqd incorrectlyFilled';
				fieldRef.value = "";
				break;
			}
		}
	}
	// EXCEPTIONS
	for(i = 0; i < aExceptions.length; i ++)
	{
    sException = aExceptions[i];
    
    switch(sException)
    {
      case 'regPwd':
        var pwd = document.getElementById('regPwd');
        var pwdConfirmation = document.getElementById('regPwdConfirmation');
        pwd.className = 'rqd';
        pwdConfirmation.className = 'rqd';
        // equal pwds
        if( pwd.value != pwdConfirmation.value )
        {
          result = false;
          resultInfo.push( "<strong>Hesla</strong> nejsou shodná." );
          pwdConfirmation.className = 'rqd incorrectlyFilled';
          pwdConfirmation.value = "";
        }
        // min length
        if( pwd.value.length < minPwdLength )
        {
          result = false;
          pwd.className = 'rqd incorrectlyFilled';
          pwdConfirmation.className = 'rqd incorrectlyFilled';
          resultInfo.push( "<strong>Heslo</strong> musí být minimálně " + minPwdLength + " znaků dlouhé." );
          pwd.value = "";
          pwdConfirmation.value = "";
        }
      break;
      case 'legalAgreement':
        var legalAgreement = document.getElementById('legalAgreement');
        if( !legalAgreement.checked )
        {
          result = false;
          resultInfo.push( "<strong>Souhlas s obchodními podmínkami</strong> je vyžadován." );
        }
      break;
    }
  }
	
	
	// RESULT
	if(!result)
	{
	  if(resultInfo.length > 4)// oseknuti na max 4 prvky pole
	  {
	    resultInfo = resultInfo.slice(0, maxResultInfoRows);
	    resultInfo.push("<em>... počet chyb je větší než dovoluje zobrazení ...</em>");
		}
		resultInfo.push("<strong>Chybně vyplněná pole byla pro přehlednost zvýrazněna.</strong>");
	  changeErrContent('warning', 'Dopustil/a jste se chyb !', resultInfo);
	  switchErr("show");
	}
	else
	{
	  form.submit();
	}
}

function switchDeliveryAddressBox(action)
{
	// legal form
  var legalFormCompany = document.getElementById('legalFormCompany');
  if(legalFormCompany.checked)
  {
    legalForm = "company";
	}
	else
	{
	  legalForm = "person";
	}
	// delivery enabled
  var deliveryDisabled = document.getElementById('deliveryDisabled');
  if(deliveryDisabled.checked)
  {
    deliveryDiffers = 0;
	}
	else
	{
	  deliveryDiffers = 1;
	}

	// fields, rows, boxes
	var deliveryAddressBox = document.getElementById('deliveryAddressBox');
	var daCompany = document.getElementById('daCompany');
	var daCompanyRow = document.getElementById('daCompanyRow');
  var daFirstname = document.getElementById('daFirstname');
  var daSurname = document.getElementById('daSurname');
  var daStreet = document.getElementById('daStreet');
  var daCity = document.getElementById('daCity');
  var daPostalCode = document.getElementById('daPostalCode');
  
  // actions
	switch(action)
	{
	  case 'disable':
	    // hide box
	    deliveryAddressBox.style.display = "none";
	    // reset fields
	    daCompany.value = "";
  		daFirstname.value = "";
  		daSurname.value = "";
  		daStreet.value = "";
  		daCity.value = "";
  		daPostalCode.value = "";
	  break;
	  case 'enable':
	    // show box
	    deliveryAddressBox.style.display = "block";
	    // conditional COMPANY DISPLAY
	    daCompanyRow.style.display = (legalForm == "company" ? 'block' : 'none');
	  break;
	}
}

function switchLegalForm()
{
	// legal form
  var legalFormCompany = document.getElementById('legalFormCompany');
  if(legalFormCompany.checked)
  {
    legalForm = "company";
	}
	else
	{
	  legalForm = "person";
	}
	// fields adn divs to manage
  var company = document.getElementById('company');
  var companyRow = document.getElementById('companyRow');
  var daCompany = document.getElementById('daCompany');
  var daCompanyRow = document.getElementById('daCompanyRow');
  var ic = document.getElementById('ic');
  var icRow = document.getElementById('icRow');
  var dic = document.getElementById('dic');
  var dicRow = document.getElementById('dicRow');

  // actions
	switch(legalForm)
	{
	  case 'person':
	    // hide rows
	    companyRow.style.display = "none";
	    daCompanyRow.style.display = "none";
	    icRow.style.display = "none";
	    dicRow.style.display = "none";
	    // reset fields
	    company.value = "";
	    daCompany.value = "";
  		ic.value = "";
  		dic.value = "";
	  break;
	  case 'company':
	    // show rows
	    companyRow.style.display = "block";
	    daCompanyRow.style.display = "block";
	    icRow.style.display = "block";
	    dicRow.style.display = "block";
	  break;
	}
}

function checkIntegerOnly(inputToCheckId, defaultValue)
{
	var inputToCheck = document.getElementById(inputToCheckId);

	if(!isNaN(parseInt(inputToCheck.value)))
  {
    inputToCheck.value = parseInt(inputToCheck.value);
  }
  else
  {
    inputToCheck.value = defaultValue;
  }
}

function showInformation(str)
{
  window.alert(str);
}

function helpAvailabilityIcon(str)
{
  window.alert(str);
}

function setCatalogueView(view)
{
	var frmView = document.getElementById('frm_catalogueView');
	var inputView = document.getElementById('catalogueView');

	inputView.value = view;
	frmView.submit();
}

function setCatalogueOrderByDirection(orderByDirection)
{
	var frmOrderBy = document.getElementById('frm_orderBy');
	var direction = document.getElementById('catalogueOrderByDirection');

	direction.value = orderByDirection;
	frmOrderBy.submit();
}

function pd_checkVariant(variantStamp)
{
	var selectedVariant = document.getElementById('pd_variant_' + variantStamp);
	var selectedRow = document.getElementById('pd_variant_row_' + variantStamp);
	var variantTable = document.getElementById('pd_tbl_variants');
	//variantTable.rows[0].style.border = "10px solid #000000";
	var variantRows = variantTable.getElementsByTagName('tr');
	var numVariantRows = variantRows.length;

	for(i = 1; i < numVariantRows; i ++)
	{
		var variantRow = variantRows[i];
		var rowClass = variantRow.className;
		if(rowClass.indexOf("odd") == -1)
		{
			variantRow.className = "noClass";
		}
		else
		{
			variantRow.className = "odd";
		}
	}
	
	selectedVariant.checked = "checked";
	var selectedRowClass = selectedRow.className;
	if(selectedRowClass.indexOf("odd") == -1)
	{
		selectedRow.className = "checked";
	}
	else
	{
		selectedRow.className = "odd checked";
	}
}

function loading(){
			
	var data = this.req.responseXML.documentElement;
	var iCount = data.getElementsByTagName('ITEM')[0].firstChild.nodeValue;
	var btnDisplayResults = document.getElementById('btn_displayCatalogueFilterResults');
	var numFilterResults = document.getElementById('numFilterResults');
	var numCatalogueTotal = document.getElementById('numCatalogueTotal').value;
	
	// CSS reaction
	if(iCount != numCatalogueTotal)
	{
		numFilterResults.style.background = "#BC2C1E";
		numFilterResults.style.color = "#DDD4CE";
		if(iCount == 0)
		{
		  btnDisplayResults.style.textDecoration = "line-through";
		}
		else
		{
			btnDisplayResults.style.textDecoration = "none";
		}
	}
	else
	{
		numFilterResults.style.background = "#DDD4CE";
		numFilterResults.style.color = "#BC2C1E";
		btnDisplayResults.style.textDecoration = "none";
	}
	
	
	numFilterResults.innerHTML = iCount;
}

function checkFilterSetup()
{
  var categoryId = document.getElementById('categoryId').value;
  var manufacturerId = document.getElementById('manufacturerId').value;
  var userType = document.getElementById('userType').value;

  var numFilterResults = document.getElementById('numFilterResults');
  var btnDisplayResults = document.getElementById('btn_displayCatalogueFilterResults');
  var enableAjaxQuestion = true;
  var filterManufacturerCollection = document.getElementsByName('filterManufacturer[]');
  var filterAvailabilityCollection = document.getElementsByName('filterAvailability[]');
  var priceFrom = document.getElementById('filterPriceFrom');
  var priceTo = document.getElementById('filterPriceTo');
  var filters = document.getElementById('frm_filters');

  // filter manufacturers
  var filterManufacturerValues = new Array();
  for(var i = 0; i < filterManufacturerCollection.length; i ++)
  {
    eval("var manufacturerChecked = document.getElementById('manufacturer_" + filterManufacturerCollection[i].value + "').checked;");
    if(manufacturerChecked) filterManufacturerValues.push(filterManufacturerCollection[i].value);
  }
  if(!filterManufacturerValues.length) enableAjaxQuestion = false;

  // filter availability
  var filterAvailabilityValues = new Array();
  for(var i = 0; i < filterAvailabilityCollection.length; i ++)
  {
    eval("var availabilityChecked = document.getElementById('availability_" + filterAvailabilityCollection[i].value + "').checked;");
    if(availabilityChecked) filterAvailabilityValues.push(filterAvailabilityCollection[i].value);
  }
  if(!filterAvailabilityValues.length) enableAjaxQuestion = 0;

  // filter prices
  if(!isNaN(parseInt(priceFrom.value)))
  {
    priceFrom.value = parseInt(priceFrom.value);
  }
  else
  {
    priceFrom.value = "";
  }
  if(!isNaN(parseInt(priceTo.value)))
  {
    priceTo.value = parseInt(priceTo.value);
  }
  else
  {
    priceTo.value = "";
  }

  if(!enableAjaxQuestion) {
  	btnDisplayResults.style.textDecoration = "line-through";
		numFilterResults.style.background = "#BC2C1E";
		numFilterResults.style.color = "#DDD4CE";
  	numFilterResults.innerHTML = "0";
  }
  
  else{
      //document.getElementById('test').innerHTML = "/ajax/catalogueFiltr.php?iManufacturers="+filterManufacturerValues+"&iAvailability="+filterAvailabilityValues+"&iPriceFrom="+priceFrom.value+"&iPriceTo="+priceTo.value+"&categoryId="+categoryId+"&manufacturerId="+manufacturerId+"&userType="+userType;
    	var ajax = new net.ContentLoader("/ajax/catalogueFiltr.php?iManufacturers="+filterManufacturerValues+"&iAvailability="+filterAvailabilityValues+"&iPriceFrom="+priceFrom.value+"&iPriceTo="+priceTo.value+"&categoryId="+categoryId+"&manufacturerId="+manufacturerId+"&userType="+userType, loading);
        
  }
  
  return enableAjaxQuestion;
  
}

function submitFilters()
{
  
  var passed = checkFilterSetup();
  if(passed)
  {
    
    if (document.getElementById('numFilterResults').innerHTML == 0) {
    
    	window.alert("Vámi nastavený filtr vrací nulový počet výsledků.");
     	return false;	
	} else return true;
  }
  else
  {   
  	window.alert("Vámi nastavený filtr vrací nulový počet výsledků. Zkuste snížit omezení filtrů.");
    return false;
  }
}

function manageProductCompare(productId, action)
{
	var productCompareForm = document.getElementById('productCompareRequest');
	var productCompareId = document.getElementById('productCompareId');
	var productCompareAction = document.getElementById('productCompareAction');

	productCompareId.value = productId;
	productCompareAction.value = action;
	productCompareForm.submit();
}

function compareDisabledNotice()
{
	window.alert(" V jednu chvíli je možné srovnávat pouze 4 produkty. chcete-li některý z již vybraných vyměnit za jiný, odstraňte nejdříve tento vybraný produkt ze seznamu k porovnání.");
}

function switchCssIconCompare(id, cssClass)
{
	var element = document.getElementById(id);
	element.className = "cssClass";
}

function changeDeliveryOption() {
	
	var rInput = document.getElementById("doAction"); // jde o klasicke "do", ale kvuli ... IE se to musi jmenovat jinak (konfrontace nekolika name="do" a jednoho id="do")
	rInput.value = 'changeDeliveryOption';
	
	var rForm = document.getElementById("frm_payment");
	rForm.submit();
	
}

function manageQtyWidth(id, action)
{
	var widthExtended = 30;
	var widthContracted = 16;
	var elementQty = document.getElementById(id);
	switch(action)
	{
	  case 'extend':
	    elementQty.style.width = widthExtended + 'px';
	  break;
	  case 'contract':
	  	elementQty.style.width = widthContracted + 'px';
	  break
	  default:
	  break;
	}
}

function switchElementLoading()
{
	var data = this.req.responseXML.documentElement;
	var elementAlert = data.getElementsByTagName('ALERT')[0].firstChild.nodeValue;
	var action = data.getElementsByTagName('ACTION')[0].firstChild.nodeValue;
	var viewAlert = Number(data.getElementsByTagName('VIEW_ALERT')[0].firstChild.nodeValue);

	if(viewAlert == "1" && action == "hide")
	{
		window.alert(elementAlert + " jsou skryté. Chcete-li je opět zobrazit, klepněte na stejné tlačitko.");
	}
}

function switchElement(id)
{
  var element = document.getElementById(id);
  var elementBtmHsep = document.getElementById(id + "Hsep");
  var elementDisplayStatus = element.style.display;
  
  if(elementDisplayStatus == "none" || elementDisplayStatus == undefined)
  {
    var action = "unhide";
    element.style.display = "block";
    elementBtmHsep.style.background = "none";
  }
  else
  {
  	var action = "hide";
    element.style.display = "none";
    elementBtmHsep.style.background = "url('/bg/hsep_line_lightocher.gif') repeat-x";
  }
  var url = "../ajax/switch_element.php?element="+ id + "&action=" + action;
  //window.alert(url);
	var ajax = new net.ContentLoader(url, switchElementLoading);
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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_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_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];}
}

function setPayment(choice){
	var element = document.getElementById('payment');
	if(choice == 4 && element.value == 1){
	  element.value = 2;
	  window.alert("Pro tento způsob dopravy je možnost platby pouze hotově. Způsob platby byl automaticky nastaven.");
	}else if (choice != 4 && element.value == 2){
	  element.value = 1;
	  window.alert("Pro tento způsob dopravy je možnost platby pouze dobírkou. Způsob platby byl automaticky nastaven.");
	}
}

function setShipping(choice){
	var element = document.getElementById('shipping');
	if(choice == 1 && element.value == 4){
	  element.value = 1;
	  window.alert('Způsob platby dobírkou není možný v případě osobního odběru. Způsob dopravy byl automaticky změněn na "Česká pošta - obyčejný balík".');
	}else if (choice == 2 && element.value != 4){
	  element.value = 4;
	  window.alert("V hotovosti lze platit pouze při osobním odběru. Způsob dopravy byl automaticky nastaven.");
	}
}

function cartadd(frm, session_id, currency, user_type){

	if(user_type == '') user_type = '1';
	var url = "../ajax/cart_add.php?currency="+currency+"&user_type="+user_type+"&session_id="+session_id+"&productStamp="+frm.productStamp.value+"&qty="+frm.qty.value;
	//window.location=url;
	var ajax = new net.ContentLoader(url, cartloading);

}

function zmenaHledani() {

	var element = document.getElementById('hledani');

	if (element.value == 'hledat...') {
		element.value = '';
	}

}

function cartloading(){
	var elmnt = document.getElementById('cart-ajax');
	var data = this.req.responseXML.documentElement;
	var ks = Number(data.lastChild.firstChild.nodeValue);
	var cena = data.firstChild.firstChild.nodeValue;
	if(!isNaN(ks)){
		elmnt.innerHTML = ks + "<br />"+cena;
		alert("Vybrané zboží bylo přidáno do košíku. Děkujeme.");
	}
}


function watchDog(e, productId){
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.documentElement.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop;
	}


	var frm = document.getElementById('frm_watchDog');
	frm.wdProductId.value = productId;
	var wdBox = document.getElementById('watchDog');

	wdBox.style.top = (posy + 5) + "px";
	wdBox.style.left = (posx +5) + "px";
	wdBox.style.display = 'block';
}

function addItem(box, id) {
   var sel = document.getElementById(box);
   var opt = document.createElement("OPTION");
   opt.value = id;

	var txt = document.createTextNode(id);
	opt.appendChild(txt);
   sel.appendChild(opt);
}


function ValidateEmail( email){
	var regStr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if( !regStr.test(email)){
		alert("Vámi zadaná e-mailová adresa nemá platný formát.");
		return false;
	}
	return true;
}

function ValidateEmailNotStrict( email){
	if(email == '') return true;
	var regStr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if( !regStr.test(email)){
		alert("Vámi zadaná e-mailová adresa nemá platný formát.");
		return false;
	}
	return true;
}

function ValidateNotEmpty( values){
	for(var i=0; i<values.length; i++){

		if(values[i] == ''){
			alert("Vyplňte prosím požadované údaje.");
			return false;
		}
	}
	return true;
}

function ValidateAreNumbers( values  ){
	var regStr = /^(\d)+$/;
	for(var i=0; i<values.length; i++){
		if(!regStr.test(values[i])){
			alert("Do číselných polí prosím vložte nezáporné celé číslo.");
			return false;
		}
	}
	return true;
}

function fFormOnlyEmail( evt )
{
	var charCode = (evt.which) ? evt.which : window.event.keyCode; 
 	var keyChar = String.fromCharCode(charCode); 
    var re = /^([a-zA-Z0-9_\.\-@])+$/;
    if (charCode <= 13) 
    { 
        return true; 
    } 
    return re.test(keyChar); 
}

function fFormOnlyNumber( evt )
{
	var charCode = (evt.which) ? evt.which : window.event.keyCode; 
 	var keyChar = String.fromCharCode(charCode); 
    var re = /^(\d)+$/;
    if (charCode <= 13) 
    { 
        return true; 
    } 
    return re.test(keyChar);  
}

function ShowTooltip(e, tip)
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.documentElement.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop;
	}

	var tooltipBox = document.getElementById('tooltip');
	tooltipBox.innerHTML = tip;

	tooltipBox.style.top = (posy + 5) + "px";
	tooltipBox.style.left = (posx +5) + "px";
	tooltipBox.style.display = 'block';

}

function HideTooltip(){

	var tooltipBox = document.getElementById('tooltip');

	tooltipBox.style.display = 'none';
}

function fOpenArconWindow(sDomain , sFileName)
{
	if( sFileName=="" || sFileName==null || sFileName==undefined ) return false;
    var width = 400;
    var height = 500;
    var sArconHtml = sDomain+"/arcon/?arcon="+sFileName;
	var myWindow;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(sArconHtml, "subWind", windowFeatures);
    myWindow.focus();
    return false;
}
