/*
// *********************************************************************************************** //
// T7 Instant 
// © Copyright David Tracz, Bitefish
// All Rights Reserved, www.bitefish.com
// *********************************************************************************************** //
*/
var gIE = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var gFX = (navigator.userAgent.indexOf('Firefox') >= 0) ? 1 : 0; 

function SetBookmark()
{
	if(document.all)
		window.external.AddFavorite(location.href,document.title);
	else
	{
		if(window.sidebar)
			window.sidebar.addPanel(document.title,location.href,'');
	}
}

function SwitchCheckbox(pid)
{
	if (document.getElementById(pid).checked == true)
		document.getElementById(pid).checked = false;
	else
		document.getElementById(pid).checked = true;
}

function SwitchDiv(pid,pset)
{
	if (document.getElementById(pid).style.display == "block")
		document.getElementById(pid).style.display = "none";
	else
		document.getElementById(pid).style.display = "block";
		
	document.getElementById(pset).value = document.getElementById(pid).style.display;
}



function ToggleVisibility(pDiv)
{
	if (document.getElementById(pDiv).style.display == "block")
		document.getElementById(pDiv).style.display = "none";
	else
		document.getElementById(pDiv).style.display = "block";
}


function ToggleVisibilityList(pList,pSelected)
{
	var pListArray = pList.split(",");
	for(i = 0; i < pListArray.length; i++)
	{
		if (pListArray[i] != "")
		{
			if (pListArray[i] == pSelected)
				document.getElementById(pSelected).style.display = "block";
			else
				document.getElementById(pListArray[i]).style.display = "none";
		}
	}
}

function ShowDiv(pid)
{
	if (pid != "")
		document.getElementById(pid).style.display = "block";
}

function HideDiv(pid)
{
	if (pid != "")
		document.getElementById(pid).style.display = "none";
}

function HideDivList(pList)
{
	var pListArray = pList.split(",");
	for(i = 0; i < pListArray.length; i++)
	{
		if (pListArray[i] != "")
		{
			document.getElementById(pListArray[i]).style.display = "none";
		}
	}

}




function ScrollTo(pid)
{
	document.getElementById(pid).scrollIntoView(true);
}


function SwitchDivSimple(pid)
{
	if (document.getElementById(pid).style.display == "block" || 
			document.getElementById(pid).style.visibility == "visible")
	{		 
		document.getElementById(pid).style.visibility = "collapse";
		document.getElementById(pid).style.display = "none";
	}
	else
	{
		document.getElementById(pid).style.visibility = "visible";
		document.getElementById(pid).style.display = "block";
	}
}


function ConfirmLink(pmessage,purl)
{
	if (window.confirm(pmessage) == true)
	{
		window.location.href = purl;
	}
}

function ParentConfirmLink(pmessage,purl)
{
	if (window.confirm(pmessage) == true)
	{
		parent.location.href = purl;
	}
}

function ReloadLogin(pMode,pUrl)
{
	if (pMode == "1")
	{
		window.close();
		opener.focus();
		opener.location.href = pUrl;
	}
	else
	{
		window.location.href = pUrl;		
	}
}


function Redirect(purl)
{
	if (purl == "")
	{
		purl = window.location.href;	
	}
	
	window.location.href = purl;
}


function OpenGallerySlide(pWebRoot,pId,pWidth,pHeight,pImagePath,pCloseLabel,pShadow)
{
	var sTop = 0;
	var sLeft = 0;
	var sWidth = pWidth;
	var sHeight = pHeight;
	var sPadding = 25;
	
	//z-index:;
	var iv = "<div style=\"position:absolute;top:"+sTop+"px;left:"+sLeft+"px;width:"+sWidth+"px;height:"+sHeight+"px;";
	iv += "padding:"+sPadding+"px;background-image:url("+pWebRoot+"/image/Shadow"+pShadow+".png);cursor:pointer;\" ";
	iv += " onclick=\"setHtml('"+pId+"','');\" title=\""+pCloseLabel+"\">";
	
	iv += "<img src=\""+pImagePath+"\" border=\"0\" alt=\"\" /></div>";
	
	setHtml(pId,iv);
}


