// Main Javascript scripts
// HOST INSTALL - WEB SOLUTIONS
// 2004-2009


//////////////////
//// User Login
//////////////////
function userlogin(){

  var loginusername = document.userloginform.loginuser.value;
  var loginpassword = document.userloginform.loginpass.value;
var postData = "username=" + loginusername + "&password=" + loginpassword;

        if(loginusername == "") {
    alert('You must enter your Username / Password');
    return false;
  }
        if(loginpassword == "") {
    alert('You must enter your Username / Password');
    return false;
  }
  
		if((loginusername.value != "") && (loginpassword.value != "")){
			    Shadowbox.open({
        player:     'html',
        title:      'Logging In...',
        content:    '<br><br><b><center>Processing Log In. Please Stand By.</center></b>',
        height:     90,
        width:      350
    });

	}
	
var responseSuccess = function(o){
	if(o.responseText !== undefined){
	if(o.responseText == 1){
				    Shadowbox.open({
        player:     'html',
        title:      'Welcome Back <b>' + loginusername + '</b>,',
        content:    '<br><br><center>You Logged In Successfully. You can now access Live Panel and Members Area.</center>',
        height:     90,
        width:      360
    });
					
///	

var leftlivepanel = document.getElementById('leftlivepanel');

var responseSuccess = function(o){
	if(o.responseText !== undefined){
	leftlivepanel.innerHTML = o.responseText;
	}
}	
var responseFailure = function(o){
alert("Error in getting data... Please try again!");
}
var callback =
{
  success:responseSuccess,
  failure:responseFailure
};
var hiurl = "leftlivepanel.php?loggedin=1";
var HiJax = YAHOO.util.Connect.asyncRequest('GET',hiurl, callback);
if(YAHOO.util.Connect.isCallInProgress(HiJax)){
	leftlivepanel.innerHTML = '<img src="images/loading.gif" width="16" height="16" />';
	}	
	
///

	}else{
					    Shadowbox.open({
        player:     'html',
        title:      'Problem in Login',
        content:    '<br><br><b><center>' + o.responseText + '</center></b>',
        height:     90,
        width:      350
    });

	}

	}
}
var responseFailure = function(o){
alert("Error in getting data... Please try again!");	
}
var callback =
{
  success:responseSuccess,
  failure:responseFailure
};

var hiurl = "userlogin.php";
var HiJaxcart = YAHOO.util.Connect.asyncRequest('POST',hiurl, callback, postData);
if(YAHOO.util.Connect.isCallInProgress(HiJaxcart)){
				    Shadowbox.open({
        player:     'html',
        title:      'Logging In...',
        content:    '<br><br><center>Login in Process... Please Stand by.</center>',
        height:     90,
        width:      350
    });
	}
}

//////////////////
//// User Logout
//////////////////

function userlogout(){
var leftlivepanel = document.getElementById('leftlivepanel');

var responseSuccess = function(o){
	if(o.responseText !== undefined){
	leftlivepanel.innerHTML = o.responseText;
	}
}	
var responseFailure = function(o){
alert("Error in getting data... Please try again!");
}
var callback =
{
  success:responseSuccess,
  failure:responseFailure
};
var hiurl = "leftlivepanel.php?userlogout=1";
var HiJax = YAHOO.util.Connect.asyncRequest('GET',hiurl, callback);
if(YAHOO.util.Connect.isCallInProgress(HiJax)){
	leftlivepanel.innerHTML = '<img src="images/loading.gif" width="16" height="16" />';
	}	
}

//////////////////
//// YMenu JS
//////////////////
            YAHOO.util.Event.onContentReady("productsandservices", function () {
                var Dom = YAHOO.util.Dom,
                    oAnim;
                function onSubmenuBeforeShow(p_sType, p_sArgs) {
                    var oBody,
                        oShadow,
                        oUL;
                    if (this.parent) {
                        oShadow = this.element.lastChild;
                        oShadow.style.height = "0px";
                        if (oAnim && oAnim.isAnimated()) {
                            oAnim.stop();
                            oAnim = null;
                        }
                        oBody = this.body;
                        if (this.parent && 
                            !(this.parent instanceof YAHOO.widget.MenuBarItem) && 
                            YAHOO.env.ua.gecko) {
                            Dom.setStyle(oBody, "width", (oBody.clientWidth + "px"));
                        }
                        Dom.setStyle(oBody, "overflow", "hidden");
                        oUL = oBody.getElementsByTagName("ul")[0];
                        Dom.setStyle(oUL, "marginTop", ("-" + oUL.offsetHeight + "px"));
                    }
                }
                function onTween(p_sType, p_aArgs, p_oShadow) {
                    if (this.cfg.getProperty("iframe")) {
                        this.syncIframe();
                    }
                    if (p_oShadow) {
                        p_oShadow.style.height = this.element.offsetHeight + "px";
                    }
                }
                function onAnimationComplete(p_sType, p_aArgs, p_oShadow) {
                    var oBody = this.body,
                        oUL = oBody.getElementsByTagName("ul")[0];
                    if (p_oShadow) {
                        p_oShadow.style.height = this.element.offsetHeight + "px";
                    }
                    Dom.setStyle(oUL, "marginTop", "");
                    Dom.setStyle(oBody, "overflow", "");
                    if (this.parent && 
                        !(this.parent instanceof YAHOO.widget.MenuBarItem) && 
                        YAHOO.env.ua.gecko) {
                        Dom.setStyle(oBody, "width", "");
                    }
                }
                function onSubmenuShow(p_sType, p_sArgs) {
                    var oElement,
                        oShadow,
                        oUL;
                    if (this.parent) {
                        oElement = this.element;
                        oShadow = oElement.lastChild;
                        oUL = this.body.getElementsByTagName("ul")[0];
                        oAnim = new YAHOO.util.Anim(oUL, 
                            { marginTop: { to: 0 } },
                            .5, YAHOO.util.Easing.easeOut);
                        oAnim.onStart.subscribe(function () {
                            oShadow.style.height = "100%";
                        });
                        oAnim.animate();
                        if (YAHOO.env.ua.ie) {
                            oShadow.style.height = oElement.offsetHeight + "px";
                            oAnim.onTween.subscribe(onTween, oShadow, this);
                        }
                        oAnim.onComplete.subscribe(onAnimationComplete, oShadow, this);
                    }
                }
                var oMenuBar = new YAHOO.widget.MenuBar("productsandservices", { 
                                                            autosubmenudisplay: true, 
                                                            hidedelay: 750, 
                                                            lazyload: true });
                oMenuBar.subscribe("beforeShow", onSubmenuBeforeShow);
                oMenuBar.subscribe("show", onSubmenuShow);
                oMenuBar.render();            
            
            });