function ShowAdvert(pSTR012_Id)
{
	if (pSTR012_Id != null)
	{
		cTop = document.body.scrollTop + event.y;
		cLeft = document.body.scrollLeft + event.x ;
		if (cTop  - 210 < document.body.scrollTop)
		{
			cTop=document.body.scrollTop + event.y - 15;
		}
		else
		{
			cTop = cTop - 180;
		}
		if (cLeft + 375 > screen.availWidth - 15)
		{
			cLeft = document.body.scrollLeft + event.x - 390;
		}
		else
		{
			cLeft  = document.body.scrollLeft + event.x - 25;
		}
		document.getElementById("divAdvert").style.display = '';
		document.getElementById("divAdvert").style.top = cTop;
		document.getElementById("divAdvert").style.left = cLeft;
		document.getElementById("labAdvert").innerHTML = "<iframe width='375'  height='195' onMouseOut='CloseAdvert();' frameborder='0' src='" + "Tools/Advert.aspx?Q1=" + pSTR012_Id + "'></iframe>";
	}
}

function CloseAdvert()
{
	document.getElementById("divAdvert").style.display = 'none';
}

function InsertExplane()
{
	alert("Yorumunuz Tarafımıza Ulaşmıştır. Teşekkür Ederiz..");
}

function InsertConn()
{
	alert("Bilgileriz Tarafımıza Ulaşmıştır. En Kısa Zamanda Sizinle İletişime Geçilecektir. Teşekkür Ederiz..");
}

function gridOver(mThis,mType)
{
	if (mType == 'gray')
	{
		mThis.style.backgroundColor= 'Silver';
	}
	if (mType == 'yellow')
	{
		mThis.style.backgroundColor= '#FF9C00';
	}
	if (mType == 'green')
	{
		mThis.style.backgroundColor= '#009900';
	}
	if (mType == 'LightGray')
	{
		mThis.style.backgroundColor= 'Silver';
	}
	if (mType == 'blue')
	{
		mThis.style.backgroundColor='#B1CAE0';
	}
}

function ColorsView2(pColor,pState)
{
	var cRet;
	cRet = window.showModalDialog('../../Tools/Colors.aspx?id=' + pColor ,'','toolbar:no;location:no;status:no;menubar:no;scrollbars:yes;resizabl:no;dialogWidth:650px;dialogHeight:420px')	
	if (cRet != '')
	{
		document.getElementById(pState).style.backgroundColor = cRet;
		document.getElementById(pState).title = cRet;
	}
}

function tbcColorFill(pColor)
{
	document.getElementById('tbcColor').style.backgroundColor = pColor;
	document.getElementById('txtColor').value  = pColor.substring(1,7);
}

function btnViewColorFill()
{
	myACol =  "#" + document.getElementById('txtColor').value.toString() ;
	tbcColorFill(myACol);
}

function ColorsCancel()
{
	returnValue = '';
	window.close();
}

function ColorsOk()
{
	returnValue = document.getElementById('tbcColor').style.backgroundColor;
	window.close();
}

function gridOut(mThis,mType)
{
	if (mType == 0)
	{
		mThis.style.backgroundColor='Maroon';
	}
	if (mType == 1)
	{
		mThis.style.backgroundColor='#ffcc00';
	}
	if (mType == 2)
	{
		mThis.style.backgroundColor='#00cc00';
	}
	if (mType == 3)
	{
		mThis.style.backgroundColor='White';
	}
	if (mType == 4)
	{
		mThis.style.backgroundColor='White';
	}
	if (mType == 5)
	{
		mThis.style.backgroundColor='WhiteSmoke';
	}
}

function MsgBox(pPath,pType,pCode,pPar)
{
	var cRet;
	cRet = window.showModalDialog(pPath + '/MsgBox.aspx?Mt=' + pType + '&Mc=' + pCode + '&Mp=' + pPar,'','dialogHeight:247px;dialogWidth:400px;scroll:no;help:no;status:yes');
	
	if (cRet != null)
	{
		return cRet;
	}
	else
	{
		return false;
	}
}

