/*
// *********************************************************************************************** //
// 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 ToggleValue(pId,pValue,pA,pB)
{
	if (document.getElementById(pId).value == pValue)
		setValue(pId,pA);
	else
		setValue(pId,pB);
}


function ToggleImage(pCheckId,pId,pValue,pA,pB)
{
	if (document.getElementById(pCheckId).value == pValue)
		document.getElementById(pId).src = pA;
	else
		document.getElementById(pId).src = pB;	
}


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 != "")
	{
		if (document.getElementById(pid).style.display != "block")
			document.getElementById(pid).style.display = "block";
	}
}

function HideDiv(pid)
{
	if (pid != "")
	{
		if (document.getElementById(pid).style.display != "none")
			document.getElementById(pid).style.display = "none";
	}
}

function HideDivList(pList)
{
	var pListArray = pList.split(",");
	for(i = 0; i < pListArray.length; i++)
	{
		if (pListArray[i] != "")
		{
			if (document.getElementById(pListArray[i]).style.display != "none")
				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(pKey,pKeyMax,pWebRoot,pId,pWidth,pHeight,pImagePath,pCloseLabel,pShadow,pBackLabel,pForwardLabel,pBarWidth)
{
	var sTop = 0;
	var sLeft = 0;
	var sWidth = pWidth;
	var sHeight = pHeight;
	var sPadding = 25;		
	var urlKey = 0;

	
	var urlBack = "";
	if (pKey > 0)
	{
		urlKey = (pKey - 1);
		urlBack = getValue(pId + "SU" + urlKey);
	}
	
	var urlForward = "";
	if (pKey < pKeyMax)
	{
		urlKey = (pKey + 1);
		urlForward = getValue(pId + "SU" + urlKey);
	}
	
	//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 += "<div style=\"position:relative;width:100%;height:100%;\">";
	
	
	if (urlBack != "")
	{
 		iv += "<div onmouseover=\"ShowDiv('" + pId + "Back')\" onmouseout=\"HideDiv('" + pId + "Back')\" onclick=\"" + urlBack + "\" title=\"" + pBackLabel + "\" ";
 		iv += " style=\"position:absolute;top:0px;left:0px;width:" + pBarWidth + "px;height:100%;\">";
 		iv += "<div id=\"" + pId + "Back\" style=\"display:none;width:" + pBarWidth + "px;height:100%;background-image:url(" + pWebRoot + "/image/Shadow32.png);\">";
 		iv += "<table style=\"width:100%;height:100%;\"><tr><td align=\"center\"><img src=\"" + pWebRoot + "/image/ShadowArrowLeft.png\" border=\"0\" alt=\"\" /></td></tr></table>";
 		iv += "</div></div>";	
	}
	
	if (urlForward != "")
	{
 		iv += "<div onmouseover=\"ShowDiv('" + pId + "Forward')\" onmouseout=\"HideDiv('" + pId + "Forward')\" onclick=\"" + urlForward + "\" title=\"" + pForwardLabel + "\" ";
 		iv += " style=\"position:absolute;top:0px;right:0px;width:" + pBarWidth + "px;height:100%;\">";
 		iv += "<div id=\"" + pId + "Forward\" style=\"display:none;width:" + pBarWidth + "px;height:100%;background-image:url(" + pWebRoot + "/image/Shadow32.png);\">";
 		iv += "<table style=\"width:100%;height:100%;\"><tr><td align=\"center\"><img src=\"" + pWebRoot + "/image/ShadowArrowRight.png\" border=\"0\" alt=\"\" /></td></tr></table>";
 		iv += "</div></div>";	
	}
	
	iv += "<div onclick=\"setHtml('" + pId + "','');\" title=\"" + pCloseLabel + "\"><img src=\"" + pImagePath + "\" border=\"0\" alt=\"\" /></div>";
	
	iv += "</div>";
	iv += "</div>";
	
	setHtml(pId,iv);
}



function OpenSlide(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 += "<div style=\"position:relative;width:100%;height:100%;\">";
	
	iv += "<div onclick=\"setHtml('" + pId + "','');\" title=\"" + pCloseLabel + "\"><img src=\"" + pImagePath + "\" width=\"" + sWidth + "\" height=\"" + sHeight + "\" border=\"0\" alt=\"\" /></div>";
	
	iv += "</div>";
	iv += "</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;
}


function resizeIFrame()
{
	
}
