﻿// JScript File


function ConfirmDoYouWantToDelete() {
	if (confirm("?האם אתה בטוח רוצה לבצע מחיקה") == true)
		return true;
	else
		return false;
}

function OpenPopupWindow(url, features) {
	window.open(url, 'Test', features)
}

function ConfirmByMessage(message) {
	if (confirm(message) == true)
		return true;
	else
		return false;
}

function showHideById(objID) {
	var obj = document.getElementById(objID);
	if (!obj)
		return;
	obj.style.display = obj.style.display == "none" ? "" : "none";
	/*
	if (obj.style.display == "none") {
	obj.style.display = "";
	return;
	}
	obj.style.display = "none";
	*/
}

//configure the two variables below to match yoursite's own info

function addbookmark() {
	var bookmarkurl = "http://www.allnadlan.co.il"
	var bookmarktitle = "אתר הנדל''ן של ישראל"

	if (document.all)
		window.external.AddFavorite(bookmarkurl, bookmarktitle)
}

//=====================DropDownList.JS======================

// JScript File

function CODropDownList_Load(ddlControlId) {
	var ddlControl = document.getElementById(ddlControlId);
	if (ddlControl == null) //TODO: this might happen when a visible control is found in an invisible gridColumn
		return;
	CODropDownList_VerifyInit(ddlControl);
}


function CODropDownList_VerifyInit(ddlControl) {
	if (ddlControl.IsInited)
		return;
}

function CODropDownList_AllowNull(ddlControl) {
	return ddlControl.AllowNull == "true";
}

function IsDropDownValueWasChosen(source, args) {
	//debugger;
	if (args.Value == "0")
		args.IsValid = false;
	else
		args.IsValid = true;
}


//=====================GUI.JS======================

// Moving JavaScript Document



function ShowPicture(obj, img) {
	obj.firstChild.src = img //"images/box_on.gif";
}

function boxOpen(obj) {
	obj.firstChild.src = "images/box_on.gif";
}

function boxClose(obj) {
	obj.firstChild.src = "images/box_off.gif";
}

function showHelp(divId, title, txt, aEvent, tableWidth, imgObg) {
	//document.getElementById(divId).style.background = "yellow";
	var helpTable = document.getElementById(divId).firstChild;
	tableWidth = tableWidth ? tableWidth : 150;
	helpTable.style.width = tableWidth + "px";
	helpTable.parentNode.style.width = tableWidth + "px";
	helpTable.firstChild.firstChild.firstChild.innerText = title;
	helpTable.firstChild.firstChild.nextSibling.firstChild.innerText = txt;
	//showHelpContent(divId, aEvent)
	positionByImage(document.getElementById(divId), imgObg, helpTable)
}

function positionByImage(tablContent, imgObg, tblObj) {
	//debugger
	if (!tablContent)
		return;
	tablContent.style.display = "block";
	tablContent.style.position = "absolute";
	tablContent.style.left = (imgObg.offsetLeft - tblObj.offsetWidth) + "px";
	tablContent.style.top = (imgObg.offsetTop + (imgObg.offsetHeight / 2) - (tblObj.offsetHeight / 2)) + "px";



}


function showHelpContent(helpID, aEvent) {
	var posx = 0;
	var posy = 0;
	var helpDiv;
	var winWidth = 1024;
	var e = aEvent ? aEvent : window.event;
	//debugger
	if (document.layers)	   //NN4+
	{
		helpDiv = document.layers[helpID]
	}
	else (document.getElementById)	  //gecko(NN6) + IE 5+
	{
		helpDiv = document.getElementById(helpID)
	}
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) { // Firefox
		posx = mouseX(aEvent)
		posy = mouseY(aEvent)
	}
	else {
		if (e.pageX || e.pageY) {
			winWidth = window.innerWidth;
			posx = e.pageX + window.pageXOffset;
			posy = e.pageY + window.pageYOffset;
		}
		else if (e.clientX || e.clientY) {
			winWidth = document.body.offsetWidth;
			posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
	}
	/*if(posx>(winWidth/2)){
	posx = posx-400
	}*/
	if (helpDiv) {
		helpDiv.style.position = "absolute";
		helpDiv.style.left = posx + "px";
		helpDiv.style.top = posy + "px";
		helpDiv.style.display = "block";
	}
}

