/*$(function() {
        var settings = { containerResizeSpeed: 350
            };
            $('#gallery a').lightBox(settings);
        });*/
/*         
$(document).ready(function() {
			// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 
			$("#form1").validationEngine({
				success :  function() {$.post("adduser.php", $("#form1").serialize()),
				$("#dialog").dialog({
					bgiframe: true,
					modal: true,
					buttons: {
					Ok: function() {
						$(this).dialog('close');
						}
					}
				}),
				$('#form1').fadeOut('slow');
				},
				failure : function() {}
			})
			//$.validationEngine.buildPrompt("#date","This is an example","error")	 		 // Exterior prompt build example
			//$.validationEngine.closePrompt(".date") 										 // Exterior prompt close example
		});   */


$(document).ready(function() {
    if($("#lead_gen").length > 0){
        $("#lead_gen").dataTable({
            "bLengthChange": false,
            "bFilter": false,
            "bAutoWidth": false,
            "aaSorting": [[3, "desc"]]
        });
    }
    if($("#new_vids").length > 0){
        $("#new_vids").dataTable({
            "bLengthChange": false,
            "bFilter": false,
            "bAutoWidth": false,
            "aaSorting": [[3, "desc"]]
        });
    }
    $("fieldset legend").click(function(){
        if($(this).parent().is('.collapsible')){
            $(this).parent().children().filter("p,img,table,ul,div,span").toggle("fast");
        }
    });
    if($("#gymdetailtext").length > 0){
        changeTab('2');
    }
    if($("#gymslides").length > 0){
        $("#gymslides").cycle({
            fit:1
        });
    } 
    
});
function openWindow(url,width,height,scrollbars)
{
    var leftoffset = (screen.width - width - 10)/2;
    var topoffset = (screen.height - width - 40)/2;
    window.open(url,'_blank','titlebar=no,resizable=no,scrollbars=' + scrollbars + ',width=' + width + ',height=' + height + ',left=' + leftoffset + ',top=' + topoffset);
}
function delSpecBrand(t, id, hash)
{
    var answer = confirm("Are you sure you want to delete entry " + id + "?");
    if(answer){
        window.location = "delspecbrand.php?i=" + id + "&t=" + t + "&h=" + hash;
    }
}
function delVideo(id, hash)
{
    var answer = confirm("Are you sure you want to delete this video?");
    if(answer)
        window.location = "deletevideo.php?v=" + id + "&h=" + hash;
}

function makeRequest(url, parameters)
{
    var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
        {
            http_request.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        //alert('Cannot create XMLHTTP instance');
        return false;
    }
    
    http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                // alert(http_request.responseText);
            } else {
                //alert('There was a problem with the request.');
                //alert(http_request.responseText);
            }
        } 
    };
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
}


function confirmBillChange(currentPlan){
    var answer;
    var currentText;
    switch(currentPlan){
        case 0:
        currentText = "Basic";
        break;
        case 2:
        currentText = "Value";
        break;
        case 3:
        currentText = "Promoter";
        break;
        default:
        currentText = "Basic";
        break;
    }
    answer = confirm("Are you sure you want to change your subscription? You are responsible for all fees and charges associated with a new subscription plan.  Your current plan is: " + currentText);
    
    if(answer){
        return true;
    }
    else {
        document.form1.billing.selectedIndex = currentPlan-1;
        return false;
    }
}
/*
$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#searchbox').hide();
 // toggles the slickbox on clicking the noted link
  $('a#searchrequest').click(function() {
 $('#searchbox').toggle(400);
 return false;
  });
});		*/


