	// JavaScript Document	
	//-------------------------------------
	
	function GetControlByName(controlName){
		//return GetControlsByMatchedName(controlName);
		totalForms = document.forms.length;
		for(x = 0 ; x < totalForms; x++)
		{
			control = eval("document.forms[" + x + "]." + controlName);
			if(control)
			{
				break;
			}
		}
		return control;
	}
	//-------------------------------------
	/*function GetControlsByMatchedName(matchedName){
		matchedControls = new Array();
		myForm = document.forms[0];
		totalControls = myForm.elements.length;
		counter = 0;
		for(i = 0; i < totalControls; i++){
			if(myForm.elements[i].name){
				if(myForm.elements[i].name.indexOf(matchedName) != -1){
					matchedControls[counter] = myForm.elements[i];
					counter++;
				}
			}
		}
		return matchedControls;
	}*/
	function GetControlsByMatchedName(matchedName){
		matchedControls = new Array();
		myForm = document.forms[0];
		
		totalControls = myForm.elements.length;
		counter = 0;
		for(i = 0; i < totalControls; i++){
			if(myForm.elements[i].name){
				if(myForm.elements[i].name.indexOf(matchedName) != -1){
					return  myForm.elements[i];
				}
			}
		}
		return matchedControls;
	}
	function _GetControlsByMatchedName(matchedName){
		matchedControls = new Array();
		myForm = document.frmprint;
		alert(myForm)
		
		totalControls = myForm.elements.length;
		alert( totalControls)
		counter = 0;
		for(i = 0; i < totalControls; i++){
			if(myForm.elements[i].name){
				if(myForm.elements[i].name.indexOf(matchedName) != -1){
					return  myForm.elements[i];
				}
			}
		}
		return matchedControls;
	}
	
	//------------------------------------
	function SetFocus(controlName) {
		control = GetControlByName(controlName);
		if(control.type){
			if(control.type == "text" || control.type == "password"){
				control.select();
				control.focus();
			}else{
				control.focus();
			}
		}
		else if(control.length)
		{
			control[0].focus();
		}
	}
	
	
	//------------------------------------
	function GetDropDownListValue(control){
		return control.options[control.selectedIndex].value;
	}
	
	//-----------------------------------
	function SetDropDownListValue(control, value){
		totalOptions = control.options.length;
		for(i = 0; i < totalOptions; i++){
			if(control.options[i].value == value){
				control.options.selectedIndex = i;
				return;
			}
		}
	}
	
	//--------------------------------
	function GetRadioButtonValue(control){
		//alert(control.type)
		totalOptions = control.length;		
		for(i = 0; i < totalOptions; i++){
			if(control[i].checked){
				return control[i].value;
			}
		}
		//return "";
	}
	
	//------------------------------
	function SetRadioButtonValue(control, value){
		totalOptions = control.length;
		for(i = 0; i < totalOptions; i++){
			if(control[i].value == value){
				control[i].checked = true;
				return;
			}
		}
	}
	
	
	//-----------------------------
	function SetCheckBoxValue(control, value)
	{
		control.checked = (control.value == value);
	}
	
	
	
