﻿// 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;
}

    

  //configure the two variables below to match yoursite's own info

//  function addbookmark(){
//	var bookmarkurl="http://www.hovalala.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;
}