function mouseX(evt) {
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX)
		return evt.clientX + (document.documentElement.scrollLeft ?
	   document.documentElement.scrollLeft :
	   document.body.scrollLeft);
	else return null;
}
function mouseY(evt) {
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)
		return evt.clientY + (document.documentElement.scrollTop ?
	   document.documentElement.scrollTop :
	   document.body.scrollTop);
	else return null;
}
function hideHelp(helpID, aEvent) {
	var helpObj;
	if (document.layers)	   //NN4+
	{
		helpObj = document.layers[helpID]
	}
	else (document.getElementById)	  //gecko(NN6) + IE 5+
	{
		helpObj = document.getElementById(helpID)
	}
	if (helpObj)
		helpObj.style.display = "none";
}

// Handling images opacity

function cahngeOpacity(mouseOver, obj, opacity) {
	opacity = opacity ? opacity : 100;
	if (mouseOver) {
		obj.style.filter = "alpha(opacity=" + opacity + ")";
		obj.style.opacity = opacity / 100;
		return;
	}
	obj.style.filter = "alpha(opacity=" + opacity + ")";
	obj.style.opacity = opacity / 100;
	/*
	if(mouseOver){
	obj.className = "galleryFull";
	return;
	}
	obj.className = "galleryTrans";
	*/
}


//code for fixing repeater problem in asp.net
//http: //www.developer.com/net/asp/article.php/3623096

function SetUniqueRadioButton(nameregex, current) {
	re = new RegExp(nameregex);
	for (i = 0; i < document.forms[0].elements.length; i++) {
		elm = document.forms[0].elements[i]
		if (elm.type == 'radio') {
			if (re.test(elm.name)) {
				elm.checked = false;
			}
		}
	}
	current.checked = true;
}

var repeatHeightAdjustment = null;
function ShowHideMessageText(AdID, adLink) {
	var currRow = document.getElementById("TR" + AdID);
	var detailsRow = document.getElementById("AllText" + AdID);
	var detailsFrame = document.getElementById("Frame" + AdID);
	var expanderImg = currRow.lastChild.firstChild;
	if (!currRow || !detailsRow || !detailsFrame)
		return;
	if (detailsRow.style.display != 'none') {
		detailsFrame.src = 'about:blank';
		detailsRow.style.display = 'none';
		currRow.className = currRow.className.replace('Click', 'Out');
		expanderImg.src = expanderImg.src.replace('close', 'open');
		return;
	}
	detailsFrame.src = (adLink + "?AdID=" + AdID);
	detailsRow.style.display = '';
	repeatHeightAdjustment = setTimeout(function() { adjustHeight(detailsFrame.id) }, 500);
	currRow.className = currRow.className.replace('Over', 'Click');
	currRow.className = currRow.className.replace('Out', 'Click');
	currRow.className = currRow.className.replace('Visited', 'Click');
	expanderImg.src = expanderImg.src.replace('open', 'close');

}

function adjustHeight(detailsFrameID) {

	var detailsFrame = document.getElementById(detailsFrameID);
	var detailsFrameHeight = detailsFrame.contentDocument;
	if (!detailsFrameHeight)
		detailsFrameHeight = frames[detailsFrameID].document.getElementsByTagName('body')[0];
	else
		detailsFrameHeight = detailsFrameHeight.body;
	if (!detailsFrameHeight) {
		detailsFrame.style.height = "300px";

		repeatHeightAdjustment = null;
		return;
	}

	var detailsFrameHeight = detailsFrameHeight.clientHeight;
	if (detailsFrameHeight > 250) {
		detailsFrame.style.height = detailsFrameHeight + "px";
		repeatHeightAdjustment = null;
		return;
	}
	repeatHeightAdjustment = setTimeout(function() { adjustHeight(detailsFrameID) }, 100);
}



function openWindowForImage(path) {
	window.open(path, 'jav', 'location=0,status0,scrollbars=1,width=720,height=600,resizable=1');

	function ShowHideTender(num) {
		if (document.all("ShowText" + num).style.display == "none") {
			document.all("ShowText" + num).style.display = "";
			//act.location = "addcount.asp?count=ViewCount&id=" + numid + "&sec=" + sec;
		}
		else {
			document.all("ShowText" + num).style.display = "none";
		}
	}
}


    
    
    
    