function addCommas(pArea,nStr,nDecFormat)
{
	e = window.event;
	
	if (e.keyCode == 9 || e.keyCode == 16)
	{
		return false;	
	}
	else
	{
		if (nDecFormat.indexOf('.') != "-1")
		{
			nDecSpl = nDecFormat.split('.')
			nDecFormat = nDecSpl[1].length -1
	
			nStrLen = nStr.length;
			nStrLastChar = nStr.substring(nStrLen-1,nStrLen);

			if (nStrLastChar == '0' || nStrLastChar == '1' || nStrLastChar == '2' || nStrLastChar == '3' || nStrLastChar == '4' || nStrLastChar == '5' || nStrLastChar == '6' || nStrLastChar == '7' || nStrLastChar == '8' || nStrLastChar == '9' || nStrLastChar == '-' || nStrLastChar == ',')
			{
				if (nStrLastChar == '-' & nStrLen > 1)
				{
					nStr = nStr.substring(0,nStrLen-1);
				}

				if (nStrLastChar == ',')
				{
					if (nStr.indexOf(',') < nStr.lastIndexOf(','))
					{
						nStr = nStr.substring(0,nStrLen-1);
					}
				}
				
				if (nStr.indexOf(',') == -1)
				{
					nNum = 1;
					if (nStr.substring(0,1) == '-') 
					{ 
						nNum = 2;	
					}
				
					if (nStr.length > nNum & (nStr.substring(0,1) == '0' || nStr.substring(0,2) == '-0'))
					{
						nStr = nStr.substring(0,nStrLen-1);
					}
				}
			}
			else
			{
				nStr = nStr.substring(0,nStrLen-1);
			}	
			nStrLen = nStr.length;
			nNewStr = "";
			
			for (i=0; i <= nStrLen -1; i++)
			{
				nStrChar = nStr.substring(i,i+1);
				if (nStrChar == '0' || nStrChar == '1' || nStrChar == '2' || nStrChar == '3' || nStrChar == '4' || nStrChar == '5' || nStrChar == '6' || nStrChar == '7' || nStrChar == '8' || nStrChar == '9' || nStrChar == '-' || nStrChar == ',')
				{
					nNewStr += nStrChar;
				}
			}
			nStr = nNewStr;
			
			nSing = '';
			if (nStr.substring(0,1) == '-')
			{
				nSing = '-';
				nStr = nStr.substring(1,nStr.length);
			}
			
			x = nStr.split(',');
			x1 = x[0];
			x2 = x[1];
			if (x1 == null || x1 == '')
			{
				if (nStr.indexOf(',') !=  -1)
				{
					x1 = 0;
				}
			}
			
			if (x2 == null)
			{
				nStr = addMyComma(x1);
			}
			else
			{
				nX2Len = x2.length;
				if (nX2Len > nDecFormat)
				{
					nStr = addMyComma(x1) + "," + x2.substring(0,nDecFormat);
				}
				else
				{
					nStr = addMyComma(x1) + "," + x2;
				}
			}
			document.getElementById(pArea).value = nSing + nStr;
		}
		else
		{
			//no decimal
			nStrLen = nStr.length;
			nStrLastChar = nStr.substring(nStrLen-1,nStrLen);
				
			if (nStrLastChar == '0' || nStrLastChar == '1' || nStrLastChar == '2' || nStrLastChar == '3' || nStrLastChar == '4' || nStrLastChar == '5' || nStrLastChar == '6' || nStrLastChar == '7' || nStrLastChar == '8' || nStrLastChar == '9' || nStrLastChar == '-')
			{
				if (nStrLastChar == '-' & nStrLen > 1)
				{
					nStr = nStr.substring(0,nStrLen-1);
				}
				
				nNum = 1;
				if (nStr.substring(0,1) == '-') 
				{ 
					nNum = 2;	
				}
				
				if (nStr.length > nNum & (nStr.substring(0,1) == '0' || nStr.substring(0,2) == '-0'))
				{
					nStr = nStr.substring(0,nStrLen-1);
				}
			}
			else
			{
				nStr = nStr.substring(0,nStrLen-1);
			}
			document.getElementById(pArea).value = nStr;
		}
	}
}

function addMyComma(xStr)
{
	z1 = xStr;
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(z1)) {
		z1 = z1.replace(rgx, '$1' + '.' + '$2');
	}
	return z1;
}

