// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// This is used in the RMA page to hide/show table rows.
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function SwapVisibility(myControlNumber)
{
    var myControl1 = document.getElementById("CourierRow" + myControlNumber);

    if (myControl1.style.display == "none")
    {
        myControl1.style.display = "";
    }
    else
    {
        myControl1.style.display = "none";
    }
}

function printpage()
{
window.print()
}


function SwapTab(myCTRLNo)
{

var myCTRL;
var mySelectedCTRLName, myNOTSelectedCTRLName;

mySelectedCTRLName = ("tab" + myCTRLNo);
myCTRL = document.getElementById( mySelectedCTRLName ).style.background="url(/mt/images/prod_current_bgright.gif) bottom right no-repeat;";
myCTRL = document.getElementById( mySelectedCTRLName ).style.padding="2px 3px 3px 0px;";


mySelectedCTRLName = ("anchor" + myCTRLNo);
myCTRL = document.getElementById( mySelectedCTRLName ).style.background="url(/mt/images/prod_current_bgleft2.gif) bottom left no-repeat;";
myCTRL = document.getElementById( mySelectedCTRLName ).style.color="#fff;";
myCTRL = document.getElementById( mySelectedCTRLName ).style.padding="4px 4px 4px 7px;";




// Make others non-selected
for (count = 1; count < 4; count++)
{
    if (count != myCTRLNo)
    {
        myNOTSelectedCTRLName = ("tab" + count);
        myCTRL = document.getElementById( myNOTSelectedCTRLName ).style.background="url(/mt/images/prodtabs_bg_right.gif) bottom right no-repeat;";
        myCTRL = document.getElementById( myNOTSelectedCTRLName ).style.padding="2px 3px 3px 0px;";
        

        myNOTSelectedCTRLName = ("anchor" + count);
        myCTRL = document.getElementById( myNOTSelectedCTRLName ).style.background="url(/mt/images/prodtabs_bg_left2.gif) bottom left no-repeat;";
        myCTRL = document.getElementById( myNOTSelectedCTRLName ).style.color="#fff;";

    
    }
}

//alert("j");
}


    
var InsertImg;

function showUploader(txtBox, win_title, u_path, theformname)
{
    InsertImg = popUpWin( ('insert_img3.asp?txtBox=' + txtBox + '&upload_path=' + u_path + '&title=' + win_title + '&theformname=' + theformname), 500, 500, 'status=yes,');
}

function popUpWin (url, width, height, options)
{
    
    dlgCleanUp();
    var leftPos = (screen.availWidth - width) / 2;
    var topPos = (screen.availHeight - height) / 2;
    options += 'width=' + width + ',height=' + height + ',left=' + leftPos + ',top=' + topPos;

    return window.open(url, 'myWindow', options);

}

function dlgCleanUp()
{
    if(InsertImg != null)
    {
        InsertImg.close();
        InsertImg=null;
    }
}

function insertFilename(myFilename, txtBox, theformname)
{
    var ctrl_txt_file = document.getElementById(txtBox);
    ctrl_txt_file.value=myFilename;
    
    dlgCleanUp();
    
    var myform = document.getElementById(theformname);
    //alert("text box:" + txtBox);
    //alert("form name:" + theformname);
    //alert(myform.txt_img_small900.value);
    myform.submit();
   
}

function textLimit(field, maxlen)
{
    if (field.value.length > maxlen + 1)
    {
        if (field.value.length > maxlen)
        {
            field.value = field.value.substring(0, maxlen);
        }
    }
} 

function CheckAddBasket(myform) 
{
    var ctrl_txt_qty = myform.qty.value;
    //alert(ctrl_txt_qty);
    if (ctrl_txt_qty == "" )
    {
        return false;
    }
    return true;
    
}


// New left menu with sub sub type.
menu_status = new Array();

function initLeftMenu()
{
	if (document.getElementById)
	{
		var groupID = getCookie("mt-electronics-group");

		if (groupID != '')
		{
			var switch_id = document.getElementById(groupID);
			switch_id.className = 'show';
			menu_status[groupID] = 'show';
			
			var manID = getCookie("mt-electronics-manufacturer");
			if (manID != '')
			{
				switch_id = document.getElementById(manID);
				switch_id.className = 'show';
				menu_status[manID] = 'show';
			}
		}
	}
}

function showHide(theid, type)
{
    if (document.getElementById)
	{
		var switch_id = document.getElementById(theid);
		
        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
		   setCookie("mt-electronics-" + type, theid, 1)
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}

// New left menu with sub sub type cookie utlity function.
function setCookie(c_name, value, expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

// New left menu with sub sub type cookie utlity function.
function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}