function OpenDialog(purl,pname,pwidth,pheight)
{
	psize = "";
	if (pwidth > 0 && pheight > 0)
	{
		if (gIE)
		{
			pwidth += 24;
			pheight += 20;
		}
		psize = "width="+ pwidth +",height="+ pheight +",";
	}
	dialog = window.open(purl,pname,psize + "resizable=yes,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no",true);
	
	wScreenX = ((screen.width-(pwidth*1))/2);
	wScreenY = ((screen.height-(pheight*1))/2);
	
// 	if (navigator.appName != "Microsoft Internet Explorer")
		dialog.moveTo(wScreenX,wScreenY);
	dialog.focus();
}



function OpenDialogAP(purl,pname,pwidth,pheight,pX,pY)
{
	psize = "";
	if (pwidth > 0 && pheight > 0)
	{
		if (gIE)
		{
			pwidth += 24;
			pheight += 20;
		}
		psize = "width="+ pwidth +",height="+ pheight +",";
	}
	
		
	dialog = window.open(purl,pname,psize + "resizable=yes,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no",true);
	dialog.moveTo(pX,pY);
	dialog.focus();
}



function FormSetField(pid,pvalue)
{
	document.getElementById(pid).value = pvalue;
 	FormSubmit();
}

function FormSubmit()
{
	FormSubmitByIndex(0);
}


function ConfirmSubmit(pmessage,pIndex,pField,pSet)
{
	var pContinue = false;
	
	if (pmessage == "")
		pContinue = true;
	else
		pContinue = window.confirm(pmessage);	
	
	if (pContinue == true)
	{
		if (pField != "")
			SetField(pField,pSet);
			
		FormSubmitByIndex(pIndex);
	}
}


function FormSubmitByIndex(pIndex)
{
	document.forms[pIndex].submit();
}

function ReloadFrame(pid)
{
	document.getElementById(pid).location.reload(true);
}

function SetField(pid,pvalue)
{
	document.getElementById(pid).value = pvalue;
}

function GetField(pid)
{
	return document.getElementById(pid).value;
}


function SwitchUri(pValue,pPrimaryUri,pSecondaryUri)
{
	if (pValue != "")
		return pPrimaryUri
	else
		return pSecondaryUri
}




function SetCss(pid,pCssText)
{
	document.getElementById(pid).style.cssText = pCssText;
}



function SetCssClass(pid,pCssClass)
{
	document.getElementById(pid).className  = pCssClass;
}
 

function SetCssClassList(pList,pCssClass)
{
	var pListArray = pList.split(",");
	for(i = 0; i < pListArray.length; i++)
	{
		if (pListArray[i] != "")
			SetCssClass(pListArray[i],pCssClass);
	}

}

function Chie(pId,pAction,pPar,pValue,pAdditional)
{
	var pIE = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
	if (pIE)
		document[pId].jCall(pAction,pPar,pValue,pAdditional);
	else
		document.embeds[pId].jCall(pAction,pPar,pValue,pAdditional);
}



function FrameGoTo(pFrame,pUrl)
{
	window.frames[pFrame].location = pUrl;	
}

function SetImage(pPath,pId,pName)
{
	document.getElementById(pId).src = pPath + "/" + pName;
}

function MConcat(pA,pB,pQuery)
{	
	var pC = "@";
	document.location = "mailto:" + pA + pC + pB + pQuery;	
}



function getHtml(pId)
{
  var rv = "";
  
  try
  { 
    rv = document.getElementById(pId).innerHTML;
  } 
  catch(e)
  { 
  }   
  
  return rv;
}

function setHtml(pId,pValue)
{
  document.getElementById(pId).innerHTML = pValue;
}




function getValue(pId)
{
  var rv = "";
  
  try
  { 
    rv = document.getElementById(pId).value;
  } 
  catch(e)
  { 
  }   
  
  return rv;
}

function setValue(pId,pValue)
{
  document.getElementById(pId).value = pValue;
}

