/*******************************************************************************
**
** FileName: pop.js
**
** Version 1.0
**
*******************************************************************************/

function OpenWindow(jURL,jNm,jW,jH,jSX,jSY,jLc,jMb,jSt,jTb,jSb,jRs)
{

// abreJanela(URL,wName,width,height,left,top,location,menubar,status,toolbar,scrollbars,resizable)
// Variaveis de entrada
// jImg	Imagem a ser editada
// jURL	Pagina a ser aberta na janela
// jNm	Nome da janela a ser aberta
// jW	Largura da janela
// jH	Altura da janela
// jSX	Posicao horizontal da janela
// jSY	Posicao vertical da janela
// jLc	location=
// jMb	menubar=
// jSt	status=
// jTb	toolbar=
// jSb	scrollbars=
// jRs	resizable=
	if (jNm == '') jNm = '_blank';
//	Montagem da sequencia de parametros
	sParam = "width=" + jW + ",";
	sParam = sParam + "height=" + jH + ",";
	sParam = sParam + "left=" + jSX + ",";
	sParam = sParam + "top=" + jSY + ",";
	sParam = sParam + "location=" + jLc + ",";
	sParam = sParam + "menubar=" + jMb + ",";
	sParam = sParam + "status=" + jSt + ",";
	sParam = sParam + "toolbar=" + jTb + ",";
	sParam = sParam + "scrollbars=" + jSb + ",";
	sParam = sParam + "resizable=" + jRs;
//	Abertura da janela
	var aJanela = null;
	aJanela = window.open(jURL,jNm,sParam);
	if (aJanela != null ) {
		if (aJanela.opener == null ) {
			aJanela.opener = self;
			self.location.href=document.location;
		}
		//aJanela.location.href=jURL;	
		aJanela.focus();
	}
}


function showPop(url,name)
{
	var ctrl = document.getElementById(name);
	if (ctrl == null)
		return;
	var shadow = document.getElementById(name + "Shadow");
	if (shadow == null)
	{
		shadow = document.createElement("div");
		shadow.id="lead_InfoShadow";
		document.body.appendChild(shadow);
	}
	shadow.style.display = "block";
	ctrl.style.display = "block";
	
	if (url != "")
	{
		var theframe = document.getElementById(name + "Iframe");
		if (theframe != null)
			theframe.src = url;
	}
}
		
function closePop()
{
	var ctrl = document.getElementById(name);
	if (ctrl != null)
		ctrl.style.display = "none";
		
	ctrl = document.getElementById(name + "Shadow");
	if (ctrl != null)
		ctrl.style.display = "none";
}

 function limitLength(name, max)
 {
    var field = document.getElementById(name);

    var len = field.value.length;
    
    if(parseInt(len) > parseInt(max))
    {
      field.value = field.value.substring(0,max);
    }
}

function showcountcharacter(name1, name2) {
 
    var field = document.getElementById(name1);
 
    var len = field.value.length;
 
    document.getElementById(name2).value = len.toString();
}
 
 function toggleImg(masterImg,imgNewSource) 
{
	if(document.getElementById) 
	{
		document.getElementById(masterImg).src = imgNewSource;
	} 
	else 
	{
		document.images[masterImg].src = imgNewSource;
	}
}

function toggleID(masterImg,imgNewSource) 
{
	if(document.getElementById) 
	{
		document.getElementById(masterImg).value = imgNewSource;
	} 
	else 
	{
		document.images[masterImg].value = imgNewSource;
	}
}

function setRadionButtonPictureType(imgNewSource) 
{
	if(document.getElementById) 
	{
	    document.getElementById(imgNewSource).checked = true;
	} 
	else 
	{
		document.images[imgNewSource].checked = true;
	}
}

function setDropDownPictureType(masterImg,imgNewSource) 
{
	if(document.getElementById) 
	{
	    document.getElementById(masterImg).value = imgNewSource;
	} 
	else 
	{
		document.images[masterImg].value = imgNewSource;
	}
}

function togglePicture(picHolder,imgNewSource,id,caption,radioButton,isDefault,dropdownvalue) 
{
    document.getElementById('ctl00_ContentPlaceHolder1_ImageMaster').src = imgNewSource;
    document.images['ctl00_ContentPlaceHolder1_ImageMaster'].src = imgNewSource;
    document.getElementById('ctl00_ContentPlaceHolder1_TextBoxID').value = id;
    document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCaption').value = caption;
	//document.getElementById(radioButton).checked = true;
//	var tmpList = document.getElementById('DropDownListProcedures');
//	for (i=0;i<tmpList.length;i++)
//	{	    
//	    if(tmpList.options[i].value == dropdownvalue)
//	        tmpList.options[i].selected;	    
//	}
	selectPicture(picHolder,supplierGallery);
	/*if(supplierGallery.picArray != null)
	{
	    for(i in supplierGallery.picArray)
	    {	        
	        supplierGallery.picArray[i].style.border = "1px solid #BAD7D4";
	    }
	}
	picHolder.style.border = "2px solid #28A297";
	*/

	var defaultbutton = document.getElementById('ctl00_ContentPlaceHolder1_ButtonMakeDefault');
	if (isDefault == "True") {
	    defaultbutton.style.display = "none";
	} else {
	    defaultbutton.style.display = "";
	}
//	if(isDefault=="True")
//	{	    
//	    defaultbutton.enabled = false;
//	    //defaultbutton.style.backgroudImage = "url(/images/button_box_gray.png)";
//	    defaultbutton.className += " button_box_gray";
//	    defaultbutton.onclick = function(){alert("This is your Listing Image Already");return false;};
//	}else
//	{
//	    defaultbutton.enabled = true;
//	    defaultbutton.className = "button_box";
//	    defaultbutton.onclick = "";
//	}
	
	return false;
}





