
function OpenDetails(ID){
    mywindow = window.open("detailspopup.aspx?pid=" + ID, "mywindow", "location=0,status=0,scrollbars=1,width=820,height=650,resizable=0");
}


function OpenDetailsRel(Page) {
    mywindow = window.open(Page, "mywindow", "location=0,status=0,scrollbars=1,width=820,height=650,resizable=0");
}

function OpenDemo(Page,Demo){
	mywindow = window.open (Page+ "?demofile="+Demo,"mydemo","location=0,status=0,scrollbars=0,width=700,height=640"); 
}
function quicknotes(ID){
    mywindow = window.open("quickview.aspx?oy5_3=" + ID, "mywindow", "location=0,status=0,scrollbars=1,width=500,height=400"); 
}
function toggle_divs(div1, div2){
  //alert("client response");
  div1 = document.getElementById(div1);
  div2 = document.getElementById(div2);
  
  div1.style["display"]='inline';
  div2.style["display"]='none';
  //document.forms[0].submit();
}
function toggle_checks(checkboxes,toggletype){
  for (i=0;i < checkboxes.length;i++){
    checkbox = document.getElementById(checkboxes[i]);
    if (toggletype == 1){
        checkbox.checked = true;
    } else if (toggletype == 0){
        checkbox.checked = false;
    } else {
        checkbox.checked = !checkbox.checked;
    }
  }
}
function toggle_checks2(checkboxes, checked) {
    for (i = 0; i < checkboxes.length; i++) {
        checkbox = document.getElementById(checkboxes[i]);
        checkbox.checked = checked;
    }
}
function toggle_div(odiv1){
    odiv = document.getElementById(odiv1);
    //alert(odiv.style.toString());
    if (odiv.style['display']=='inline'){
       odiv.style['display']='none';
    } else if (odiv.style['display']=='none'){
       odiv.style['display']='inline';
    } else {
       odiv.style['display']='none';
    }
}
function toggle_nested(parentContainer) {
    var p = document.getElementById(parentContainer);
    var display = p.firstChild.style['display'];
    if (display == '' || display == 'block') {
        display = 'none';
    } else {
        display = 'block';
    }
    for (var i = 0; i < p.childNodes.length; i++) {
        p.childNodes[i].style['display'] = display;
    }
}
function trace_attribute(odiv1, hField, attribute){
    odiv = document.getElementById(odiv1);
    ohfield = document.getElementById(hField);
    ohfield.value = odiv.style[attribute];
}

function toggle_div2(odiv1, visibleStyle){
    odiv = document.getElementById(odiv1);
    if (odiv.style['display']==visibleStyle){
       odiv.style['display']='none';
    } else if (odiv.style['display']=='none'){
       odiv.style['display']=visibleStyle;
    } else {
       odiv.style['display']='none';
    }
}
function swapImage(target, path) {
    var img = document.getElementById(target)
    img.src = path;
}
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;


//confirm delets gridview 
//  keeps track of the delete button for the row
//  that is going to be removed
var _source;
// keep track of the popup behavior
var _popup;

function showConfirm(source) {
    this._source = source;
    
    //  check to see if the current user is tired of
    //  seeing confirmation dialogs ...
    if(Sys.Services.ProfileService.properties.DisplayDeleteConfirm == true) {
        this._popup = $find('popup');
        //  show the popup
        this._popup.show();
    } else {
        //  use the cached button as the postback source
        __doPostBack(this._source.name, '');                     
    }
}
function showConfirm(source, prompt) {
    this._source = source;
    //  check to see if the current user is tired of
    //  seeing confirmation dialogs ...
    if(prompt == true) {
        this._popup = $find('popup');
        //  show the popup
        this._popup.show();
    } else {
            //  use the cached button as the postback source
        __doPostBack(this._source.name, '');                     
    }
}   
function okClick() {
    //  find the confirm ModalPopup and hide it    
    this._popup.hide();
    
//    //  check to see if they want to opt out of this confirmation
//    var chk = $get('<%= this.chkDontAskAgain.ClientID %>');
//    
//    //  if so, set the property to false and save this value
//    if(chk.checked) {
//        Sys.Services.ProfileService.properties.DisplayDeleteConfirm = false;
//        Sys.Services.ProfileService.save(null, function() {
//            //  use the cached button as the postback source
//            __doPostBack(this._source.name, '');                       
//        });
//    }
//    else {
        //  use the cached button as the postback source
        __doPostBack(this._source.name, '');                   
//    }
}

function cancelClick() {
    //  find the confirm ModalPopup and hide it    
    this._popup.hide();
    //  clear the event source
    this._source = null;
    this._popup = null;
}

//function resetProfile() {
//    //  reset the profile, for testing purposes only
//    Sys.Services.ProfileService.properties.DisplayDeleteConfirm = true;
//    Sys.Services.ProfileService.save();
//}     

function toggle(div_id) {
    var el = document.getElementById(div_id);
    if (el.style.display == 'none') { el.style.display = 'block'; }
    else { el.style.display = 'none'; }
}
//function blanket_size(popUpDivVar) {
//    if (typeof window.innerWidth != 'undefined') {
//        viewportheight = window.innerHeight;
//    } else {
//        viewportheight = document.documentElement.clientHeight;
//    }
//    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
//        blanket_height = viewportheight;
//    } else {
//        if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
//            blanket_height = document.body.parentNode.clientHeight;
//        } else {
//            blanket_height = document.body.parentNode.scrollHeight;
//        }
//    }
//    var blanket = document.getElementById('blanket');
//    blanket.style.height = blanket_height + 'px';
//    var popUpDiv = document.getElementById(popUpDivVar);
//    popUpDiv_height = blanket_height / 2 - 150; //150 is half popup's height
//    popUpDiv.style.top = popUpDiv_height + 'px';
//}
//function window_pos(popUpDivVar) {
//    if (typeof window.innerWidth != 'undefined') {
//        viewportwidth = window.innerHeight;
//    } else {
//        viewportwidth = document.documentElement.clientHeight;
//    }
//    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
//        window_width = viewportwidth;
//    } else {
//        if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
//            window_width = document.body.parentNode.clientWidth;
//        } else {
//            window_width = document.body.parentNode.scrollWidth;
//        }
//    }
//    var popUpDiv = document.getElementById(popUpDivVar);
//    window_width = window_width / 2 - 150; //150 is half popup's width
//    popUpDiv.style.left = window_width + 'px';
//}
//function popup(windowname) {
//    blanket_size(windowname);
//    window_pos(windowname);
//    toggle('blanket');
//    toggle(windowname);
//}
