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=(screen.availWidth-Width)/2;

	Top=(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)
{
  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)
{    
    //document.getElementsByTagName('form')[0].style.visibility='hidden';
    
    //var HTML = "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'><tr><td align='center'><img src='https://epowerv4.amadeus.com.tr/ucuzabiletepowerv4/App_Themes/UcuzaBilet_theme1/images/loading.gif'></td></tr></table>";
	var HTML

    if(window.frames[SplashScreenId])
 	{  
	   HTML=document.frames[SplashScreenId].document.body.innerHTML;
	}
	else if (window.parent.frames[SplashScreenId])
	{  
	   HTML=window.parent.frames[SplashScreenId].document.body.innerHTML;
	}
	else
	{
	   return;
	}

	while((HTML.indexOf('{imagepath}/')>=0) || (HTML.indexOf('{imagepath}')>=0))
	{
       HTML=HTML.replace('{imagepath}/',ImagePath+'/');
	   HTML=HTML.replace('{imagepath}',ImagePath+'/');
	}
    
	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";
	}

}