function addReCommas(pArea,nStr,nDecFormat,nMinVal)
{
	if (nDecFormat.indexOf('.') != "-1")
	{
		nDecSpl = nDecFormat.split('.')
		nDecFormat = nDecSpl[1].length -1

		nSing = '';
		
		if (nStr.substring(0,1) == '-')
		{
			nSing = '-';
			nStr = nStr.substring(1,nStr.length);
		}

		x = nStr.split(',');
		x1 = x[0];
		if (x1 == null || x1 == '')
		{
			if(nMinVal == null || nMinVal == '')
			{
				nMinVal = 0;
			}
			x1 = nMinVal;
		}
	
		x2 = x[1];
		if (x2 == null)
		{
			nStr = x1 + ",";
			for (i=0 ; i<= nDecFormat -1;i++)
			{
				nStr += "0";
			}
		}
		else
		{
			nX2Len = x2.length;
			
			if (nX2Len < nDecFormat)
			{
				nStr = x1 + "," + x2;
				
				for (i=0 ; i<= nDecFormat - nX2Len-1; i++)
				{
					nStr += "0";
				}
			}
		}
		document.getElementById(pArea).value = nSing + nStr;
	}
	else
	{
		//no Decimal
		if (nStr == null || nStr == '' || nStr == '-')
		{
			if (nMinVal == null || nMinVal == '')
			{
				nMinVal = 0;
			}
			nStr = nMinVal;
		}
		else
		{
			if (parseInt(nStr) < parseInt(nMinVal))
			{
				nStr = nMinVal;
			}			
		}
		document.getElementById(pArea).value = nStr;
	}
}

function GoLink(pPar)
{
	var pVal = pPar.split("~");
	var mPath;
	
	mPath = "";

	switch (pVal[0])
	{
		case "0" :
			document.location = mPath + "Main.aspx";
			break;
		case "1" :
			if (pVal[4] == '0')
			{
				document.location = 'http://' + pVal[1];
			}
			else
			{
				window.open('http://' + pVal[1],'','scrollbars=yes,status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,width=' + pVal[6] + ',height=' + pVal[5] + ',titlebar=yes');
			}
			break;
		case "2" :
			if (pVal[4] == '0')
			{
				document.location = 'https://' + pVal[1];
			}
			else
			{
				window.open('https://' + pVal[1],'','scrollbars=yes,status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,width=' + pVal[6] + ',height=' + pVal[5] + ',titlebar=yes');
			}
			break;
		case "3" :
			if (pVal[4] == '0')
			{
				document.location = 'ftp://' + pVal[1];
			}
			else
			{
				window.open('ftp://' + pVal[1],'','scrollbars=yes,status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,width=' + pVal[6] + ',height=' + pVal[5] + ',titlebar=yes');
			}
			break;
		case "4" :
			if (pVal[4] == '0')
			{
				document.location = 'news://' + pVal[1];
			}
			else
			{
				window.open('news://' + pVal[1],'','scrollbars=yes,status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,width=' + pVal[6] + ',height=' + pVal[5] + ',titlebar=yes');
			}
			break;
		case "5" :
			document.location = 'mailto://' + pVal[1];
			break;
		case "6" :
			if (pVal[2] != null)
			{
				if (pVal[2] == "1")
				{
					document.location = mPath + "ProductDetail.aspx?Q1=" + pVal[3];
				}
			}
			else
			{
				document.location = mPath + "ProductDetail.aspx?Q1=0";
			}
			break;
		case "8" :
			if (pVal[4] == '0')
			{
				document.location = mPath + 'Tools/FlushFile.aspx?Q1=' + pVal[1] + '&Q2=1000&&Q3=1000&Q4=ARC001';
			}
			else
			{
				window.open(mPath + 'Tools/FlushFile.aspx?Q1=' + pVal[1] + '&Q2=1000&&Q3=1000&Q4=ARC001','','scrollbars=yes,status=no,resizable=no,toolbar=no,menubar=no,location=no,width=' + pVal[6] + ',height=' + pVal[5] + ',titlebar=no');
			}
			break;
		case "9" :
			if (pVal[4] == '0')
			{
				document.location = mPath + "Document.aspx?Q1=" + pVal[1] + "&Q2=A";
			}
			else
			{
				window.open(mPath + 'Document.aspx?Q1=' + pVal[1] + '&Q2=A','','scrollbars=yes,status=no,resizable=no,toolbar=no,menubar=no,location=no,width=' + pVal[6] + ',height=' + pVal[5] + ',titlebar=no');
			}
			break;
		case "11" :
			document.location = mPath + "Categories.aspx?Q1=" + pVal[1];
			break;
	}
}