﻿function Confirm_Delete() {
    var check = confirm("Are you sure to delete?");
    if (check) return true;
    else return false;
}
function Confirm_Delete_ALL() {
    var check = confirm("Are you sure to delete All?");
    if (check) return true;
    else return false;
}
// button hover;
function hov(loc,cls) {
  if(loc.className)
    loc.className=cls;
}
function OpenPicture(url)
{   
    url = url.toString().replace("projects_sml","projects");
    window.open(url,"Picture","menubar=0,resizable=1,scrollbars=1");    
}


// Open New window
function OpenDatePicker(theURL, Name, popW, popH, scroll, resize) 
{
    var winleft = (screen.width - popW) / 2;
    var winUp = (screen.height - popH) / 2;
    var winProp = 'width=' + popW + ',height=' + popH + ',left=' + winleft + ",status=No,location=No" +
    ',top=' + winUp + ',scrollbars=' + scroll + ',resizable=' + resize + '';
    Win = window.open(theURL, Name, winProp);
    if(Win != null)Win.window.focus();
}
function fnClickLogin(sender, e) {
    if (document.MyForm.top_txtusername.value == '' || document.form1.top_txtpassword.value == '')
    {
        alert('Please enter your username AND password');
        return true;
    }
    else
    {
        __doPostBack(sender,e);
        return true;
    }
}

function ShowTimeoutWarning ()
{
    var answer = confirm("Your session is about to expire. Click 'OK' to remain logged in.")
	if (answer){
		window.location.reload();
		
	}
	else{
		window.location = "http://www.marbleflorida.com/SessionTimeOut.aspx";
	}
}
setTimeout('ShowTimeoutWarning();', 1770000);
function Load_Sections(Section,ObjValue)
{
    var ObjCategory = document.getElementById('ddlCategory');
    CatSelection = ObjValue;
    var URL = 'LoadDropboxes.aspx?Section='+'&id=' + ObjValue;
    Submit_Ajax_Get_Request(URL, Set_Sections);
    var URL = 'LoadDropboxes.aspx?Section='+'&id=' + ObjValue;
    Submit_Ajax_Get_Request(URL, Set_Sections);
    var URL = 'LoadDropboxes.aspx?Section='+'&id=' + ObjValue;
    Submit_Ajax_Get_Request(URL, Set_Sections);
}
function Set_Sections(PostBackValue)
{
    var DropBoxArray = PostBackValue.split(',');
    var ObjSubcategory = document.getElementById('ddlSubcategory');
    
    ObjSubcategory.innerHTML="";
    
    var option = document.createElement('option');
    option.value="0";
    option.innerHTML="Select Subcategory";     
    ObjSubcategory.appendChild(option);

    for (var i = 0; i < subcategories.length-1; i++)
    {
        option = document.createElement('option');
        option.value=subcategories[i];
        option.innerHTML = subcategories[i];
        ObjSubcategory.appendChild(option);
    }
}

// Global variables to keep track of the request
var ajaxreq=false;
var ajaxCallback = false;
function Instantiate_Ajax_Request()
{ 
    ajaxreq = false;
    try{ ajaxreq = new XMLHttpRequest();} // Firefox, IE7, Others
    catch (error){// IE5, IE6
        try{ajaxreq = new ActiveXObject("Microsoft.XMLHTTP");}
        catch (error){alert('Error creating Ajax request');
        return false;}}
        return true;
}

// Create an XMLHttpRequest and submit request 
// for specified url with GET.  
// Remember caller's callback function.
function Submit_Ajax_Get_Request(url, callback) 
{ 
    if (Instantiate_Ajax_Request()) 
    {
        ajaxCallback = callback;
        ajaxreq.open("GET", url, true);
        ajaxreq.onreadystatechange = ReadyState_Change;
        ajaxreq.send(null);
    }
}
// Here on ReadyState Change
function ReadyState_Change()
{
    // Anything other than "Complete"
    if (ajaxreq.readyState != 4) return;   
    if (ajaxreq.status==200)
    {
        // Request succeeded
        if (ajaxCallback)
        {
            ajaxCallback(ajaxreq.responseText);
            ajaxCallback = false;
        }
        else alert("ReadyState_Change: No ajaxCallback");
    }
    else
    {
        alert("Ajax request failed");
        ajaxCallback = false;
    }
}