//PUBLIC FUNCTIONS : -------------------------	
	
	//------------------------------------
	function GetValue(controlName){
		control = GetControlByName(controlName);
		if(control.type) {
			if(control.type == "text" || control.type == "password" || control.type == "hidden" || control.type == "textarea"){
				return control.value;
			}else if(control.type == "select-one"){
				return GetDropDownListValue(control);
			}else if(control.type == "radio"){
				return GetRadioButtonValue(control);
			}
		}
		if (control.length)
		{
			if(control.length > 0)
			{
				if (control[0].type == "radio")
				{
					return GetRadioButtonValue(control);
				}
			}
		}
	}
	
	
	//-------------------------------------
	function SetValue(controlName, value){
		control = GetControlByName(controlName);
		if(!control.length)
		{
			if(control.type){
				if(control.type == "text" || control.type == "password" || control.type == "hidden" || control.type == "textarea"){
					control.value = value;
				}else if(control.type == "select-one"){
					SetDropDownListValue(control,value);
				}else if(control.type == "radio"){
					SetRadioButtonValue(control,value);
				}else if(control.type == "checkbox"){
					SetCheckBoxValue(control,value);
				}
			}
		}
		else
		{
			if(control.length > 0)
			{
				if(control[0].type == "radio")
				{
					SetRadioButtonValue(control,value);
				}
				else if(control.type == "select-one")
				{
					SetDropDownListValue(control,value);
				}
			}
		}	
	}
	
	
	//------------------------------------
	function IsEmpty(controlName){
		if(GetValue(controlName) == ""){
			return true;
		}else{
			return false;
		}
	}
	
	
	//------------------------------------
	function IsNumber(ctlValue){
		number = "0123456789";
		ln = ctlValue.length;
		for(i = 0; i < ln; i++) {
			singleChar = ctlValue.charAt(i);
			pos = number.indexOf(singleChar);
			if(pos == -1){
				return false;
			}
		}
		return true;
	}
	
	
	//------------------------------------
	function IsNumeric(value) {
		return !isNaN(value);
	}
	
	//--------------------------------
	function CheckAll(matchName){
		controls = _GetControlsByMatchedName(matchName);
		if(controls.length && controls.length > 0){
			totalControls = controls.length;
			for(i = 0;i < totalControls; i++){
				control = controls[i];
				if(control.type = "checkbox"){
					control.checked = true;
				}
			}
		}
	}
	
	//-------------------------------
	function UnCheckAll(matchName){
		controls = GetControlsByMatchedName(matchName);
		if(controls.length && controls.length > 0){
			totalControls = controls.length;
			for(i = 0;i < totalControls; i++){
				control = controls[i];
				if(control.type = "checkbox"){
					control.checked = false;
				}
			}
		}
	}
	
	//--------------------------------
	function IsAllChecked(matchName){
		controls = GetControlsByMatchedName(matchName);
		if(controls.length && controls.length > 0){
			totalControls = controls.length;
			for(i = 0;i < totalControls; i++){
				control = controls[i];
				if(control.type = "checkbox" && control.checked == false){
					return false;
				}
			}
		}
		return true;
	}
	
	//--------------------------------
	function ValidateEmptyValue(controlNameList, messageList){
		if(controlNameList.length){
			totalControls = controlNameList.length;
			for(i = 0;i < totalControls; i++){
				if(GetValue(controlNameList[i]) == ""){
					alert(messageList[i]);
					SetFocus(controlNameList[i]);
					return false;
				}
			}
		}else{
			if(GetValue(controlNameList) == ""){
				alert(messageList);
				SetFocus(controlNameList);
				return false;
			}
		}
		return true;
	}
	
	function ConfirmLogout()
	{
		return confirm("Are you sure that you want to logout?");
	}
	
	function ConfirmDelete(itemType)
	{
		return confirm("Are you sure that you want to delete this " + itemType + "?");
	}
	
	function IsDuplicateValue(firstControlName, secondControlName)
	{
		if(GetValue(firstControlName) == GetValue(secondControlName))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function _IsValidEmail(str)
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true
	}
	
	function IsValidEmail(targetName)
	{
		var chkemail = /^([a-zA-Z0-9_\.\-])+(\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4}))+$/;		
		var value = GetValue(targetName);
		//alert(value);
		/*if(value.match(chkemail) == null && value != 0){				
			 return false;
		}*/
		if(!chkemail.test(value))
		{
			 return false;
		}
	return true
	}
	
	function ValidateEmail(ctlName)
	{
		if(!IsValidEmail(ctlName))
		{
			alert("Invalid e-mail address! Please re-enter.\t");
			SetFocus(ctlName);
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function ConfirmPassword(ctlPasswordName, ctlConfirmName)
	{
		if(!IsDuplicateValue(ctlPasswordName, ctlConfirmName))
		{
			alert("Please confirm your password again.");
			SetFocus(ctlConfirmName);
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function TransferAllOptions(from, to, startFrom)
	{
		ctlFrom = GetControlByName(from)
		ctlTo = GetControlByName(to)
		
		totalFrom = ctlFrom.options.length
		totalTo = ctlTo.options.length
		for(i = startFrom; i < totalFrom; i++)
		{
			opt = new Option(ctlFrom.options[startFrom].text,ctlFrom.options[startFrom].value);
			ctlTo.options[totalTo+(i-startFrom)] = opt;
			ctlFrom.options[startFrom] = null
		}
	}
	
	function TransferSelectedOptions(from, to, startFrom)
	{
		ctlFrom = GetControlByName(from)
		ctlTo = GetControlByName(to)
		
		totalFrom = ctlFrom.options.length
		totalTo = ctlTo.options.length
		for(i = startFrom; i < ctlFrom.options.length; i++)
		{
			if (ctlFrom.options[i].selected)
			{
				opt = new Option(ctlFrom.options[i].text,ctlFrom.options[i].value);
				ctlTo.options[ctlTo.options.length] = opt;
				ctlFrom.options[i] = null
				i--;
			}
		}
	}
	
	function SelectAllOptions(ctlName, startFrom)
	{
		ctl = GetControlByName(ctlName)
		total = ctl.options.length
		for(i = startFrom; i < total; i++)
		{
			ctl.options[i].selected = true;
		}
		for(i = 0 ; i < startFrom; i++)
		{
			ctl.options[i].selected = false;
		}
	}
	
	function SelectMultipleOptions_2(ctlName, commaDelimatedValue)
	{
		valueArray = commaDelimatedValue.split(",")
		//ctl = GetControlByName(ctlName);
		ctl = GetControlByName(ctlName);		
		for(i = 0; i < valueArray.length; i++)
		{
			currentValue = valueArray[i];
			for(j = 0; j < ctl.options.length; j++)
			{
				if (ctl.options[j].value != "" && (ctl.options[j].value == currentValue.replace(" ","")))
				{
					ctl.options[j].selected = true;
				}	
			}
			
		}
	}
	
	function SelectMultipleOptions(ctlName, commaDelimatedValue)
	{
		valueArray = commaDelimatedValue.split(",")
		//ctl = GetControlByName(ctlName);
		ctl = GetControlsByMatchedName(ctlName);		
		for(i = 0; i < valueArray.length; i++)
		{
			currentValue = valueArray[i];
			for(j = 0; j < ctl.options.length; j++)
			{
				if (ctl.options[j].value != "" && (ctl.options[j].value == currentValue.replace(" ","")))
				{
					ctl.options[j].selected = true;
				}	
			}
			
		}
	}
	
	function UnselectAllOptions(ctlName)
	{
		ctl = GetControlByName(ctlName);
		for(i = 0; i < ctl.options.length; i++)
		{
			ctl.options[i].selected = false;
		}
	}
	
	function GetCommaListFromOptions(ctlName, startFrom)
	{
		rslt = "";
		ctl = GetControlByName(ctlName);
		for(i = startFrom ; i < ctl.options.length; i++)
		{
			rslt += ctl.options[i].value + ",";
		}
		rslt = rslt.substring(0,rslt.length-1);
		return rslt;
	}
	
	function OpenWindow(pagePath)
	{
		wd = parseInt(screen.width/2);
		ht = parseInt(screen.height/2);
		l = parseInt((screen.width - wd)/2);
		t = parseInt((screen.height - ht)/2);
		win = window.open(pagePath,'','width=' + wd + ',height=' + ht + ',scrollbars=yes,resizable=yes');
		win.moveTo(l,t);
		return false;
	}
	
	function OpenDefaultWindow(pagePath)
	{
		win = window.open(pagePath,'','scrollbars=yes,resizable=yes');
		return false;
	}
	
	function GoUrl(url)
	{
		
		//alert(url);
		document.location = url;
		//document.location = url + "?r=" + Math.random(1);
	}
	function GoTo(url)
	{
		document.location = url;
	}
	function GoBack()
	{
		history.back();
	}
	
	function SubmitForm()
	{
		ln = document.forms.length;
		document.forms[ln-1].submit();
	}
	
	function ResetForm()
	{
		myForm = document.forms[0];
		totalControls = myForm.elements.length;
		for(i = 0; i < totalControls; i++)
		{
			if((myForm.elements[i].type == "text") || (myForm.elements[i].type == "password") || (myForm.elements[i].type == "select-one")|| (myForm.elements[i].type == "textarea"))
			{
				myForm.elements[i].value = "";
			}
		}
	}
	
	
	
	function ForgotPassword()
	{
		var controls 	=	 new Array("TxtEmail");
		var messages 	=	 new Array("Please specify email address.\t ");
		for(i = 0; i<controls.length; i++)
		{
			if( GetValue( controls[i] ) == "" )
			{
				alert( messages[i] );
				SetFocus( controls[i] );
				return false;		
			}
			
			if(i==0)
			{
				if(!ValidateEmail(controls[0]))
				{
					return false;
				}
			}
		}		
	}
	
var UploadpopWindow=0;
function UploadWindow(URLStr)
{
	var left = "290";
	var top = "250";
	var width = "300";
	var height = "220";
  if(UploadpopWindow)
  {
	if(!UploadpopWindow.closed) UploadpopWindow.close();
  }
  UploadpopWindow = window.open(URLStr, 'UploadpopWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
var popUpWin=0;
function popUpWindow(URLStr, width, height)
{

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  var left = parseInt((screen.width - width)/2);
  var top = parseInt((screen.height - height)/2);
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function popUpWindowClose()
{

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
 }

var ImagePopUpWin=0;
function ImagePopUpWindow(URLStr)
{
	var left = "600";
	var top = "70";
	var width = "395";
	var height = "533";
  if(ImagePopUpWin)
  {
	if(!ImagePopUpWin.closed) ImagePopUpWin.close();
  }
  ImagePopUpWin = window.open(URLStr, 'ImagePopUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function Check()
{
	if(GetValue('TxtSearchWord')=="")
	{
	alert("Can't search blank field.please insert a value.\t");
	SetFocus('TxtSearchWord');
	return false
	}
}

	
function DoFocus(obj,colorcode)
{
	obj.style.background = colorcode;

}	
function DoDisabled(obj)
{	
	//obj.className = "Disabled";
	obj.disabled = true;
	
}
function DoDisabledTopMenu(obj)
{	
	//obj.className = "DisabledTopMenu";
	//obj.disabled = true;
		
}

	
	function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function LogoutWindow()
{
	var ok =  confirm('Are you sure that you want to logout?\t');
	if(ok)
	{
		window.location = "secure_logout.php";
	}	
}

MM_preloadImages('images/btn1_r.jpg','images/btn2_r.jpg','images/btn3_r.jpg','images/btn4_r.jpg','images/btn5_r.jpg');

function VrfySearch()
{
	var TxtValue = document.FrmSiteSearch.TxtSiteSearch.value;
	if(TxtValue == "" || TxtValue == " ")
	{
		alert("You should enter at least one keyword. \t");		
		SetFocus('TxtSiteSearch');
		return false;	
	}
}

function VrfyChecked(myForm)
{	
	if(myForm.TxtQty.value == "")
	{
		alert("Please enter quantity.\t");
		myForm.TxtQty.focus();
		return false;
	}
	else if(isNaN(myForm.TxtQty.value))
	{
		alert("Quantity must be numeric.\t");
		myForm.TxtQty.focus();
		return false;
	}
}
// Example:
// var b = new BrowserInfo();
// alert(b.version); 
function BrowserInfo()
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}




//var price = new Array();
function PrintPrice(optValue,proID,frm)
{		
	if(optValue != "")
	{
		var ctlPrice = "TxtPrice"+proID;
		var TxtPrintControlObj = eval("document."+frm+"."+ctlPrice);
		
		var Qty = "TxtQty"+proID;
		var TxtQtyObj = eval("document."+frm+"."+Qty);		
		
		var proPrice = "$ " +( Number(eval("price"+optValue) * TxtQtyObj.value).toFixed(2));
		
		TxtPrintControlObj.value = proPrice;
		eval("document."+frm+".hdnPrice").value = eval("price"+optValue);
	}
	else
	{
		var ctlPrice = "TxtPrice"+proID;
		TxtPrintControlObj.value = '$ 0.00';
		//SetValue(ctlPrice,'$ 0.00');
	}	
}


function PrintTotalPrice( val, proID,frm )
{
	var ctlPrice = "TxtPrice"+proID;
	var TxtPrintControlObj = eval("document."+frm+"."+ctlPrice);
	
	var Qty = "TxtQty"+proID;
	var TxtQtyObj = eval("document."+frm+"."+Qty);
	
	//alert(TxtPrintControlObj);
	
	var val = Number(val).toFixed(0);	
	
	if( !isNaN(val) )
	{		
		var TotalPrice = "$ " +( Number( eval("document."+frm+".hdnPrice").value * val ).toFixed(2) );		
		
		TxtPrintControlObj.value = TotalPrice;
		//TxtPrintControlObj.select();
		//TxtQtyObj.focus();
	}
	else
	{		
		alert("Quantity shoud be numeric. \t");		
		TxtQtyObj.value = 1;
		TxtQtyObj.focus();			
	}	
}
function ShowHideContent(name,img)
{
	var target=eval("document.all['"+ name +"']");
	var targetimg=eval("document.all['"+ img +"']");
	
	if(target.style.visibility == 'hidden')
	{
		target.style.visibility = "visible";		
		targetimg.src = "images/min.gif";
		targetimg.alt = 'Minimize'
	}else
	{
		target.style.visibility = "hidden";		
		targetimg.src = "images/max.gif";
		targetimg.alt = 'Maximize'
	}
}

var mapPopUp = 0;
function MapPopUpWindow(URLStr)
{
  if(mapPopUp)
  {
    if(!mapPopUp.closed) mapPopUp.close();
  }
  var width = screen.width-200;
  var height = screen.height-70;
  var left = 0;
  var top = 0;
  
  mapPopUp = open(URLStr, 'mapPopUp', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var ApartmentPopUp = 0;
function ApartmentPopUpWindow(URLStr)
{
  if(ApartmentPopUp)
  {
    if(!ApartmentPopUp.closed) ApartmentPopUp.close();
  }
  var width = screen.width-300;
  var height = screen.height-100;
  var left = 0;
  var top = 0;
  
  ApartmentPopUp = open(URLStr, 'ApartmentPopUp', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
