


function clickButton(e, buttonid){
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){
          if (evt.keyCode == 13){
                bt.click();
                return false;
          }
      }
}


function DumpButtonHTML(id,css,TemplateName,onclientclick,isDefaultButton,text,width,enabled,target,themeName)

{
    HTML="<span id=\"{id}\" {disabled} {onclickFromDefaultButton} style=\"display:inline-block;\"><table {tableid} onMouseOut=\"this.className='{css}';\" border=\"0\" {width} Class=\"{css}\" cellPadding=\"0\" onclick=\"{onclick}\" onMouseOver=\"this.className='{css}Over';\" {handstyle} cellSpacing=\"0\"><tr><td width=\"1\"><img src='I.axd?t=b&th={themename}&p={TemplateName}/left.gif'></td><td width=\"100%\" align=\"Center\" nowrap=\"nowrap\" background=\"I.axd?t=b&amp;th={themename}&amp;p={TemplateName}/back.gif\">{text}</td> <td width=\"1\"><img src='I.axd?t=b&th={themename}&p={TemplateName}/right.gif'></td></tr></table></span>";



    if(enabled=="True")

    {

        HTML=HTML.replace("{handstyle}","style=\"cursor:pointer;cursor:hand;\"");

    }

    else

    {

        HTML=HTML.replace("{disabled}","disabled=\"disabled\"");

    }

    

    if(width.length>0)

    {

        HTML=HTML.replace("{width}","width=\"" + width + "\"");

    }

    

    if(isDefaultButton == "True")

    {

        onclientclick += "StopEvent(event);";

        HTML=HTML.replace("{onclickFromDefaultButton}","onclick=\"document.getElementById('{id}_Table').onclick();StopEvent(event)\"");

        HTML=HTML.replace("{tableid}" , "id=\"{id}_Table\"");

    }

    

    HTML=HTML.replace("{handstyle}","");

    HTML=HTML.replace("{width}","");

    HTML=HTML.replace("{onclickFromDefaultButton}","");

    HTML=HTML.replace("{tableid}","");

    HTML=HTML.replace("{disabled}","");

    

    HTML=ReplaceAll(HTML,"{themename}",themeName);

    HTML=ReplaceAll(HTML,"{id}",id);

    HTML=ReplaceAll(HTML,"{css}",css);

    HTML=ReplaceAll(HTML,"{TemplateName}",TemplateName);

    HTML=ReplaceAll(HTML,"{onclick}",onclientclick);

    HTML=ReplaceAll(HTML,"{text}",text);



    document.write(HTML);

}



function ReplaceAll(str,strFind,StrChange)

{

    str = str.replace( new RegExp( strFind, "gi" ), StrChange );

    return str;

}



function SetLocked(objID,lockStatus)

{

    document.getElementById(objID).onkeydown=function(){return lockStatus;};

    document.getElementById(objID).onselectstart=function(){return lockStatus;};

}



function HideDDLs()

{

	var DDls=document.getElementsByTagName('SELECT');

	for(i=0;i<DDls.length;i++)

	{

		DDls[i].style.visibility = "hidden";

	}

}



function ShowDDLs()

{

	var DDls=document.getElementsByTagName('SELECT');

	for(i=0;i<DDls.length;i++)

	{

		DDls[i].style.visibility = "visible";

	}

}



function GetQueryStringValue(Key)

{

	try

	{

		var s=new String();

		s=window.document.location;



		var r=new RegExp('([?&]' + Key + '=)([^&^?]*)');



		return r.exec(s)[2];

	}

	catch(ex)

	{

		return null;

	}

}



function PopupOpen(OpenPage,PopupName,Properties)

{



	window.open(OpenPage,PopupName,Properties);

	

}



function PopupOpenCenter(OpenPage,PopupName,Width,Height,Properties)

{

    Left = parseInt((screen.availWidth - Width) / 2);



	Top = parseInt((screen.availHeight - Height) / 2);


	window.open(OpenPage, PopupName, Properties + ',top=' + Top + ',left=' + Left + ',width=' + Width + ',height=' + Height);

}



function RadioCheck(parentid,id)

{

	RadioList=document.all.tags('Input');



	for(i=0;i<RadioList.length;i++)

	{

    		if (RadioList[i].id.indexOf(parentid)>-1 && RadioList[i].id!=id)

		{

      		if (RadioList[i].checked)

	      	{

            		RadioList[i].checked=false;

			}

		}

	}

}



function clearDD(oDropDown)

{

  if(oDropDown==null)

      return;

  var	oOptions = oDropDown.options;

  for(var	i=oOptions.length; i>=0; i--){

    oOptions[i]	= null;

  }

}



function getDDValue(oDropDown)

{

  return oDropDown.options[oDropDown.selectedIndex].value;

}



function getMinValue(p_Value1,p_Value2){

  if (p_Value1>p_Value2)

  {return p_Value2;}

  else

  {return p_Value1;}

}



function PageIsValid(ValidationGroup)

{

    var validationResult = true;



    if (typeof(Page_ClientValidate) == 'function') 

    {

        validationResult = Page_ClientValidate(ValidationGroup);

    }

    

    return validationResult;

}



function Loading(isValid,SplashScreenId,ImagePath)

{

    if(!SplashScreenId)	{return;}

    if(isValid)

    {

	    window.setTimeout("ShowLoading('"+SplashScreenId+"','"+ImagePath+"')",200);

	}

}



function ShowLoading(SplashScreenId,ImagePath)

{    

   

	var HTML



    d = document;

    f = d.frames ? d.frames[SplashScreenId] : d.getElementById(SplashScreenId);

    j = f.document || f.contentWindow.document;

    HTML = j.getElementsByTagName("body")[0].innerHTML;



    HTML = ReplaceAll(HTML,'{imagepath}',ImagePath+'/');

    HTML = ReplaceAll(HTML,'%7Bimagepath%7D',ImagePath+'/');

    if(document.all["loadingPanel"])

	{document.getElementById("loadingPanel").innerHTML=HTML;}

	else

	{document.body.innerHTML = HTML;}

}



function findObj(n, d) 

{

  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=findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function swapImage(imgId,url) 

{

  	 if ((x=findObj(imgId))!=null)

	 {

        x.style.filter="blendTrans(duration=1)";

        x.style.filter="blendTrans(duration=1)";

        x.filters.blendTrans.Apply();



		x.src=url;



        x.filters.blendTrans.Play();

	 }

}



function wrap(HiddenStatusID,ContainerID,ImageID,MinimizeImage,RestoreImage)

{

    HiddenStatus = document.getElementById(HiddenStatusID);

    Container = document.getElementById(ContainerID);



	if (Container.style.display=="") 

	{

	    Container.style.display = "block";

	}



	if ( Container.style.display=="none")

	{ 

	    Container.style.display="block";

        swapImage(ImageID,MinimizeImage);

        HiddenStatus.value = "Opened";

    }

    else if (Container.style.display=="block")  

	{

	    Container.style.display="none";

        swapImage(ImageID,RestoreImage);

        HiddenStatus.value = "Closed";

	}



}



function changeCulture(cultureCode)

{	var CurrentCultureStr=GetQueryStringValue("Culture");

    var pathStr =window.location.href;

    var newPath=pathStr;

    var strToReplace="?";

	if(CurrentCultureStr!=null && CurrentCultureStr!='')

	{newPath=pathStr.replace("Culture="+CurrentCultureStr,"Culture=" + cultureCode);}

	else if(pathStr.indexOf("?")>0)

	{newPath=pathStr.replace("?","?Culture=" + cultureCode +"&" );}

	else

	{newPath=pathStr+"?Culture=" + cultureCode }

	var r=new RegExp('&$');

	try

	{  if((r.exec(newPath))!=null)

	    { newPath=newPath.substring(0,newPath.length-1);

	    }

    }

	catch(ex)

	{}

	document.location.href = newPath;

}

